fa37bd8ce31896ebc6e2ed75049b476594603b93
2 # -*- coding: utf-8 -*-
11 from Hurricane
import DbU
12 from Hurricane
import DataBase
13 from Hurricane
import UpdateSession
14 from Hurricane
import Breakpoint
15 from Hurricane
import Box
16 from Hurricane
import Transformation
17 from Hurricane
import Instance
18 from Hurricane
import Contact
19 from Hurricane
import Vertical
20 from Hurricane
import Horizontal
21 from Hurricane
import Pin
22 from Hurricane
import NetExternalComponents
29 from helpers
import l
, u
, n
30 import clocktree
.ClockTree
31 import plugins
.RSavePlugin
32 import plugins
.ClockTreePlugin
35 af
= CRL
.AllianceFramework
.get()
38 def toDbU ( l
): return DbU
.fromLambda(l
)
40 def createVertical ( contacts
, x
, layer
, width
=None):
41 def yincrease ( lhs
, rhs
): return int(lhs
.getY() - rhs
.getY())
43 contacts
.sort( yincrease
)
45 if width
is None: width
= l(2.0)
47 for i
in range(1,len(contacts
)):
48 print "create vert", contacts
[i
-1], contacts
[i
], layer
, x
, width
49 v
= Vertical
.create( contacts
[i
-1], contacts
[i
], layer
, x
, width
)
53 def createHorizontal ( contactPaths
, y
, layer
, width
=None):
54 def xincrease ( lhs
, rhs
): return int(lhs
.getX() - rhs
.getX())
56 contacts
= contactPaths
58 if width
is None: width
= l(2.0)
60 contacts
.sort( xincrease
)
62 for i
in range(1,len(contacts
)):
63 Horizontal
.create( contacts
[i
-1], contacts
[i
], layer
, y
, width
)
66 def build_crosstrace(net
, via
, layer
, x
, x1
, y
):
69 [ Contact
.create( net
, via
, l(x
), l(y
), l(1.0), l(1.0) )
70 , Contact
.create( net
, via
, l(x1
), l(y
), l(1.0), l(1.0) )
73 createHorizontal( contacts
, l(y
), layer
)
74 print "slaves", contacts
[-1].getSlaveComponents()
75 for component
in contacts
[-1].getSlaveComponents():
76 NetExternalComponents
.setExternal(component
)
78 def build_downtrace(net
, via
, layer
, x
, y
, y1
):
81 [ Contact
.create( net
, via
, l(x
), l(y
), l(1.0), l(1.0) )
82 , Contact
.create( net
, via
, l(x
), l(y1
), l(1.0), l(1.0) )
85 createVertical( contacts
, l(x
), layer
)
86 print "slaves", contacts
[-1].getSlaveComponents()
87 for component
in contacts
[-1].getSlaveComponents():
88 NetExternalComponents
.setExternal(component
)
93 Cfg
.Configuration
.pushDefaultPriority( Cfg
.Parameter
.Priority
.UserFile
)
95 cellsTop
= '~/alliance-check-toolkit/cells'
96 env
= af
.getEnvironment()
97 env
.addSYSTEM_LIBRARY( library
=cellsTop
+'/nsxlib', mode
=CRL
.Environment
.Prepend
)
98 env
.addSYSTEM_LIBRARY( library
=cellsTop
+'/mpxlib', mode
=CRL
.Environment
.Prepend
)
101 Cfg
.getParamBool ( 'misc.catchCore' ).setBool ( False )
102 Cfg
.getParamBool ( 'misc.info' ).setBool ( False )
103 Cfg
.getParamBool ( 'misc.paranoid' ).setBool ( False )
104 Cfg
.getParamBool ( 'misc.bug' ).setBool ( False )
105 Cfg
.getParamBool ( 'misc.logMode' ).setBool ( True )
106 Cfg
.getParamBool ( 'misc.verboseLevel1' ).setBool ( True )
107 Cfg
.getParamBool ( 'misc.verboseLevel2' ).setBool ( True )
108 #Cfg.getParamInt ( 'misc.minTraceLevel' ).setInt ( 159 )
109 #Cfg.getParamInt ( 'misc.maxTraceLevel' ).setInt ( 160 )
110 Cfg
.getParamEnumerate ( 'etesian.effort' ).setInt ( 2 )
111 Cfg
.getParamPercentage( 'etesian.spaceMargin' ).setPercentage( 20.0 )
112 Cfg
.getParamPercentage( 'etesian.aspectRatio' ).setPercentage( 100.0 )
113 Cfg
.getParamBool ( 'etesian.uniformDensity' ).setBool ( True )
114 Cfg
.getParamInt ( 'anabatic.edgeLenght' ).setInt ( 24 )
115 Cfg
.getParamInt ( 'anabatic.edgeWidth' ).setInt ( 8 )
116 Cfg
.getParamString ( 'anabatic.topRoutingLayer' ).setString ( 'METAL5')
117 Cfg
.getParamInt ( 'katana.eventsLimit' ).setInt ( 1000000 )
118 Cfg
.getParamInt ( 'katana.hTracksReservedLocal' ).setInt ( 7 )
119 Cfg
.getParamInt ( 'katana.vTracksReservedLocal' ).setInt ( 6 )
120 #Cfg.getParamInt ( 'clockTree.minimumSide' ).setInt ( l(1000) )
122 env
= af
.getEnvironment()
123 env
.setCLOCK( '^clk$|m_clock' )
124 env
.setPOWER( 'vdd' )
125 env
.setGROUND( 'vss' )
127 Cfg
.Configuration
.popDefaultPriority()
134 if kw
.has_key('editor') and kw
['editor']:
135 editor
= kw
['editor']
137 db
= DataBase
.getDB()
139 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
140 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
141 metal5
= DataBase
.getDB().getTechnology().getLayer( 'metal5' )
143 cell
= af
.getCell( 'add', CRL
.Catalog
.State
.Logical
)
144 print cell
.getNet('a(0)')
147 print '[ERROR] Unable to load cell "alu16.vst", aborting .'
159 cellGauge
= af
.getCellGauge()
160 spaceMargin
= (Cfg
.getParamPercentage('etesian.spaceMargin').asPercentage()+5) / 100.0
161 aspectRatio
= Cfg
.getParamPercentage('etesian.aspectRatio').asPercentage() / 100.0
162 clocktree
.ClockTree
.computeAbutmentBox( cell
, spaceMargin
, aspectRatio
, cellGauge
)
163 ab2
= cell
.getAbutmentBox()
164 print "box", ab
, ab
.getHeight(), ab
.getWidth()
165 print "calc box", ab2
, ab2
.getHeight(), ab2
.getWidth()
167 #height = ab.getHeight()
168 #width = ab.getWidth()
171 cell
.setAbutmentBox( ab
)
177 Pin
.create( cell
.getNet('a(%d)' % i
)
179 , Pin
.Direction
.NORTH
180 , Pin
.PlacementStatus
.FIXED
182 , l( x
), l( y
- 0 ) # Position.
183 , l( 2.0 ) , l( 2.0 ) # Size.
187 Pin
.create( cell
.getNet('o(%d)' % i
)
189 , Pin
.Direction
.SOUTH
190 , Pin
.PlacementStatus
.FIXED
192 , l( 10.0*i
+ 100.0 ), l( 0) # Position.
193 , l( 2.0 ) , l( 2.0 ) # Size.
198 net
= cell
.getNet('b(%d)' % i
)
199 x
= 20.0*i
+ 10.0 + 10
201 #build_downtrace(net, metal3, x, y+11, y)
205 , Pin
.Direction
.NORTH
206 , Pin
.PlacementStatus
.FIXED
208 , l( x
), l( y
- 0 ) # Position.
209 , l( 2.0 ) , l( 2.0 ) # Size.
212 Pin
.create( cell
.getNet('rst')
215 , Pin
.PlacementStatus
.FIXED
222 UpdateSession
.close()
225 if editor
: editor
.setCell( cell
)
227 etesian
= Etesian
.EtesianEngine
.create(cell
)
230 katana
= Katana
.KatanaEngine
.create(cell
)
231 katana
.digitalInit ()
232 #katana.runNegociatePreRouted()
234 katana
.runGlobalRouter (0)
235 katana
.loadGlobalRouting ( Anabatic
.EngineLoadGrByNet
)
236 katana
.layerAssign ( Anabatic
.EngineNoNetLayerAssign
)
237 katana
.runNegociate ( Katana
.Flags
.NoFlags
)
238 katana
.finalizeLayout ()
240 success
= katana
.getSuccessState()
244 VIA23
= DataBase
.getDB().getTechnology().getLayer( 'VIA23' )
246 #net = cell.getNet('b(%d)' % 0)
247 net
= cell
.getNet('vdd')
248 build_downtrace(net
, VIA23
, metal2
, -5, -10, -20)
249 build_downtrace(net
, VIA23
, metal2
, -10, -10, -20)
250 build_crosstrace(net
, VIA23
, metal2
, -5, -10, -10)
251 build_crosstrace(net
, VIA23
, metal2
, -5, -10, -20)
254 net
= cell
.getNet('b(%d)' % i
)
255 x
= 20.0*i
+ 10.0 + 10
257 build_downtrace(net
, metal2
, x
, y
, y
+10)
258 ab
.inflate ( l(30.0) )
259 cell
.setAbutmentBox( ab
)
260 UpdateSession
.close()
262 #af.saveCell( cell, CRL.Catalog.State.Views )
263 plugins
.RSavePlugin
.ScriptMain( **kw
)
270 if kw
.has_key('editor') and kw
['editor']:
271 editor
= kw
['editor']
273 db
= DataBase
.getDB()
275 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
276 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
277 metal5
= DataBase
.getDB().getTechnology().getLayer( 'metal5' )
279 cell
= af
.getCell( 'sub', CRL
.Catalog
.State
.Logical
)
280 print cell
.getNet('a(0)')
283 print '[ERROR] Unable to load cell "alu16.vst", aborting .'
295 cellGauge
= af
.getCellGauge()
296 spaceMargin
= (Cfg
.getParamPercentage('etesian.spaceMargin').asPercentage()+5) / 100.0
297 aspectRatio
= Cfg
.getParamPercentage('etesian.aspectRatio').asPercentage() / 100.0
298 clocktree
.ClockTree
.computeAbutmentBox( cell
, spaceMargin
, aspectRatio
, cellGauge
)
299 ab2
= cell
.getAbutmentBox()
300 print "box", ab
, ab
.getHeight(), ab
.getWidth()
301 print "calc box", ab2
, ab2
.getHeight(), ab2
.getWidth()
303 #height = ab.getHeight()
304 #width = ab.getWidth()
307 cell
.setAbutmentBox( ab
)
313 Pin
.create( cell
.getNet('a(%d)' % i
)
315 , Pin
.Direction
.NORTH
316 , Pin
.PlacementStatus
.FIXED
318 , l( x
), l( y
- 0 ) # Position.
319 , l( 2.0 ) , l( 2.0 ) # Size.
323 Pin
.create( cell
.getNet('o(%d)' % i
)
325 , Pin
.Direction
.SOUTH
326 , Pin
.PlacementStatus
.FIXED
328 , l( 10.0*i
+ 100.0 ), l( 0) # Position.
329 , l( 2.0 ) , l( 2.0 ) # Size.
334 net
= cell
.getNet('b(%d)' % i
)
335 x
= 20.0*i
+ 10.0 + 10
337 #build_downtrace(net, metal3, x, y+11, y)
341 , Pin
.Direction
.NORTH
342 , Pin
.PlacementStatus
.FIXED
344 , l( x
), l( y
- 0 ) # Position.
345 , l( 2.0 ) , l( 2.0 ) # Size.
348 Pin
.create( cell
.getNet('rst')
351 , Pin
.PlacementStatus
.FIXED
358 UpdateSession
.close()
361 if editor
: editor
.setCell( cell
)
363 etesian
= Etesian
.EtesianEngine
.create(cell
)
366 katana
= Katana
.KatanaEngine
.create(cell
)
367 katana
.digitalInit ()
368 #katana.runNegociatePreRouted()
370 katana
.runGlobalRouter (0)
371 katana
.loadGlobalRouting ( Anabatic
.EngineLoadGrByNet
)
372 katana
.layerAssign ( Anabatic
.EngineNoNetLayerAssign
)
373 katana
.runNegociate ( Katana
.Flags
.NoFlags
)
374 katana
.finalizeLayout ()
376 success
= katana
.getSuccessState()
381 cell
.setAbutmentBox( ab
)
384 net
= cell
.getNet('b(%d)' % i
)
385 x
= 20.0*i
+ 10.0 + 10
387 build_downtrace(net
, metal2
, x
, y
, y
+10)
388 UpdateSession
.close()
390 #af.saveCell( cell, CRL.Catalog.State.Views )
391 plugins
.RSavePlugin
.ScriptMain( **kw
)
393 def connect ( instanceRef
, pin
, netRef
):
394 instance
= instanceRef
396 if isinstance(netRef
,str):
397 net
= self
.getNet( netRef
)
401 masterNet
= instance
.getMasterCell().getNet(pin
)
403 print '[ERR] Master cell "%s" of instance "%s" no connector named "%s".' \
404 % (instance
.getMasterCell().getName(), instance
.getName(), pin
)
406 instance
.getPlug( instance
.getMasterCell().getNet(pin
) ).setNet( net
)
408 def place ( instanceRef
, x
, y
, orient
):
409 print "place", instanceRef
, x
, y
, orient
410 instance
= instanceRef
411 instance
.setTransformation ( Transformation( x
, y
, orient
) )
412 instance
.setPlacementStatus( Instance
.PlacementStatus
.PLACED
)
414 def createInstance ( cell
, instanceName
, modelRef
, portmap
={}, transf
=None ):
415 instance
= cell
.getInstance( instanceName
)
417 print "found instace", instance
419 if isinstance(modelRef
,str):
420 model
= af
.getCell( modelRef
, Catalog
.State
.Views
)
423 instance
= Instance
.create( self
.cell
, instanceName
, model
)
424 for pin
, net
in portmap
.items():
425 connect( instance
, pin
, net
)
427 print "create transf", transf
429 place( instance
, transf
[0], transf
[1], transf
[2] )
432 ################# SNX
435 def alu_hier_place(**kw
):
438 if kw
.has_key('editor') and kw
['editor']:
439 editor
= kw
['editor']
441 db
= DataBase
.getDB()
443 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
444 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
446 add
= af
.getCell( 'add', CRL
.Catalog
.State
.Views
)
447 sub
= af
.getCell( 'sub', CRL
.Catalog
.State
.Views
)
448 cell
= af
.getCell( 'alu_hier', CRL
.Catalog
.State
.Logical
)
450 print '[ERROR] Unable to load cell "snx.vst", aborting .'
460 cell
.setAbutmentBox( ab
)
462 transf
= (l(50.0), l(100.0), Transformation
.Orientation
.ID
)
463 subi
= createInstance(cell
, "subckt_49_sub", sub
)
464 place( subi
, transf
[0], transf
[1], transf
[2] )
465 print "sub place", subi
467 transf
= (l(550.0), l(100.0), Transformation
.Orientation
.ID
)
468 addi
= createInstance(cell
, "subckt_48_add", add
)
469 place( addi
, transf
[0], transf
[1], transf
[2] )
470 print "add place", addi
474 Pin
.create( cell
.getNet('a(%d)' % i
)
476 , Pin
.Direction
.SOUTH
477 , Pin
.PlacementStatus
.FIXED
479 , l( 100.0*i
+ 50.0 ) , l( 0.0 ) # Position.
480 , l( 2.0 ) , l( 2.0 ) # Size.
482 Pin
.create( cell
.getNet('b(%d)' % i
)
484 , Pin
.Direction
.SOUTH
485 , Pin
.PlacementStatus
.FIXED
487 , l( 100.0*i
+ 50.0 ) , l( 0.0 ) # Position.
488 , l( 2.0 ) , l( 2.0 ) # Size.
490 Pin
.create( cell
.getNet('o(%d)' % i
)
492 , Pin
.Direction
.NORTH
493 , Pin
.PlacementStatus
.FIXED
495 , l( 100.0*i
+ 25.0 ) , l( 0.0 ) # Position.
496 , l( 2.0 ) , l( 2.0 ) # Size.
499 Pin
.create( cell
.getNet('rst')
502 , Pin
.PlacementStatus
.FIXED
509 UpdateSession
.close()
511 if editor
: editor
.setCell( cell
)
513 print "editor", editor
, dir(editor
)
515 #af.saveCell( cell, CRL.Catalog.State.Views )
516 plugins
.RSavePlugin
.ScriptMain( **kw
)
520 ################# SNX
523 def alu_hier_route(**kw
):
526 if kw
.has_key('editor') and kw
['editor']:
527 editor
= kw
['editor']
529 db
= DataBase
.getDB()
531 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
532 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
534 cell
= af
.getCell( 'alu_hier', CRL
.Catalog
.State
.Logical
)
536 print '[ERROR] Unable to load cell "snx.vst", aborting .'
545 cell
.setAbutmentBox( ab
)
547 if editor
: editor
.setCell( cell
)
549 print "editor", editor
, dir(editor
)
552 etesian
= Etesian
.EtesianEngine
.create(cell
)
555 katana
= Katana
.KatanaEngine
.create(cell
)
556 katana
.digitalInit ()
557 katana
.runNegociatePreRouted()
559 katana
.runGlobalRouter (0)
560 katana
.loadGlobalRouting ( Anabatic
.EngineLoadGrByNet
)
561 katana
.layerAssign ( Anabatic
.EngineNoNetLayerAssign
)
562 katana
.runNegociate ( Katana
.Flags
.NoFlags
)
563 katana
.finalizeLayout ()
565 success
= katana
.getSuccessState()
570 #af.saveCell( cell, CRL.Catalog.State.Views )
571 plugins
.RSavePlugin
.ScriptMain( **kw
)
573 print "cell", cell
, dir(cell
)
574 c
= cell
.getComponents()
575 print "components", c
, dir(c
)
576 for child
in cell
.getInstances():
582 if __name__
== '__main__':
585 #success = alu_hier_place()
586 #success = alu_hier_route()
588 if not success
: shellSuccess
= 1
590 sys
.exit( shellSuccess
)