# -*- Mode:Python; explicit-buffer-name: "technology.conf<freepdk_45>" -*-
#
# FreePDK 45 nanometers.
#
# Provides standard settings for:
# - <viewerConfig>
# - <realLayersTable>
# - <compositeLayersTable>
# - <symbolicLayersTable>

from Hurricane          import DbU
from helpers            import sysConfDir
from helpers            import l, u, n
from helpers.Technology import initTechno

initTechno( { 'name'             : 'freepdk_45'
            , 'precision'        : 2
            , 'gridValue'        : 0.0025
            , 'gridUnit'         : DbU.UnitPowerMicro
            , 'gridsPerLambda'   : 18
            , 'symbolicGridStep' : 1.0
            , 'polygonStep'      : 1.0
            } )

# Contains the layers
execfile( helpers.sysConfDir+'/common/technology.conf' )


# Format of <layersExtensionsTable>:
#    Each entry is a pair of (string, value).
#    * string: a synthetic way to designate the real or symbolic layer on
#              which it applies, an optional sub layer (BasicLayer) in case
#              where there is more than one, and the dimension name.
#    * value : the rule (dimension) value.
#    Values/dimensions must be given using one of the following conversion
#    function:
#    * l(value) : value expressed in lambda (symbolic).
#    * u(value) : value is expressed in microns.
#    * n(value) : value is expressed in nanometers.

layersExtensionsTable = symbolicLayersExtensionsTable + \
    [ ('metal1.minimalSpacing'              , u( 0.065))
    , ('metal2.minimalSpacing'              , u( 0.075))
    , ('metal3.minimalSpacing'              , u( 0.07 ))
    , ('metal4.minimalSpacing'              , u( 0.14 ))
    , ('metal5.minimalSpacing'              , u( 0.14 ))
    , ('metal6.minimalSpacing'              , u( 0.14 ))
    , ('metal7.minimalSpacing'              , u( 0.4  ))
    , ('metal8.minimalSpacing'              , u( 0.4  ))
    , ('metal9.minimalSpacing'              , u( 0.8  ))
    , ('metal10.minimalSpacing'             , u( 0.8  ))

    # VIAs (i.e. Metal <--> Metal) (real).
    , ('via12.minimum.side'                 , u( 0.065))
      # This is the rule as defined in LEF, but seems wrong to me.
   #, ('via12.metal1.enclosure'             , (u(0.035 ), u(0.0  )) )
    , ('via12.metal1.enclosure'             , (u(0.0   ), u(0.035)) )
    , ('via12.metal2.enclosure'             , (u(0.0025), u(0.035)) )
    , ('via23.minimum.side'                 ,  u(0.070 ))
    , ('via23.metal2.enclosure'             , (u(0.0   ), u(0.035)) )
    , ('via23.metal3.enclosure'             , (u(0.035 ), u(0.0  )) )
    , ('via34.minimum.side'                 ,  u(0.070 ))
    , ('via34.metal3.enclosure'             , (u(0.035 ), u(0.0  )) )
    , ('via34.metal4.enclosure'             ,  u(0.035 ))
    , ('via45.minimum.side'                 ,  u(0.140 ))
    , ('via45.metal4.enclosure'             ,  u(0.0   ))
    , ('via45.metal5.enclosure'             ,  u(0.0   ))
    , ('via56.minimum.side'                 ,  u(0.140 ))
    , ('via56.metal5.enclosure'             ,  u(0.0   ))
    , ('via56.metal6.enclosure'             ,  u(0.0   ))
    , ('via67.minimum.side'                 ,  u(0.140 ))
    , ('via67.metal6.enclosure'             ,  u(0.0   ))
    , ('via67.metal7.enclosure'             ,  u(0.130 ))
    , ('via78.minimum.side'                 ,  u(0.200 ))
    , ('via78.metal7.enclosure'             ,  u(0.0   ))
    , ('via78.metal8.enclosure'             ,  u(0.0   ))
    , ('via89.minimum.side'                 ,  u(0.200 ))
    , ('via89.metal8.enclosure'             ,  u(0.0   ))
    , ('via89.metal9.enclosure'             ,  u(0.200 ))
    , ('via910.minimum.side'                ,  u(0.400 ))
    , ('via910.metal9.enclosure'            ,  u(0.0   ))
    , ('via910.metal10.enclosure'           ,  u(0.0   ))
    ]


# Table guessed from the Cadence configuration files:
#     FreePDK45/ncsu_basekit/techfile/FreePDK45.tf
#
# Format of an entry in the table:
#     (Symbolic_Name, CIF_Name, GDSII_Number)
#gdsLayersTable = \
#    ( ("pWell"   , "CWN"    ,  2, 0)
#    , ("nWell"   , "CWP"    ,  3, 0)
#    , ("active"  , "CAA"    ,  1, 0)
#    , ("pImplant", "CSP"    ,  5, 0)
#    , ("nImplant", "CSN"    ,  4, 0)
#    , ("poly"    , "CPG"    ,  9, 0)
#    , ("cut0"    , "CCC"    , 10, 0)
#    , ("metal1"  , "CM1"    , 11, 0)
#    , ("cut1"    , "CV1"    , 12, 0)
#    , ("metal2"  , "CM2"    , 13, 0)
#    , ("cut2"    , "CV2"    , 14, 0)
#    , ("metal3"  , "CM3"    , 15, 0)
#    , ("cut3"    , "CV3"    , 16, 0)
#    , ("metal4"  , "CM4"    , 17, 0)
#    , ("cut4"    , "CV4"    , 18, 0)
#    , ("metal5"  , "CM5"    , 19, 0)
#    , ("cut5"    , "CV5"    , 20, 0)
#    , ("metal6"  , "CM6"    , 21, 0)
#    , ("cut6"    , "CV6"    , 22, 0)
#    , ("metal7"  , "CM7"    , 23, 0)
#    , ("cut7"    , "CV7"    , 24, 0)
#    , ("metal8"  , "CM8"    , 25, 0)
#    , ("cut8"    , "CV8"    , 26, 0)
#    , ("metal9"  , "CM9"    , 27, 0)
#    , ("cut9"    , "CV9"    , 28, 0)
#    , ("metal10" , "CM10"   , 29, 0)
#    )


# Table guessed from the GDSII layouts of the cells.
#    FreePDK45/osu_soc/lib/source/gds/*.gds
#
# Format of an entry in the table:
#     (Symbolic_Name, CIF_Name, GDSII_Number)
gdsLayersTable = \
    ( ("pWell"   , "CWN"    ,  2, 0)
    , ("nWell"   , "CWP"    ,  1, 0)
    , ("active"  , "CAA"    ,  5, 0)
    , ("pImplant", "CSP"    ,  8, 0)
    , ("nImplant", "CSN"    ,  7, 0)
    , ("poly"    , "CPG"    , 15, 0)
    , ("cut0"    , "CCC"    , 16, 0)
    , ("metal1"  , "CM1"    , 21, 0)
    , ("cut1"    , "CV1"    , 22, 0)
    , ("metal2"  , "CM2"    , 23, 0)
    , ("cut2"    , "CV2"    , 24, 0)
    , ("metal3"  , "CM3"    , 25, 0)
    , ("cut3"    , "CV3"    , 26, 0)
    , ("metal4"  , "CM4"    , 27, 0)
    , ("cut4"    , "CV4"    , 28, 0)
    , ("metal5"  , "CM5"    , 29, 0)
    , ("cut5"    , "CV5"    , 30, 0)
    , ("metal6"  , "CM6"    , 31, 0)
    , ("cut6"    , "CV6"    , 32, 0)
    , ("metal7"  , "CM7"    , 33, 0)
    , ("cut7"    , "CV7"    , 34, 0)
    , ("metal8"  , "CM8"    , 35, 0)
    , ("cut8"    , "CV8"    , 36, 0)
    , ("metal9"  , "CM9"    , 37, 0)
    , ("cut9"    , "CV9"    , 38, 0)
    , ("metal10" , "CM10"   , 39, 0)
    )
