add sub function (class-ish form)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 28 Feb 2020 20:27:29 +0000 (20:27 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 28 Feb 2020 20:27:29 +0000 (20:27 +0000)
experiments5/ringoscillator.py

index 8451eb5b0b37447457172c1d0b613eb38a380bd4..edb5107cf1de2da1ee75a3485239ec650e38d4d1 100755 (executable)
@@ -239,6 +239,123 @@ def add ( cell, **kw ):
     #plugins.RSavePlugin.ScriptMain( **kw )
 
 
+###################
+# sub
+
+def sub ( cell, **kw ):
+    editor = None
+    if kw.has_key('editor') and kw['editor']:
+      editor = kw['editor']
+
+    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' )
+
+    #cell = af.getCell( 'sub', CRL.Catalog.State.Logical )
+    print cell.getNet('a(0)')
+
+    if not cell:
+      print '[ERROR] Unable to load cell "alu16.vst", aborting .'
+      return False
+    kw[ 'cell' ] = cell
+
+    width = 350.0
+    height = 405.0
+
+    ab = Box( l(    0.0 )
+            , l(    0.0 )
+            , l( width )
+            , l( height ) )
+
+    cellGauge   = af.getCellGauge()
+    spaceMargin = (Cfg.getParamPercentage('etesian.spaceMargin').asPercentage()+5) / 100.0
+    aspectRatio =  Cfg.getParamPercentage('etesian.aspectRatio').asPercentage()    / 100.0
+    clocktree.ClockTree.computeAbutmentBox( cell, spaceMargin, aspectRatio, cellGauge )
+    ab2 = cell.getAbutmentBox()
+    print "box", ab, ab.getHeight(), ab.getWidth()
+    print "calc box", ab2, ab2.getHeight(), ab2.getWidth()
+
+    #height = ab.getHeight()
+    #width = ab.getWidth()
+
+    #UpdateSession.open()
+    cell.setAbutmentBox( ab )
+
+    for i in range(16):
+      if True:
+          x = 20.0*i + 10.0
+          y = height
+          Pin.create( cell.getNet('a(%d)' % i)
+                , 'a(%d).0' % i
+                , Pin.Direction.NORTH
+                , Pin.PlacementStatus.FIXED
+                , metal3
+                , l( x ), l( y - 0 )   # Position.
+                , l( 2.0 )            , l( 2.0 )  # Size.
+                )
+    for i in range(16):
+      if True:
+          Pin.create( cell.getNet('o(%d)' % i)
+                , 'o(%d).0' % i
+                , Pin.Direction.SOUTH
+                , Pin.PlacementStatus.FIXED
+                , metal3
+                , l( 10.0*i + 100.0 ), l( 0)   # Position.
+                , l( 2.0 )            , l( 2.0 )  # Size.
+                )
+
+    for i in range(16):
+      if True:
+          net = cell.getNet('b(%d)' % i)
+          x = 20.0*i + 10.0 + 10
+          y = height - 0
+          #build_downtrace(net, metal3, x, y+11, y)
+          #continue
+          Pin.create( net
+                , 'b(%d).0' % i
+                , Pin.Direction.NORTH
+                , Pin.PlacementStatus.FIXED
+                , metal3
+                , l( x ), l( y - 0 )   # Position.
+                , l( 2.0 )            , l( 2.0 )  # Size.
+                )
+    if False:
+      Pin.create( cell.getNet('rst')
+              , 'p_reset.0'
+              , Pin.Direction.WEST
+              , Pin.PlacementStatus.FIXED
+              , metal2
+              , l(   0.0 )
+              , l( 140.0 )
+              , l(   2.0 )
+              , l(   2.0 )
+              )
+    #UpdateSession.close()
+
+    if True:
+          if editor: editor.setCell( cell )
+
+          etesian = Etesian.EtesianEngine.create(cell)
+          etesian.place()
+
+          katana = Katana.KatanaEngine.create(cell)
+          katana.digitalInit          ()
+          #katana.runNegociatePreRouted()
+          print dir(katana)
+          katana.runGlobalRouter      (0)
+          katana.loadGlobalRouting    ( Anabatic.EngineLoadGrByNet )
+          katana.layerAssign          ( Anabatic.EngineNoNetLayerAssign )
+          katana.runNegociate         ( Katana.Flags.NoFlags )
+          katana.finalizeLayout       ()
+          print dir(katana)
+          success = katana.getSuccessState()
+          katana.destroy()
+
+    #af.saveCell( cell, CRL.Catalog.State.Views )
+    #plugins.RSavePlugin.ScriptMain( **kw )
+
 
 #def toDbU(v): return DbU.fromLambda(v)
 def toDbU(v): return l(v)
@@ -487,13 +604,7 @@ class Model (object):
         print '[ERROR] Model.build() base class method should never be called.'
 
 
-class Add (Model):
-
-    def build(self):
-        #self.setAbutmentBox(
-            #Box(toDbU(0.0), toDbU(0.0), toDbU(1595.0), toDbU(450.0)))
-        add(self.cell)
-        self.buildPower()
+class Ringed (Model):
 
     def addFillers(self):
         self.addFillersRow(toDbU(1580.0), toDbU(0.0),
@@ -695,17 +806,33 @@ class Add (Model):
 
         return
 
+class Add(Ringed):
+
+    def build(self):
+        add(self.cell)
+        self.buildPower()
+
+
+class Sub(Ringed):
+
+    def build(self):
+        sub(self.cell)
+        self.buildPower()
+
 
 def ScriptMain(**kw):
-    editor = None
-    if "editor" in kw and kw["editor"]:
-        editor = kw["editor"]
-
-    ringo = Add('add')
-    ringo.save()
-    if editor:
-        editor.setCell(ringo.getCell())
-        editor.fit()
+    #editor = None
+    #if "editor" in kw and kw["editor"]:
+    #    editor = kw["editor"]
+
+    add = Add('add')
+    add.save()
+    sub = Sub('sub')
+    sub.save()
+
+    #if editor:
+    #    editor.setCell(ringo.getCell())
+    #    editor.fit()
     return True