--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import sys
+import re
+import traceback
+import os.path
+import optparse
+import Cfg
+import Hurricane
+from Hurricane import DbU
+from Hurricane import DataBase
+from Hurricane import UpdateSession
+from Hurricane import Breakpoint
+from Hurricane import Box
+from Hurricane import Transformation
+from Hurricane import Instance
+from Hurricane import Pin
+import Viewer
+import CRL
+import Etesian
+import Anabatic
+import Katana
+import Unicorn
+from helpers import l, u, n
+import plugins.RSavePlugin
+import symbolic.cmos
+
+af = CRL.AllianceFramework.get()
+
+Cfg.Configuration.pushDefaultPriority( Cfg.Parameter.Priority.UserFile )
+
+cellsTop = '~/alliance-check-toolkit/cells'
+env = af.getEnvironment()
+env.addSYSTEM_LIBRARY( library=cellsTop+'/nsxlib', mode=CRL.Environment.Prepend )
+env.addSYSTEM_LIBRARY( library=cellsTop+'/mpxlib', mode=CRL.Environment.Prepend )
+
+
+Cfg.getParamBool ( 'misc.catchCore' ).setBool ( False )
+Cfg.getParamBool ( 'misc.info' ).setBool ( False )
+Cfg.getParamBool ( 'misc.paranoid' ).setBool ( False )
+Cfg.getParamBool ( 'misc.bug' ).setBool ( False )
+Cfg.getParamBool ( 'misc.logMode' ).setBool ( True )
+Cfg.getParamBool ( 'misc.verboseLevel1' ).setBool ( True )
+Cfg.getParamBool ( 'misc.verboseLevel2' ).setBool ( True )
+#Cfg.getParamInt ( 'misc.minTraceLevel' ).setInt ( 159 )
+#Cfg.getParamInt ( 'misc.maxTraceLevel' ).setInt ( 160 )
+Cfg.getParamEnumerate ( 'etesian.effort' ).setInt ( 2 )
+Cfg.getParamPercentage( 'etesian.spaceMargin' ).setPercentage( 20.0 )
+Cfg.getParamPercentage( 'etesian.aspectRatio' ).setPercentage( 100.0 )
+Cfg.getParamBool ( 'etesian.uniformDensity' ).setBool ( True )
+Cfg.getParamInt ( 'anabatic.edgeLenght' ).setInt ( 24 )
+Cfg.getParamInt ( 'anabatic.edgeWidth' ).setInt ( 8 )
+Cfg.getParamString ( 'anabatic.topRoutingLayer' ).setString ( 'METAL4')
+Cfg.getParamInt ( 'katana.eventsLimit' ).setInt ( 1000000 )
+Cfg.getParamInt ( 'katana.hTracksReservedLocal' ).setInt ( 7 )
+Cfg.getParamInt ( 'katana.vTracksReservedLocal' ).setInt ( 6 )
+#Cfg.getParamInt ( 'clockTree.minimumSide' ).setInt ( l(1000) )
+
+env = af.getEnvironment()
+env.setCLOCK( '^clk$|m_clock' )
+env.setPOWER( 'vdd' )
+env.setGROUND( 'vss' )
+
+Cfg.Configuration.popDefaultPriority()
+
+
+def add ( **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' )
+
+ ###################
+ # add
+
+ cell = af.getCell( 'add', 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
+
+ ab = Box( l( 0.0 )
+ , l( 0.0 )
+ , l( 2000.0 )
+ , l( 800.0 ) )
+
+ UpdateSession.open()
+ cell.setAbutmentBox( ab )
+
+ for i in range(16):
+ Pin.create( cell.getNet('a(%d)' % i)
+ , 'a(%d).0' % i
+ , Pin.Direction.SOUTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 50.0 ) , l( 0.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+ if False:
+ Pin.create( cell.getNet('b(%d)' % i)
+ , 'b(%d).0' % i
+ , Pin.Direction.EAST
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 0.0 ), l( 100.0*i + 50.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+ Pin.create( cell.getNet('o(%d)' % i)
+ , 'o(%d).0' % i
+ , Pin.Direction.SOUTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 20.0 ) , l( 0.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 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 sub(**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' )
+
+ ###################
+ # sub
+
+ 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
+
+ ab = Box( l( 0.0 )
+ , l( 0.0 )
+ , l( 2000.0 )
+ , l( 800.0 ) )
+
+ UpdateSession.open()
+ cell.setAbutmentBox( ab )
+
+ for i in range(16):
+ Pin.create( cell.getNet('a(%d)' % i)
+ , 'a(%d).0' % i
+ , Pin.Direction.SOUTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 50.0 ) , l( 0.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+ if False:
+ Pin.create( cell.getNet('b(%d)' % i)
+ , 'b(%d).0' % i
+ , Pin.Direction.EAST
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 0.0 ), l( 100.0*i + 50.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+ Pin.create( cell.getNet('o(%d)' % i)
+ , 'o(%d).0' % i
+ , Pin.Direction.SOUTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 20.0 ) , l( 0.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 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 )
+
+ print "done with add and sub"
+
+def alu_hier(**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' )
+
+ ################# SNX
+ #
+
+ cell = af.getCell( 'alu_hier', CRL.Catalog.State.Logical )
+ if not cell:
+ print '[ERROR] Unable to load cell "snx.vst", aborting .'
+ return False
+ kw[ 'cell' ] = cell
+
+ ab = Box( l( 0.0 )
+ , l( 0.0 )
+ , l( 3100.0 )
+ , l( 4100.0 ) )
+
+ UpdateSession.open()
+ cell.setAbutmentBox( ab )
+
+ for i in range(16):
+ Pin.create( cell.getNet('a(%d)' % i)
+ , 'a(%d).0' % i
+ , Pin.Direction.SOUTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 50.0 ) , l( 0.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+ Pin.create( cell.getNet('b(%d)' % i)
+ , 'b(%d).0' % i
+ , Pin.Direction.SOUTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 50.0 ) , l( 0.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+ Pin.create( cell.getNet('o(%d)' % i)
+ , 'o(%d).0' % i
+ , Pin.Direction.NORTH
+ , Pin.PlacementStatus.FIXED
+ , metal3
+ , l( 100.0*i + 25.0 ) , l( 0.0 ) # Position.
+ , l( 2.0 ) , l( 2.0 ) # Size.
+ )
+
+ 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 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 )
+
+ return success
+
+
+if __name__ == '__main__':
+ success = sub()
+ success = add()
+ success = alu_hier()
+ shellSuccess = 0
+ if not success: shellSuccess = 1
+
+ sys.exit( shellSuccess )
+