Generalize layer creation/retrieval.
authorJock Tanner <tanner.of.kha@gmail.com>
Mon, 16 Mar 2020 19:01:52 +0000 (19:01 +0000)
committerJock Tanner <tanner.of.kha@gmail.com>
Mon, 16 Mar 2020 19:01:52 +0000 (19:01 +0000)
experiments7/doAlu16.py

index 21bb60148f3e77afd1c19dcebb2a18a5067980f0..674f7ac36c8455f68be1b448cfb85618430a34c2 100755 (executable)
@@ -22,34 +22,18 @@ import symbolic.cmos  # do not remove
 af = CRL.AllianceFramework.get()
 
 
-def toDbU(l):
-    return DbU.fromLambda(l)
-
-
-def createVertical(contacts, x, layer, width=None):
-    def yincrease(lhs, rhs):
-        return int(lhs.getY() - rhs.getY())
-
-    contacts.sort(yincrease)
+def get_layer(name, layer_cache={}):
+    """ Creates a new layer or returns it from cache. """
+    if name in layer_cache:
+        return layer_cache[name]
 
-    if width is None: width = l(2.0)
+    layer = DataBase.getDB().getTechnology().getLayer(name)
+    layer_cache[name] = layer
+    return layer
 
-    for i in range(1, len(contacts)):
-        print("create vert", contacts[i - 1], contacts[i], layer, x, width)
-        v = Vertical.create(contacts[i - 1], contacts[i], layer, x, width)
-        print("v", v)
 
-
-def build_downtrace(net, layer, x, y, y1):
-    contacts = [
-        Contact.create(net, layer, l(x), l(y), l(2.0), l(2.0)),
-        Contact.create(net, layer, l(x), l(y1), l(2.0), l(2.0)),
-    ]
-
-    createVertical(contacts, l(x), layer)
-    print("slaves", contacts[-1].getSlaveComponents())
-    for component in contacts[-1].getSlaveComponents():
-        NetExternalComponents.setExternal(component)
+def toDbU(l):
+    return DbU.fromLambda(l)
 
 
 def placeAndRoute(cell):
@@ -113,13 +97,13 @@ def add(**kwargs):
 
     db = DataBase.getDB()
     print(db, dir(db))
-    METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2')
-    METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3')
-    METAL5 = DataBase.getDB().getTechnology().getLayer('METAL5')
-    BLOCKAGE2 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE2')
-    BLOCKAGE3 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE3')
-    BLOCKAGE4 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE4')
-    BLOCKAGE5 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE5')
+    METAL2 = get_layer('METAL2')
+    METAL3 = get_layer('METAL3')
+    METAL5 = get_layer('METAL5')
+    BLOCKAGE2 = get_layer('BLOCKAGE2')
+    BLOCKAGE3 = get_layer('BLOCKAGE3')
+    BLOCKAGE4 = get_layer('BLOCKAGE4')
+    BLOCKAGE5 = get_layer('BLOCKAGE5')
 
     cell = af.getCell('add', CRL.Catalog.State.Logical)
     print(cell.getNet('a(0)'))
@@ -225,13 +209,13 @@ def sub(**kwargs):
 
     db = DataBase.getDB()
     print(db, dir(db))
-    METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2')
-    METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3')
-    METAL5 = DataBase.getDB().getTechnology().getLayer('METAL5')
-    BLOCKAGE2 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE2')
-    BLOCKAGE3 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE3')
-    BLOCKAGE4 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE4')
-    BLOCKAGE5 = DataBase.getDB().getTechnology().getLayer('BLOCKAGE5')
+    METAL2 = get_layer('METAL2')
+    METAL3 = get_layer('METAL3')
+    METAL5 = get_layer('METAL5')
+    BLOCKAGE2 = get_layer('BLOCKAGE2')
+    BLOCKAGE3 = get_layer('BLOCKAGE3')
+    BLOCKAGE4 = get_layer('BLOCKAGE4')
+    BLOCKAGE5 = get_layer('BLOCKAGE5')
 
     cell = af.getCell('sub', CRL.Catalog.State.Logical)
     print(cell.getNet('a(0)'))
@@ -337,8 +321,8 @@ def alu16(**kwargs):
 
     db = DataBase.getDB()
     print(db, dir(db))
-    METAL2 = DataBase.getDB().getTechnology().getLayer('METAL2')
-    METAL3 = DataBase.getDB().getTechnology().getLayer('METAL3')
+    METAL2 = get_layer('METAL2')
+    METAL3 = get_layer('METAL3')
 
     cell = af.getCell('alu16', CRL.Catalog.State.Logical)
     if not cell: