2 # -*- coding: utf-8 -*-
12 from Hurricane
import DbU
13 from Hurricane
import DataBase
14 from Hurricane
import UpdateSession
15 from Hurricane
import Breakpoint
16 from Hurricane
import Box
17 from Hurricane
import Transformation
18 from Hurricane
import Instance
19 from Hurricane
import Contact
20 from Hurricane
import Vertical
21 from Hurricane
import Horizontal
22 from Hurricane
import Pin
23 from Hurricane
import Net
24 from Hurricane
import NetExternalComponents
31 from helpers
import l
, u
, n
32 import clocktree
.ClockTree
33 import plugins
.RSavePlugin
34 import plugins
.ClockTreePlugin
37 af
= CRL
.AllianceFramework
.get()
40 def build_crosstrace(net
, via
, layer
, x
, x1
, y
):
43 [ Contact
.create( net
, via
, l(x
), l(y
), l(1.0), l(1.0) )
44 , Contact
.create( net
, via
, l(x1
), l(y
), l(1.0), l(1.0) )
47 createHorizontal( contacts
, l(y
), layer
)
48 print "slaves", contacts
[-1].getSlaveComponents()
49 for component
in contacts
[-1].getSlaveComponents():
50 NetExternalComponents
.setExternal(component
)
52 def build_downtrace(net
, via
, layer
, x
, y
, y1
):
55 [ Contact
.create( net
, via
, l(x
), l(y
), l(1.0), l(1.0) )
56 , Contact
.create( net
, via
, l(x
), l(y1
), l(1.0), l(1.0) )
59 createVertical( contacts
, l(x
), layer
)
60 print "slaves", contacts
[-1].getSlaveComponents()
61 for component
in contacts
[-1].getSlaveComponents():
62 NetExternalComponents
.setExternal(component
)
67 Cfg
.Configuration
.pushDefaultPriority( Cfg
.Parameter
.Priority
.UserFile
)
69 cellsTop
= '~/alliance-check-toolkit/cells'
70 env
= af
.getEnvironment()
71 env
.addSYSTEM_LIBRARY( library
=cellsTop
+'/nsxlib', mode
=CRL
.Environment
.Prepend
)
72 env
.addSYSTEM_LIBRARY( library
=cellsTop
+'/mpxlib', mode
=CRL
.Environment
.Prepend
)
75 Cfg
.getParamBool ( 'misc.catchCore' ).setBool ( False )
76 Cfg
.getParamBool ( 'misc.info' ).setBool ( False )
77 Cfg
.getParamBool ( 'misc.paranoid' ).setBool ( False )
78 Cfg
.getParamBool ( 'misc.bug' ).setBool ( False )
79 Cfg
.getParamBool ( 'misc.logMode' ).setBool ( True )
80 Cfg
.getParamBool ( 'misc.verboseLevel1' ).setBool ( True )
81 Cfg
.getParamBool ( 'misc.verboseLevel2' ).setBool ( True )
82 Cfg
.getParamInt ( 'misc.minTraceLevel' ).setInt ( 159 )
83 #Cfg.getParamInt ( 'misc.maxTraceLevel' ).setInt ( 160 )
84 Cfg
.getParamEnumerate ( 'etesian.effort' ).setInt ( 2 )
85 Cfg
.getParamPercentage( 'etesian.spaceMargin' ).setPercentage( 20.0 )
86 Cfg
.getParamPercentage( 'etesian.aspectRatio' ).setPercentage( 100.0 )
87 Cfg
.getParamBool ( 'etesian.uniformDensity' ).setBool ( True )
88 Cfg
.getParamInt ( 'anabatic.edgeLenght' ).setInt ( 24 )
89 Cfg
.getParamInt ( 'anabatic.edgeWidth' ).setInt ( 8 )
90 Cfg
.getParamString ( 'anabatic.topRoutingLayer' ).setString ( 'METAL5')
91 Cfg
.getParamInt ( 'katana.eventsLimit' ).setInt ( 1000000 )
92 Cfg
.getParamInt ( 'katana.hTracksReservedLocal' ).setInt ( 7 )
93 Cfg
.getParamInt ( 'katana.vTracksReservedLocal' ).setInt ( 6 )
94 #Cfg.getParamInt ( 'clockTree.minimumSide' ).setInt ( l(1000) )
96 env
= af
.getEnvironment()
97 env
.setCLOCK( '^clk$|m_clock' )
99 env
.setGROUND( 'vss' )
101 Cfg
.Configuration
.popDefaultPriority()
106 def add ( cell
, **kw
):
108 if kw
.has_key('editor') and kw
['editor']:
109 editor
= kw
['editor']
111 db
= DataBase
.getDB()
113 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
114 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
115 metal5
= DataBase
.getDB().getTechnology().getLayer( 'metal5' )
117 #cell = af.getCell( 'add', CRL.Catalog.State.Logical )
118 print cell
.getNet('a(0)')
121 print '[ERROR] Unable to load cell "alu16.vst", aborting .'
133 cellGauge
= af
.getCellGauge()
134 spaceMargin
= (Cfg
.getParamPercentage('etesian.spaceMargin').asPercentage()+5) / 100.0
135 aspectRatio
= Cfg
.getParamPercentage('etesian.aspectRatio').asPercentage() / 100.0
136 clocktree
.ClockTree
.computeAbutmentBox( cell
,
137 spaceMargin
, aspectRatio
, cellGauge
)
138 ab2
= cell
.getAbutmentBox()
139 print "box", ab
, ab
.getHeight(), ab
.getWidth()
140 print "calc box", ab2
, ab2
.getHeight(), ab2
.getWidth()
142 #height = ab.getHeight()
143 #width = ab.getWidth()
145 #UpdateSession.open()
146 cell
.setAbutmentBox( ab
)
152 net
= cell
.getNet('a(%d)' % i
)
156 , Pin
.Direction
.NORTH
157 , Pin
.PlacementStatus
.FIXED
159 , l( x
), l( y
- 0 ) # Position.
160 , l( 2.0 ) , l( 2.0 ) # Size.
164 Pin
.create( cell
.getNet('o(%d)' % i
)
166 , Pin
.Direction
.SOUTH
167 , Pin
.PlacementStatus
.FIXED
169 , l( 10.0*i
+ 100.0 ), l( 0) # Position.
170 , l( 2.0 ) , l( 2.0 ) # Size.
175 net
= cell
.getNet('b(%d)' % i
)
176 x
= 20.0*i
+ 10.0 + 10
178 #build_downtrace(net, metal3, x, y+11, y)
182 , Pin
.Direction
.NORTH
183 , Pin
.PlacementStatus
.FIXED
185 , l( x
), l( y
- 0 ) # Position.
186 , l( 2.0 ) , l( 2.0 ) # Size.
189 Pin
.create( cell
.getNet('rst')
192 , Pin
.PlacementStatus
.FIXED
199 #UpdateSession.close()
202 if editor
: editor
.setCell( cell
)
204 etesian
= Etesian
.EtesianEngine
.create(cell
)
207 katana
= Katana
.KatanaEngine
.create(cell
)
208 katana
.digitalInit ()
209 #katana.runNegociatePreRouted()
211 katana
.runGlobalRouter (0)
212 katana
.loadGlobalRouting ( Anabatic
.EngineLoadGrByNet
)
213 katana
.layerAssign ( Anabatic
.EngineNoNetLayerAssign
)
214 katana
.runNegociate ( Katana
.Flags
.NoFlags
)
215 katana
.finalizeLayout ()
217 success
= katana
.getSuccessState()
221 VIA23
= DataBase
.getDB().getTechnology().getLayer( 'VIA23' )
222 #UpdateSession.open()
223 #net = cell.getNet('b(%d)' % 0)
224 net
= cell
.getNet('vdd')
225 build_downtrace(net
, VIA23
, metal2
, -5, -10, -20)
226 build_downtrace(net
, VIA23
, metal2
, -10, -10, -20)
227 build_crosstrace(net
, VIA23
, metal2
, -5, -10, -10)
228 build_crosstrace(net
, VIA23
, metal2
, -5, -10, -20)
231 net
= cell
.getNet('b(%d)' % i
)
232 x
= 20.0*i
+ 10.0 + 10
234 build_downtrace(net
, metal2
, x
, y
, y
+10)
235 ab
.inflate ( l(30.0) )
236 cell
.setAbutmentBox( ab
)
237 #UpdateSession.close()
239 #af.saveCell( cell, CRL.Catalog.State.Views )
240 #plugins.RSavePlugin.ScriptMain( **kw )
246 def sub ( cell
, **kw
):
248 if kw
.has_key('editor') and kw
['editor']:
249 editor
= kw
['editor']
251 db
= DataBase
.getDB()
253 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
254 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
255 metal5
= DataBase
.getDB().getTechnology().getLayer( 'metal5' )
257 #cell = af.getCell( 'sub', CRL.Catalog.State.Logical )
258 print cell
.getNet('a(0)')
261 print '[ERROR] Unable to load cell "alu16.vst", aborting .'
273 cellGauge
= af
.getCellGauge()
274 spaceMargin
= (Cfg
.getParamPercentage('etesian.spaceMargin').asPercentage()+5) / 100.0
275 aspectRatio
= Cfg
.getParamPercentage('etesian.aspectRatio').asPercentage() / 100.0
276 clocktree
.ClockTree
.computeAbutmentBox( cell
, spaceMargin
, aspectRatio
, cellGauge
)
277 ab2
= cell
.getAbutmentBox()
278 print "box", ab
, ab
.getHeight(), ab
.getWidth()
279 print "calc box", ab2
, ab2
.getHeight(), ab2
.getWidth()
281 #height = ab.getHeight()
282 #width = ab.getWidth()
284 #UpdateSession.open()
285 cell
.setAbutmentBox( ab
)
291 Pin
.create( cell
.getNet('a(%d)' % i
)
293 , Pin
.Direction
.NORTH
294 , Pin
.PlacementStatus
.FIXED
296 , l( x
), l( y
- 0 ) # Position.
297 , l( 2.0 ) , l( 2.0 ) # Size.
301 Pin
.create( cell
.getNet('o(%d)' % i
)
303 , Pin
.Direction
.SOUTH
304 , Pin
.PlacementStatus
.FIXED
306 , l( 10.0*i
+ 100.0 ), l( 0) # Position.
307 , l( 2.0 ) , l( 2.0 ) # Size.
312 net
= cell
.getNet('b(%d)' % i
)
313 x
= 20.0*i
+ 10.0 + 10
315 #build_downtrace(net, metal3, x, y+11, y)
319 , Pin
.Direction
.NORTH
320 , Pin
.PlacementStatus
.FIXED
322 , l( x
), l( y
- 0 ) # Position.
323 , l( 2.0 ) , l( 2.0 ) # Size.
326 Pin
.create( cell
.getNet('rst')
329 , Pin
.PlacementStatus
.FIXED
336 #UpdateSession.close()
339 if editor
: editor
.setCell( cell
)
341 etesian
= Etesian
.EtesianEngine
.create(cell
)
344 katana
= Katana
.KatanaEngine
.create(cell
)
345 katana
.digitalInit ()
346 #katana.runNegociatePreRouted()
348 katana
.runGlobalRouter (0)
349 katana
.loadGlobalRouting ( Anabatic
.EngineLoadGrByNet
)
350 katana
.layerAssign ( Anabatic
.EngineNoNetLayerAssign
)
351 katana
.runNegociate ( Katana
.Flags
.NoFlags
)
352 katana
.finalizeLayout ()
354 success
= katana
.getSuccessState()
357 #af.saveCell( cell, CRL.Catalog.State.Views )
358 #plugins.RSavePlugin.ScriptMain( **kw )
361 #def toDbU(v): return DbU.fromLambda(v)
362 def toDbU(v
): return l(v
)
366 def doBreak(level
, message
):
367 UpdateSession
.close()
368 Breakpoint
.stop(level
, message
)
372 class Model (object):
377 def __init__(self
, modelName
, session
=True, views
=False):
381 self
.af
= CRL
.AllianceFramework
.get()
382 #self.cell = af.createCell(modelName)
384 self
.cell
= self
.af
.getCell( modelName
, CRL
.Catalog
.State
.Logical
)
386 self
.cell
= self
.af
.getCell( modelName
, CRL
.Catalog
.State
.Views
)
387 self
.createNet('vss', direction
=Net
.Direction
.IN
,
388 isExternal
=True, isGlobal
=True, type=Net
.Type
.POWER
)
389 self
.createNet('vdd', direction
=Net
.Direction
.IN
,
390 isExternal
=True, isGlobal
=True, type=Net
.Type
.GROUND
)
394 UpdateSession
.close()
397 def createNet(self
, netName
, **attributes
):
398 net
= self
.cell
.getNet(netName
)
400 net
= Net
.create(self
.cell
, netName
)
402 if 'direction' in attributes
:
403 net
.setDirection(attributes
['direction'])
404 if 'isExternal' in attributes
:
405 net
.setExternal(attributes
['isExternal'])
406 if 'isGlobal' in attributes
:
407 net
.setGlobal(attributes
['isGlobal'])
408 if 'type' in attributes
:
409 net
.setType(attributes
['type'])
412 def getNet(self
, netName
):
413 return self
.createNet(netName
)
415 def connect(self
, instanceRef
, pin
, netRef
):
416 if isinstance(instanceRef
, str):
417 instance
= self
.getInstance(instanceRef
)
419 instance
= instanceRef
421 if isinstance(netRef
, str):
422 net
= self
.getNet(netRef
)
426 masterNet
= instance
.getMasterCell().getNet(pin
)
428 print '[ERROR] Master cell "%s" of instance "%s" ' \
429 'has no connector named "%s".' \
430 % (instance
.getMasterCell().getName(), instance
.getName(), pin
)
432 instance
.getPlug(instance
.getMasterCell().getNet(pin
)).setNet(net
)
435 def place(self
, instanceRef
, x
, y
, orient
):
436 if isinstance(instanceRef
, str):
437 instance
= self
.getInstance(instanceRef
)
439 instance
= instanceRef
441 instance
.setTransformation(Transformation(x
, y
, orient
))
442 instance
.setPlacementStatus(Instance
.PlacementStatus
.PLACED
)
445 def createInstance(self
, instanceName
, modelRef
, portmap
={}, transf
=None):
446 instance
= self
.cell
.getInstance(instanceName
)
448 if isinstance(modelRef
, str):
449 model
= self
.af
.getCell(modelRef
, CRL
.Catalog
.State
.Views
)
452 instance
= Instance
.create(self
.cell
, instanceName
, model
)
453 for pin
, net
in portmap
.items():
454 self
.connect(instance
, pin
, net
)
457 self
.place(instance
, transf
[0], transf
[1], transf
[2])
460 def createAccess(self
, termPath
, x
, y
, flags
):
461 insName
, pinName
= termPath
.split('.')
462 instance
= self
.cell
.getInstance(insName
)
464 print '[ERROR] Model "%s" has no instance named "%s"' \
465 % (self
.cell
.getName(), insName
)
467 plug
= instance
.getPlug(instance
.getMasterCell().getNet(pinName
))
468 except BaseException
:
469 print '[ERROR] Model "%s" of instance "%s" has ' \
470 'no terminal named "%s"' \
471 % (instance
.getMasterCell().getName(),
472 instance
.getName(), pinName
)
475 VIA12
= self
.getLayer('VIA12')
476 VIA23
= self
.getLayer('VIA23')
477 METAL2
= self
.getLayer('METAL2')
479 rp
= RoutingPad
.create(
480 net
, Occurrence(plug
), RoutingPad
.BiggestArea
)
481 rpCenter
= rp
.getPosition()
485 contact1
= Contact
.create(rp
, VIA12
, toDbU(0.0), y
- rpCenter
.getY())
487 if flags
& Model
.VerticalAccess
:
489 contact1
= Contact
.create(net
, VIA23
, x
, y
)
490 Horizontal
.create(contact2
, contact1
, METAL2
, y
, toDbU(2.0))
493 def createVertical(self
, contacts
, x
, width
=None, layer
=None):
494 def yincrease(lhs
, rhs
): return int(lhs
.getY() - rhs
.getY())
496 contacts
.sort(yincrease
)
502 layer
= self
.getLayer("METAL3")
503 for i
in range(1, len(contacts
)):
504 Vertical
.create(contacts
[i
- 1], contacts
[i
], layer
, x
, width
)
507 def createHorizontal(self
, contactPaths
, y
, width
=None, layer
=None):
508 def xincrease(lhs
, rhs
): return int(lhs
.getX() - rhs
.getX())
510 if isinstance(contactPaths
[0], str):
512 for termPath
in contactPaths
:
513 contacts
.append(self
.createAccess(
514 termPath
, None, y
, Model
.HorizontalAccess
))
516 contacts
= contactPaths
521 contacts
.sort(xincrease
)
524 layer
= self
.getLayer("METAL2")
525 for i
in range(1, len(contacts
)):
526 Horizontal
.create(contacts
[i
- 1], contacts
[i
], layer
, y
, width
)
529 def createSerpentine(
530 self
, contactPaths
, ymin
, ymax
, width
=None, layer
=None):
531 def xincrease(lhs
, rhs
): return int(lhs
.getX() - rhs
.getX())
533 if isinstance(contactPaths
[0], str):
535 for termPath
in contactPaths
:
536 contacts
.append(self
.createAccess(
537 termPath
, None, None, Model
.HorizontalAccess
))
539 contacts
= contactPaths
541 if len(contacts
) != 2:
542 print '[ERROR] Model.createSerpentine() takes exactly ' \
543 'two points, not %d.' % len( contacts
)
546 layer
= self
.getLayer("METAL2")
550 contacts
.sort(xincrease
)
553 trackPitch
= toDbU(5.0)
554 for i
in range((contacts
[1].getX() - contacts
[0].getX()) / trackPitch
):
560 turn1
= Contact
.create(
561 turn0
.getNet(), layer
, x
, y
, width
, width
)
562 turn2
= Contact
.create(
563 turn0
.getNet(), layer
, x
+ trackPitch
, y
, width
, width
)
564 Vertical
.create(turn0
, turn1
, layer
, x
, width
)
565 Horizontal
.create(turn1
, turn2
, layer
, y
, width
)
569 Vertical
.create(turn0
, contacts
[1], layer
, contacts
[1].getX(), width
)
573 def addFillersRow(self
, x
, y
, orient
, length
):
574 tieWidth
= self
.getMasterCell("tie_x0").getAbutmentBox().getWidth()
576 for i
in range(length
/ tieWidth
):
579 self
. fillerCount
, "tie_x0", transf
=(
580 x
+ tieWidth
* i
, y
, orient
))
581 self
.fillerCount
+= 1
582 if length
% tieWidth
:
584 if length
> tieWidth
:
586 self
.createInstance("filler_%d_i" % self
.fillerCount
, "rowend_x0",
587 transf
=(x
+ tieWidth
* (i
+ delta
), y
, orient
))
588 self
.fillerCount
+= 1
591 def getLayer(self
, name
):
592 return DataBase
.getDB().getTechnology().getLayer(name
)
594 def getCell(self
): return self
.cell
596 def getMasterCell( self
, name
):
597 return self
.af
.getCell(name
, CRL
.Catalog
.State
.Views
)
599 def setAbutmentBox(self
, ab
): self
.cell
.setAbutmentBox(ab
)
601 def getAbutmentBox(self
): return self
.cell
.getAbutmentBox()
603 def getCellWidth(self
, name
):
604 return self
.getMasterCell(name
).getAbutmentBox().getWidth()
607 plugins
.RSavePlugin
.ScriptMain( cell
=self
.cell
)
608 #self.af.saveCell(self.cell, CRL.Catalog.State.Views)
611 print '[ERROR] Model.build() base class method should never be called.'
614 class Ringed (Model
):
616 def addFillers(self
):
617 self
.addFillersRow(toDbU(1580.0), toDbU(0.0),
618 Transformation
.Orientation
.ID
, toDbU(15.0))
619 self
.addFillersRow(toDbU(1570.0), toDbU(100.0),
620 Transformation
.Orientation
.MY
, toDbU(5.0))
621 self
.addFillersRow(toDbU(1570.0), toDbU(100.0),
622 Transformation
.Orientation
.ID
, toDbU(25.0))
623 self
.addFillersRow(toDbU(1530.0), toDbU(200.0),
624 Transformation
.Orientation
.MY
, toDbU(45.0))
625 self
.addFillersRow(toDbU(1550.0), toDbU(200.0),
626 Transformation
.Orientation
.ID
, toDbU(10.0))
627 self
.addFillersRow(toDbU(1550.0), toDbU(300.0),
628 Transformation
.Orientation
.MY
, toDbU(25.0))
629 self
.addFillersRow(toDbU(1570.0), toDbU(300.0),
630 Transformation
.Orientation
.ID
, toDbU(25.0))
631 self
.addFillersRow(toDbU(1550.0), toDbU(400.0),
632 Transformation
.Orientation
.MY
, toDbU(25.0))
634 def buildPower(self
):
635 METAL1
= self
.getLayer("METAL1")
636 METAL2
= self
.getLayer("METAL2")
637 METAL3
= self
.getLayer("METAL3")
638 METAL4
= self
.getLayer("METAL3")
639 VIA12
= self
.getLayer("VIA12")
640 VIA23
= self
.getLayer("VIA23")
641 powerWidth
= toDbU(2.0)
642 powerSpacing
= toDbU(5.0)
643 ab
= self
.getAbutmentBox()
644 vdd
= self
.getNet("vdd")
645 vss
= self
.getNet("vss")
646 vddAxis
= Box(ab
).inflate(powerSpacing
+ powerWidth
/ 2)
647 vssAxis
= Box(ab
).inflate(
648 powerSpacing
+ powerWidth
/ 2 + powerWidth
+ toDbU(5.0))
650 # Building "vdd" power ring.
652 Contact
.create( vdd
, VIA23
, vddAxis
.getXMin(), vddAxis
.getYMin(),
653 powerWidth
, powerWidth
),
654 Contact
.create( vdd
, VIA23
, vddAxis
.getXMin(), vddAxis
.getYMax(),
655 powerWidth
, powerWidth
)]
657 Contact
.create( vdd
, VIA23
, vddAxis
.getXMax(), vddAxis
.getYMin(),
658 powerWidth
, powerWidth
),
659 Contact
.create( vdd
, VIA23
, vddAxis
.getXMax(), vddAxis
.getYMax(),
660 powerWidth
, powerWidth
)]
666 yaxis
= ab
.getXMin() + toDbU(50.0) * (1 + i
* 2)
668 westContact
= Contact
.create( vdd
, VIA12
, vddAxis
.getXMin(),
669 yaxis
, powerWidth
, ywidth
)
670 eastContact
= Contact
.create( vdd
, VIA12
, vddAxis
.getXMax(),
671 yaxis
, powerWidth
, ywidth
)
672 self
.createHorizontal( [westContact
, eastContact
],
673 yaxis
, ywidth
, layer
=METAL1
)
675 westContact
= Contact
.create(
676 vdd
, VIA23
, vddAxis
.getXMin(), yaxis
, powerWidth
, ywidth
)
677 eastContact
= Contact
.create(
678 vdd
, VIA23
, vddAxis
.getXMax(), yaxis
, powerWidth
, ywidth
)
680 westContactsVdd
.insert(-1, westContact
)
681 eastContactsVdd
.insert(-1, eastContact
)
683 for layer
in [METAL2
, METAL3
]:
684 self
.createVertical(westContactsVdd
, vddAxis
.getXMin(), powerWidth
,
686 self
.createVertical(eastContactsVdd
, vddAxis
.getXMax(), powerWidth
,
689 xcenter
= vddAxis
.getCenter().getX() + powerWidth
/ 2 + toDbU(5.0)
691 accessContactsVdd
= [
708 [westContactsVdd
[-1],
709 #accessContactsVdd[0],
713 [westContactsVdd
[0], eastContactsVdd
[0]
715 self
.createHorizontal(
716 southContactsVdd
, vddAxis
.getYMin(), powerWidth
)
717 self
.createHorizontal(
718 northContactsVdd
, vddAxis
.getYMax(), powerWidth
)
719 #self.createVertical(
720 #accessContactsVdd, xcenter, powerWidth)
721 #for component in accessContactsVdd[-1].getSlaveComponents():
722 #NetExternalComponents.setExternal(component)
724 # Building "vss" power ring.
760 yaxis
= ab
.getXMin() + toDbU(50.0) * (i
* 2)
762 westContact
= Contact
.create(
763 vss
, VIA12
, vssAxis
.getXMin(), yaxis
, powerWidth
, ywidth
)
764 eastContact
= Contact
.create(
765 vss
, VIA12
, vssAxis
.getXMax(), yaxis
, powerWidth
, ywidth
)
766 self
.createHorizontal(
767 [westContact
, eastContact
], yaxis
, ywidth
, layer
=METAL1
)
769 westContact
= Contact
.create(
770 vss
, VIA23
, vssAxis
.getXMin(), yaxis
, powerWidth
, ywidth
)
771 eastContact
= Contact
.create(
772 vss
, VIA23
, vssAxis
.getXMax(), yaxis
, powerWidth
, ywidth
)
774 westContactsVss
.insert(-1, westContact
)
775 eastContactsVss
.insert(-1, eastContact
)
777 for layer
in [METAL2
, METAL3
]:
778 self
.createVertical(westContactsVss
, vssAxis
.getXMin(), powerWidth
,
780 self
.createVertical(eastContactsVss
, vssAxis
.getXMax(), powerWidth
,
783 xcenter
= vssAxis
.getCenter().getX() - powerWidth
/ 2 - toDbU(5.0)
785 accessContactsVss
= [
801 [westContactsVss
[-1],
802 # accessContactsVss[0],
806 [westContactsVss
[0], eastContactsVss
[0]
809 self
.createHorizontal(
810 southContactsVss
, vssAxis
.getYMin(), powerWidth
)
811 self
.createHorizontal(
812 northContactsVss
, vssAxis
.getYMax(), powerWidth
)
813 #self.createVertical(
814 # accessContactsVss, xcenter, powerWidth)
815 #for component in accessContactsVss[-1].getSlaveComponents():
816 #NetExternalComponents.setExternal(component)
818 ab
.inflate(powerSpacing
+ powerWidth
* 2 + toDbU(20.0))
819 self
.setAbutmentBox(ab
)
837 class AddSubPlace(Ringed
):
840 self
.alu_hier_place()
842 def alu_hier_place(self
, **kw
):
846 if kw
.has_key('editor') and kw
['editor']:
847 editor
= kw
['editor']
849 db
= DataBase
.getDB()
851 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
852 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
854 add
= self
.af
.getCell( 'add', CRL
.Catalog
.State
.Views
)
855 sub
= self
.af
.getCell( 'sub', CRL
.Catalog
.State
.Views
)
856 #cell = self.af.getCell( 'alu_hier', CRL.Catalog.State.Logical )
858 print '[ERROR] Unable to load cell "snx.vst", aborting .'
867 #UpdateSession.open()
868 cell
.setAbutmentBox( ab
)
870 transf
= (l(25.0), l(250.0), Transformation
.Orientation
.ID
)
871 subi
= self
.createInstance("subckt_49_sub", sub
, transf
=transf
)
872 print "sub place", subi
874 transf
= (l(450.0), l(250.0), Transformation
.Orientation
.ID
)
875 addi
= self
.createInstance("subckt_48_add", add
, transf
=transf
)
876 print "add place", addi
880 Pin
.create( cell
.getNet('a(%d)' % i
)
882 , Pin
.Direction
.SOUTH
883 , Pin
.PlacementStatus
.FIXED
885 , l( 100.0*i
+ 50.0 ) , l( 0.0 ) # Position.
886 , l( 2.0 ) , l( 2.0 ) # Size.
888 Pin
.create( cell
.getNet('b(%d)' % i
)
890 , Pin
.Direction
.SOUTH
891 , Pin
.PlacementStatus
.FIXED
893 , l( 100.0*i
+ 50.0 ) , l( 0.0 ) # Position.
894 , l( 2.0 ) , l( 2.0 ) # Size.
896 Pin
.create( cell
.getNet('o(%d)' % i
)
898 , Pin
.Direction
.NORTH
899 , Pin
.PlacementStatus
.FIXED
901 , l( 100.0*i
+ 25.0 ) , l( 0.0 ) # Position.
902 , l( 2.0 ) , l( 2.0 ) # Size.
905 Pin
.create( cell
.getNet('rst')
908 , Pin
.PlacementStatus
.FIXED
915 #UpdateSession.close()
917 if editor
: editor
.setCell( cell
)
919 print "editor", editor
, dir(editor
)
921 #self.af.saveCell( cell, CRL.Catalog.State.Views )
922 #plugins.RSavePlugin.ScriptMain( **kw )
927 class AddSubEtesian(Ringed
):
930 self
.alu_hier_route()
932 def alu_hier_route(self
, **kw
):
936 if kw
.has_key('editor') and kw
['editor']:
937 editor
= kw
['editor']
939 db
= DataBase
.getDB()
941 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
942 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
944 #cell = self.af.getCell( 'alu_hier', CRL.Catalog.State.Logical )
946 print '[ERROR] Unable to load cell "snx.vst", aborting .'
955 cell
.setAbutmentBox( ab
)
957 if editor
: editor
.setCell( cell
)
959 print "editor", editor
, dir(editor
)
963 etesian
= Etesian
.EtesianEngine
.create(cell
)
966 print "cell", cell
, dir(cell
)
967 c
= cell
.getComponents()
968 print "components", c
, dir(c
)
969 for child
in cell
.getInstances():
975 class AddSubRoute(Ringed
):
978 self
.alu_hier_route()
980 def alu_hier_route(self
, **kw
):
984 if kw
.has_key('editor') and kw
['editor']:
985 editor
= kw
['editor']
987 db
= DataBase
.getDB()
989 metal2
= DataBase
.getDB().getTechnology().getLayer( 'metal2' )
990 metal3
= DataBase
.getDB().getTechnology().getLayer( 'metal3' )
992 #cell = self.af.getCell( 'alu_hier', CRL.Catalog.State.Logical )
994 print '[ERROR] Unable to load cell "snx.vst", aborting .'
1003 cell
.setAbutmentBox( ab
)
1005 if editor
: editor
.setCell( cell
)
1007 print "editor", editor
, dir(editor
)
1012 katana
= Katana
.KatanaEngine
.create(cell
)
1013 katana
.digitalInit ()
1014 katana
.runNegociatePreRouted()
1016 katana
.runGlobalRouter (0)
1017 katana
.loadGlobalRouting ( Anabatic
.EngineLoadGrByNet
)
1018 katana
.layerAssign ( Anabatic
.EngineNoNetLayerAssign
)
1019 katana
.runNegociate ( Katana
.Flags
.NoFlags
)
1020 katana
.finalizeLayout ()
1022 success
= katana
.getSuccessState()
1026 #self.af.saveCell( cell, CRL.Catalog.State.Views )
1027 #plugins.RSavePlugin.ScriptMain( **kw )
1029 print "cell", cell
, dir(cell
)
1030 c
= cell
.getComponents()
1031 print "components", c
, dir(c
)
1032 for child
in cell
.getInstances():
1033 print "child", child
1039 def ScriptMain(**kw
):
1041 #if "editor" in kw and kw["editor"]:
1042 # editor = kw["editor"]
1049 print ("Create alu_hier.ap")
1050 cell
= af
.getCell( "alu_hier", CRL
.Catalog
.State
.Views
)
1051 plugins
.RSavePlugin
.ScriptMain( cell
=cell
)
1053 print ("copying alu_hier to altered")
1054 with
open("alu_hier.ap") as f
:
1056 x
= x
.replace("alu_hier", "alu_hier_altered")
1057 with
open("alu_hier_altered.ap", "w") as f
:
1060 print ("AddSubEtesian")
1061 addsub
= AddSubEtesian('alu_hier_altered', True, True)
1064 print ("copying altered to alu_hier ")
1065 with
open("alu_hier_altered.ap") as f
:
1067 x
= x
.replace("alu_hier_altered", "alu_hier_altered2")
1068 with
open("alu_hier_altered2.ap", "w") as f
:
1071 with
open("alu_hier.vst") as f
:
1073 x
= x
.replace("alu_hier", "alu_hier_altered2")
1074 with
open("alu_hier_altered2.vst", "w") as f
:
1077 print ("AddSubPlace")
1078 addsub
= AddSubPlace('alu_hier_altered2', True, True)
1081 print ("AddSubRoute")
1082 addsub
= AddSubRoute('alu_hier_altered2', True, True)
1086 # editor.setCell(ringo.getCell())
1091 if __name__
== "__main__":