Port to Python3 capacitors & resistors generators.

Main list of ports:

* Replace deprecated operator '<>' by '!='.
* To check if a list is empty, do not compare to [], but check it's
  length instead.
* Do not make a class inherit indirectly twice from the same base class.
* Hurricane physical object constructors uses DbU::Unit as arguments,
  seen as int in Python, so they will not match float. Unfortunately
  the calculation often gives float. So explicitely cast them into
  int. This is due to a change of behavior in Python. Now, 3/2
  gives 1.5 (float). To get the previous one use: 3/2 -> 1 (int).
* dict.keys()[0] no longer work, instead use list(dict.keys())[0].
This commit is contained in:
Jean-Paul Chaput 2022-07-13 11:20:55 +02:00
parent f453dbc6f9
commit c737d5bd0c
9 changed files with 248 additions and 206 deletions

View File

@ -74,7 +74,7 @@ class CapacitorStack( CapacitorUnit ):
if unitCap == 0: if unitCap == 0:
self.__initGivenZeroUnitCap__( capacitance[0] ) self.__initGivenZeroUnitCap__( capacitance[0] )
elif unitCap <> 0 and CapacitorUnit.__isCapacitorUnitOK__( self, self.unitCapDim ): elif unitCap != 0 and CapacitorUnit.__isCapacitorUnitOK__( self, self.unitCapDim ):
self.__initGivenNonZeroUnitCap__( capacitance[0], unitCap ) self.__initGivenNonZeroUnitCap__( capacitance[0], unitCap )
else: else:
raise Error( 1, [ 'CapacitorStack.__init__(): Impossible to draw the unit capacitor, dimensions are either too large or too small.' raise Error( 1, [ 'CapacitorStack.__init__(): Impossible to draw the unit capacitor, dimensions are either too large or too small.'
@ -85,7 +85,7 @@ class CapacitorStack( CapacitorUnit ):
if unitCap == 0: if unitCap == 0:
self.__initGivenZeroUnitCapInMatchingMode__( capacitance ) self.__initGivenZeroUnitCapInMatchingMode__( capacitance )
elif unitCap <> 0 and CapacitorUnit.__isCapacitorUnitOK__( self, self.unitCapDim ): elif unitCap != 0 and CapacitorUnit.__isCapacitorUnitOK__( self, self.unitCapDim ):
self.__initGivenNonZeroUnitCapInMatchingMode__( capacitance, unitCap ) self.__initGivenNonZeroUnitCapInMatchingMode__( capacitance, unitCap )
else: else:
raise Error( 1, [ 'CapacitorStack.__init__(): Impossible to draw the unit capacitor, dimensions are either too large or too small.' raise Error( 1, [ 'CapacitorStack.__init__(): Impossible to draw the unit capacitor, dimensions are either too large or too small.'
@ -166,13 +166,13 @@ class CapacitorStack( CapacitorUnit ):
if self.matrixDim.values()[0]*self.matrixDim.values()[1] == capacitance/unitCap : if self.matrixDim.values()[0]*self.matrixDim.values()[1] == capacitance/unitCap :
self.__initMatrixMode__( capacitance, unitCap ) self.__initMatrixMode__( capacitance, unitCap )
else : raise Error( 1, '__init__() : Matrix dimensions and unit capacitance are not compatible : "capacitance %d divides by unit capacitance %s <> columns %d * rows %d ".' %( capacitance, unitCap, self.matrixDim["columns"], self.matrixDim["rows"] ) ) else : raise Error( 1, '__init__() : Matrix dimensions and unit capacitance are not compatible : "capacitance %d divides by unit capacitance %s != columns %d * rows %d ".' %( capacitance, unitCap, self.matrixDim["columns"], self.matrixDim["rows"] ) )
else : # self.matrixDim.values() == [1,1] : # jai donne ou jai ps donne else : # self.matrixDim.values() == [1,1] : # jai donne ou jai ps donne
if capacitance == unitCap : #compact if capacitance == unitCap : #compact
[ self.capacitance , self.unitCapDim ] = [ capacitance , self.compactCapDim ] [ self.capacitance , self.unitCapDim ] = [ capacitance , self.compactCapDim ]
elif capacitance <> unitCap : #matrice elif capacitance != unitCap : #matrice
self.__initMatrixMode__( capacitance, unitCap ) self.__initMatrixMode__( capacitance, unitCap )
self.matrixDim = {"columns" : int(sqrt(capacitance/unitCap)), "rows" : int(sqrt(capacitance/unitCap)) } # ici mettre toutes les combi si matching mode = [] sinon utiliser la meme combi que matching scheme self.matrixDim = {"columns" : int(sqrt(capacitance/unitCap)), "rows" : int(sqrt(capacitance/unitCap)) } # ici mettre toutes les combi si matching mode = [] sinon utiliser la meme combi que matching scheme
@ -230,8 +230,7 @@ class CapacitorStack( CapacitorUnit ):
def __areMatrixDimOK__( self ): return True if self.matrixDim.values() > 0 else False def __areMatrixDimOK__( self ): return True if len(self.matrixDim.values()) else False
def computeUnitCap( self, capacitance ): def computeUnitCap( self, capacitance ):
@ -307,13 +306,13 @@ class CapacitorStack( CapacitorUnit ):
if self.matchingMode in [False, True] and self.dummyRing in [False,True] and self.dummyElement in [False,True]: if self.matchingMode in [False, True] and self.dummyRing in [False,True] and self.dummyElement in [False,True]:
[ matchingSchemeCapIds , capacitanceIds ] = [ list( numpy.unique(self.matchingScheme) ) , range(0,self.capacitorsNumber) ] [ matchingSchemeCapIds , capacitanceIds ] = [ list( numpy.unique(self.matchingScheme) ) , range(0,self.capacitorsNumber) ]
if (self.matchingScheme != [] and set(matchingSchemeCapIds) == set(capacitanceIds) ) or (self.matchingScheme == [] and len(capacitance) == 1) : if (len(self.matchingScheme) and set(matchingSchemeCapIds) == set(capacitanceIds) ) or (len(self.matchingScheme) == 0 and len(capacitance) == 1) :
if (len(self.nets) == self.capacitorsNumber + 1 and self.dummyElement == False and self.dummyRing == True ) \ if (len(self.nets) == self.capacitorsNumber + 1 and self.dummyElement == False and self.dummyRing == True ) \
or (len(self.nets) == self.capacitorsNumber and self.dummyElement == False and self.dummyRing == False) \ or (len(self.nets) == self.capacitorsNumber and self.dummyElement == False and self.dummyRing == False) \
or (len(self.nets) == self.capacitorsNumber and self.dummyElement == True and self.dummyRing == True ) \ or (len(self.nets) == self.capacitorsNumber and self.dummyElement == True and self.dummyRing == True ) \
or (len(self.nets) == self.capacitorsNumber and self.dummyElement == True and self.dummyRing == False): or (len(self.nets) == self.capacitorsNumber and self.dummyElement == True and self.dummyRing == False):
if ( self.matchingMode == True and self.__isMatchingSchemeOK__() ) or ( self.matchingMode == False and self.matchingScheme == [] ): if ( self.matchingMode == True and self.__isMatchingSchemeOK__() ) or ( self.matchingMode == False and len(self.matchingScheme) == 0 ):
state = True state = True
else: raise Error(1, '__areInputDataOK__(): Please check compatibility of the entered parameters (Matching mode, matching scheme, capacitance). It must be either equal to (False, [], one capacitance value) or ( True, matching scheme, capacitance values as much as there are capacitor ids in matching scheme ). The entered parameters are (%s, %s, %s).' %(self.matchingMode, self.matchingScheme, capacitance) ) #com2 : tester else: raise Error(1, '__areInputDataOK__(): Please check compatibility of the entered parameters (Matching mode, matching scheme, capacitance). It must be either equal to (False, [], one capacitance value) or ( True, matching scheme, capacitance values as much as there are capacitor ids in matching scheme ). The entered parameters are (%s, %s, %s).' %(self.matchingMode, self.matchingScheme, capacitance) ) #com2 : tester
@ -559,7 +558,7 @@ class CapacitorStack( CapacitorUnit ):
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()

View File

@ -29,7 +29,7 @@ helpers.staticInitialization( True )
# An elementary capacitor unit can be a part of C1 or C2 according to the matching scheme. However, to respect common-centroid layout specifications, for C1 and C2 to be equal, the matrix number of colums and number of rows must be both even. Addionnally, the number of elementary capacitors dedicated to C1 must be equal to those dedicated to C2. These two conditions are tested in one of the class methods. An exception is raised if at least one of the two is not respected. # An elementary capacitor unit can be a part of C1 or C2 according to the matching scheme. However, to respect common-centroid layout specifications, for C1 and C2 to be equal, the matrix number of colums and number of rows must be both even. Addionnally, the number of elementary capacitors dedicated to C1 must be equal to those dedicated to C2. These two conditions are tested in one of the class methods. An exception is raised if at least one of the two is not respected.
class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks ): class RoutMatchedCapacitor( VerticalRoutingTracks ):
rules = oroshi.getRules() rules = oroshi.getRules()
@ -152,34 +152,37 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
trace( 101, '\tminimum before adjust: {0}\n'.format( DbU.getValueString(self.minimumPosition) )) trace( 101, '\tminimum before adjust: {0}\n'.format( DbU.getValueString(self.minimumPosition) ))
trace( 101, '\tdY: {0}\n'.format( DbU.getValueString(dY) )) trace( 101, '\tdY: {0}\n'.format( DbU.getValueString(dY) ))
firstVRTId = "t0" firstVRTId = 't0'
lastVRTId = self.vRoutingTrackXCenter[-1].keys()[-1] lastVRTId = list(self.vRoutingTrackXCenter[-1].keys())[-1]
firstIndex = int(firstVRTId[1])
lastIndex = int( lastVRTId[1])
print( lastVRTId )
if self.dummyRing: if self.dummyRing:
xMin = self.abutmentBox.getXMin() xMin = self.abutmentBox.getXMin()
xMax = self.abutmentBox.getXMax() xMax = self.abutmentBox.getXMax()
else: else:
trackSpacing = (self.vRoutingTrack_width + self.vpitch + self.metal3Width)/2 trackSpacing = (self.vRoutingTrack_width + self.vpitch + self.metal3Width)/2
if firstVRTId > len(self.vRoutingTrackXCenter[ 0]): if firstIndex > len(self.vRoutingTrackXCenter[0]):
xMin = self.abutmentBox.getXMin() - trackSpacing xMin = self.abutmentBox.getXMin() - trackSpacing
else: else:
xMin = self.vRoutingTrackXCenter[ 0][firstVRTId] - trackSpacing xMin = self.vRoutingTrackXCenter[0][firstVRTId] - trackSpacing
if lastVRTId > len(self.vRoutingTrackXCenter[-1]): if lastIndex > len(self.vRoutingTrackXCenter[-1]):
xMax = self.abutmentBox.getXMax() + trackSpacing xMax = self.abutmentBox.getXMax() + trackSpacing
else: else:
xMax = self.vRoutingTrackXCenter[-1][ lastVRTId] + trackSpacing xMax = self.vRoutingTrackXCenter[-1][lastVRTId] + trackSpacing
width = xMax - xMin width = xMax - xMin
widthAdjust = width % (2*self.vpitch) widthAdjust = width % (2*self.vpitch)
if widthAdjust: if widthAdjust:
widthAdjust = 2*self.vpitch - widthAdjust widthAdjust = 2*self.vpitch - widthAdjust
xMax += widthAdjust/2 xMax += widthAdjust//2
xMin -= widthAdjust/2 xMin -= widthAdjust//2
self.device.setAbutmentBox( Box( xMin self.device.setAbutmentBox( Box( int(xMin)
, self.minimumPosition - dY , int(self.minimumPosition - dY)
, xMax , int(xMax)
, self.maximumPosition + dY ) ) , int(self.maximumPosition + dY )) )
trace( 101, '\tHeight after tracks enclosure: {0}\n'.format( DbU.getValueString(self.device.getAbutmentBox().getHeight()) )) trace( 101, '\tHeight after tracks enclosure: {0}\n'.format( DbU.getValueString(self.device.getAbutmentBox().getHeight()) ))
if not bbMode : if not bbMode :
@ -503,7 +506,7 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
def drawHRoutingTracks( self , routingTracksLayer ): def drawHRoutingTracks( self , routingTracksLayer ):
lastVRTId = self.vRoutingTrackXCenter[-1].keys()[-1] lastVRTId = list(self.vRoutingTrackXCenter[-1].keys())[-1]
firstVRTId = "t0" firstVRTId = "t0"
#doDummyRing = 1 if self.dummyRing == True else 0 #doDummyRing = 1 if self.dummyRing == True else 0
#dxSource = self.vRoutingTrackXCenter[0][firstVRTId] - self.vRoutingTrack_width/2 if not self.dummyRing else self.abutmentBox.getXMin() #dxSource = self.vRoutingTrackXCenter[0][firstVRTId] - self.vRoutingTrack_width/2 if not self.dummyRing else self.abutmentBox.getXMin()
@ -519,10 +522,10 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
horizontal = Horizontal.create( net horizontal = Horizontal.create( net
, routingTracksLayer , routingTracksLayer
, self.hRoutingtrackYCenter[i][j] , int(self.hRoutingtrackYCenter[i][j])
, self.hRoutingTrack_width , int(self.hRoutingTrack_width)
, dxSource , int(dxSource)
, dxTarget ) , int(dxTarget) )
NetExternalComponents.setExternal( horizontal ) NetExternalComponents.setExternal( horizontal )
return return
@ -537,8 +540,18 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
[ t , b ] = [ self.nets[self.matchingScheme[i][j]][0], self.nets[self.matchingScheme[i][j]][1] ] [ t , b ] = [ self.nets[self.matchingScheme[i][j]][0], self.nets[self.matchingScheme[i][j]][1] ]
dxDict = self.__computeConnections__( i,j, self.matchingScheme[i][j] ) dxDict = self.__computeConnections__( i,j, self.matchingScheme[i][j] )
Horizontal.create ( t, xPlateRLayer , self.hRoutingLayerYCenter["topPlate" ][i][j] , self.hRoutingLayer_width , dxDict["topPlate" ][ "source" ] , dxDict["topPlate" ][ "target" ] ) Horizontal.create ( t
Horizontal.create ( b, xPlateRLayer , self.hRoutingLayerYCenter["bottomPlate"][i][j] , self.hRoutingLayer_width , dxDict["bottomPlate" ][ "source" ] , dxDict["bottomPlate" ][ "target" ] ) , xPlateRLayer
, int(self.hRoutingLayerYCenter["topPlate" ][i][j])
, int(self.hRoutingLayer_width)
, int(dxDict["topPlate" ][ "source" ])
, int(dxDict["topPlate" ][ "target" ]) )
Horizontal.create ( b
, xPlateRLayer
, int(self.hRoutingLayerYCenter["bottomPlate"][i][j])
, int(self.hRoutingLayer_width)
, int(dxDict["bottomPlate" ][ "source" ])
, int(dxDict["bottomPlate" ][ "target" ]) )
return return
@ -570,12 +583,12 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
for j in range( 0, self.matrixDim["columns"] ): for j in range( 0, self.matrixDim["columns"] ):
if ( j % 2 == 0 ): if ( j % 2 == 0 ):
leftVRTIds = self.capacitorIds[0:self.capacitorsNumber/2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0: int(self.capacitorsNumber/2+1)] leftVRTIds = self.capacitorIds[0:self.capacitorsNumber//2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0: int(self.capacitorsNumber//2+1)]
rightVRTIds = self.capacitorIds[self.capacitorsNumber/2 : self.capacitorsNumber] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber/2+1) : self.capacitorsNumber] rightVRTIds = self.capacitorIds[self.capacitorsNumber//2 : self.capacitorsNumber] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber//2+1) : self.capacitorsNumber]
else: else:
leftVRTIds = self.capacitorIds[self.capacitorsNumber/2 : self.capacitorsNumber] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber/2+1) : self.capacitorsNumber] leftVRTIds = self.capacitorIds[self.capacitorsNumber//2 : self.capacitorsNumber] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber//2+1) : self.capacitorsNumber]
rightVRTIds = self.capacitorIds[0:self.capacitorsNumber/2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0: int(self.capacitorsNumber/2+1)] rightVRTIds = self.capacitorIds[0:self.capacitorsNumber//2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0: int(self.capacitorsNumber//2+1)]
index1 = j if self.matchingScheme[i][j] in leftVRTIds else j+1 index1 = j if self.matchingScheme[i][j] in leftVRTIds else j+1
@ -605,7 +618,7 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
## Draws cuts to connect vertical routing tracks in metal 2 and horizontal routing tracks in metal 3. ## Draws cuts to connect vertical routing tracks in metal 2 and horizontal routing tracks in metal 3.
def drawCuts_vRoutingTrack_hRoutingTrack( self,cutLayer, cutNumber, enclosure_cut ): def drawCuts_vRoutingTrack_hRoutingTrack( self,cutLayer, cutNumber, enclosure_cut ):
keysList = self.hRoutingtrackYCenter.keys() keysList = list(self.hRoutingtrackYCenter.keys())
for i in range(0, len(self.vRoutingTrackXCenter) ): for i in range(0, len(self.vRoutingTrackXCenter) ):
for k in self.vRoutingTrackXCenter[i]: for k in self.vRoutingTrackXCenter[i]:
@ -698,10 +711,10 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
Vertical.create( net Vertical.create( net
, routingLayer , routingLayer
, topPlateRLayerXCenter , int(topPlateRLayerXCenter)
, topPlateRLayer_width , int(topPlateRLayer_width)
, dySource , int(dySource)
, dyTarget ) , int(dyTarget) )
return return
@ -731,12 +744,12 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
dxDict = { "bottomPlate": {}, "topPlate": {} } dxDict = { "bottomPlate": {}, "topPlate": {} }
if ( j % 2 == 0 ): if ( j % 2 == 0 ):
leftVRTIds = self.capacitorIds[0 :self.capacitorsNumber/2 ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0 : int(self.capacitorsNumber/2+1)] leftVRTIds = self.capacitorIds[0 :self.capacitorsNumber//2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0 : int(self.capacitorsNumber/2+1)]
rightVRTIds = self.capacitorIds[self.capacitorsNumber/2 : self.capacitorsNumber ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber/2+1) : self.capacitorsNumber ] rightVRTIds = self.capacitorIds[self.capacitorsNumber//2 : self.capacitorsNumber ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber//2+1) : self.capacitorsNumber ]
else: else:
leftVRTIds = self.capacitorIds[self.capacitorsNumber/2 : self.capacitorsNumber ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber/2+1) : self.capacitorsNumber ] leftVRTIds = self.capacitorIds[self.capacitorsNumber//2 : self.capacitorsNumber ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber//2+1) : self.capacitorsNumber ]
rightVRTIds = self.capacitorIds[0 : self.capacitorsNumber/2 ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0 : int(self.capacitorsNumber/2+1)] rightVRTIds = self.capacitorIds[0 : self.capacitorsNumber//2 ] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0 : int(self.capacitorsNumber//2+1)]
[topPlateLabel, bottomPlateLabel ] = [self.__setPlatesLabels__(i,j)["t"] , self.__setPlatesLabels__(i,j)["b"]] [topPlateLabel, bottomPlateLabel ] = [self.__setPlatesLabels__(i,j)["t"] , self.__setPlatesLabels__(i,j)["b"]]
@ -830,7 +843,7 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()

View File

@ -680,7 +680,7 @@ class RouteCapacitorSingle ( CapacitorUnit ):
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()

View File

@ -95,16 +95,16 @@ class CapacitorUnit():
def __initCapDim__( self, capacitance, capDim ): def __initCapDim__( self, capacitance, capDim ):
if capacitance != 0 and capDim.values() != []: if capacitance != 0 and len(capDim.values()):
if self.__computeCapacitance__( capDim, self.capacitorType ) == capacitance : if self.__computeCapacitance__( capDim, self.capacitorType ) == capacitance :
self.capDim = capDim self.capDim = capDim
else: else:
raise Error( 1, [ 'CapacitorUnit.__initCapDim__(): Please check compatibility between capacitance value {0},'.format(capacitance) raise Error( 1, [ 'CapacitorUnit.__initCapDim__(): Please check compatibility between capacitance value {0},'.format(capacitance)
, 'and the given capacitor dimensions {0}.'.format(capDim) ] ) , 'and the given capacitor dimensions {0}.'.format(capDim) ] )
elif capacitance == 0 and capDim.values() != []: elif capacitance == 0 and len(capDim.values()):
self.capDim = capDim self.capDim = capDim
capacitance = self.__computeCapacitance__( capDim, self.capacitorType ) capacitance = self.__computeCapacitance__( capDim, self.capacitorType )
elif capacitance != 0 and capDim.values() == [] : elif capacitance != 0 and len(capDim.values()) == 0 :
self.capDim = self.__computeCapDim__( capacitance, self.capacitorType ) self.capDim = self.__computeCapDim__( capacitance, self.capacitorType )
else: else:
raise Error( 1, [ 'CapacitorUnit.__initCapDim__(): Invalid capacitance and/or capacitance dimensions {0}, {1}.'.format(capacitance, capDim) raise Error( 1, [ 'CapacitorUnit.__initCapDim__(): Invalid capacitance and/or capacitance dimensions {0}, {1}.'.format(capacitance, capDim)
@ -161,12 +161,10 @@ class CapacitorUnit():
def __computeCapacitance__( self, capDim, capacitorType ): def __computeCapacitance__( self, capDim, capacitorType ):
[ areaCapacitorPerUnit, perimeterCapacitorPerUnit ] = self.__setCapacitorPerUnit__( capacitorType ) [ areaCapacitorPerUnit, perimeterCapacitorPerUnit ] = self.__setCapacitorPerUnit__( capacitorType )
areaCapacitance = toPhY(capDim["width"]) * toPhY(capDim["height"]) *areaCapacitorPerUnit areaCapacitance = toPhY(capDim["width"]) * toPhY(capDim["height"]) *areaCapacitorPerUnit
perimeterCapacitance = ( toPhY(capDim["width"]) + toPhY(capDim["height"]) )*perimeterCapacitorPerUnit perimeterCapacitance = ( toPhY(capDim["width"]) + toPhY(capDim["height"]) )*perimeterCapacitorPerUnit
capacitance = areaCapacitance + perimeterCapacitance capacitance = areaCapacitance + perimeterCapacitance
return capacitance return capacitance
@ -678,19 +676,19 @@ class CapacitorUnit():
def drawRoutingLayers( self, bottomPlateLayer, topPlateLayer, t, b ): def drawRoutingLayers( self, bottomPlateLayer, topPlateLayer, t, b ):
Vertical.create ( t, topPlateLayer Vertical.create ( t, topPlateLayer
, self.topPlateRLayerDict["XCenter"] , int(self.topPlateRLayerDict["XCenter"])
, self.topPlateRLayerDict["width" ] , int(self.topPlateRLayerDict["width" ])
, self.topPlateRLayerDict["YMin" ] , int(self.topPlateRLayerDict["YMin" ])
, self.topPlateRLayerDict["YMax" ] , int(self.topPlateRLayerDict["YMax" ])
) )
cutLinesXMins = [ self.cutLeftLineDict["XMin"], self.cutRightLineDict["XMin"] ] cutLinesXMins = [ self.cutLeftLineDict["XMin"], self.cutRightLineDict["XMin"] ]
for i in range(2): for i in range(2):
Vertical.create ( b, bottomPlateLayer Vertical.create ( b, bottomPlateLayer
, cutLinesXMins[i] , int(cutLinesXMins[i])
, self.bottomPlateRLayerDict["width"] , int(self.bottomPlateRLayerDict["width"])
, self.bottomPlateRLayerDict["YMin" ] , int(self.bottomPlateRLayerDict["YMin" ])
, self.bottomPlateRLayerDict["YMax" ] , int(self.bottomPlateRLayerDict["YMax" ])
) )
return return
@ -711,8 +709,18 @@ class CapacitorUnit():
def cutLine( self, net, layer, firstCutXCenter, firstCutYCenter, width_cut, height_cut, spacing_cut, cutNumber, direction ): def cutLine( self, net, layer, firstCutXCenter, firstCutYCenter, width_cut, height_cut, spacing_cut, cutNumber, direction ):
for i in range( cutNumber) : for i in range( cutNumber) :
segment = Contact.create( net, layer, firstCutXCenter + i*(width_cut + spacing_cut), firstCutYCenter, width_cut, height_cut ) if direction == 'horizontal' else Contact.create( net, layer, firstCutXCenter, firstCutYCenter + i*(height_cut + spacing_cut), width_cut, height_cut ) if direction == 'horizontal':
segment = Contact.create( net, layer
, int(firstCutXCenter + i*(width_cut + spacing_cut))
, int(firstCutYCenter)
, width_cut
, height_cut )
else:
segment = Contact.create( net
, layer, int(firstCutXCenter)
, int(firstCutYCenter + i*(height_cut + spacing_cut))
, width_cut
, height_cut )
return segment return segment
@ -829,7 +837,7 @@ class CapacitorUnit():
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()

View File

@ -38,7 +38,7 @@ import numpy
# is not respected. # is not respected.
class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ): class VerticalRoutingTracks ( CapacitorStack ):
rules = oroshi.getRules() rules = oroshi.getRules()
@ -128,10 +128,10 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
if self.vRoutingTrackXCenter[j][key] is not None: if self.vRoutingTrackXCenter[j][key] is not None:
Vertical.create( netsDistribution[j][k] Vertical.create( netsDistribution[j][k]
, vRoutingTracksLayer , vRoutingTracksLayer
, self.vRoutingTrackXCenter[j][key] , int(self.vRoutingTrackXCenter[j][key])
, self.vRoutingTrack_width , int(self.vRoutingTrack_width)
, self.getVTrackYMin() , int(self.getVTrackYMin())
, self.getVTrackYMax() ) , int(self.getVTrackYMax() ))
k = k + 1 if k < len(key)-1 else 0 k = k + 1 if k < len(key)-1 else 0
return return
@ -265,18 +265,18 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
capIdsToEliminate = [] capIdsToEliminate = []
capIdsj = capIdsToEliminatePerColumn[0] capIdsj = capIdsToEliminatePerColumn[0]
#print('capIdsj',capIdsj) #print('capIdsj',capIdsj)
sharedVRTIds = self.capacitorIds[0:self.capacitorsNumber/2] if self.capacitorsNumber % 2 == 0 else self.capacitorIds[0: int(self.capacitorsNumber/2+1)] sharedVRTIds = self.capacitorIds[0:self.capacitorsNumber//2] if self.capacitorsNumber % 2 == 0 else self.capacitorIds[0: int(self.capacitorsNumber//2+1)]
#print('sharedVRTIds',sharedVRTIds) #print('sharedVRTIds',sharedVRTIds)
intersection2 = list( set(capIdsj).intersection(set(sharedVRTIds)) ) intersection2 = list( set(capIdsj).intersection(set(sharedVRTIds)) )
capIdsToEliminate.append( [None] ) if intersection2 == [] else capIdsToEliminate.append( intersection2 ) capIdsToEliminate.append( [None] ) if len(intersection2) == 0 else capIdsToEliminate.append( intersection2 )
for j in range(0, len(capIdsToEliminatePerColumn) ): for j in range(0, len(capIdsToEliminatePerColumn) ):
capIdsj = capIdsToEliminatePerColumn[j] capIdsj = capIdsToEliminatePerColumn[j]
if (j % 2 == 0): if (j % 2 == 0):
sharedVRTIds = self.capacitorIds[self.capacitorsNumber/2 : self.capacitorsNumber] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber/2+1) : self.capacitorsNumber] sharedVRTIds = self.capacitorIds[self.capacitorsNumber//2 : self.capacitorsNumber] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[int(self.capacitorsNumber//2+1) : self.capacitorsNumber]
else: else:
sharedVRTIds = self.capacitorIds[0:self.capacitorsNumber/2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0: int(self.capacitorsNumber/2+1)] sharedVRTIds = self.capacitorIds[0:self.capacitorsNumber//2] if (self.capacitorsNumber % 2 == 0) else self.capacitorIds[0: int(self.capacitorsNumber//2+1)]
#print('sharedVRTIds',sharedVRTIds) #print('sharedVRTIds',sharedVRTIds)
@ -287,7 +287,7 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
intersection1 = list( set(capIdsj).intersection(set(capIdsjp1)) ) intersection1 = list( set(capIdsj).intersection(set(capIdsjp1)) )
intersection2 = list( set(intersection1).intersection(set(sharedVRTIds)) ) intersection2 = list( set(intersection1).intersection(set(sharedVRTIds)) )
capIdsToEliminate.append( [None] ) if intersection2 == [] else capIdsToEliminate.append( intersection2 ) capIdsToEliminate.append( [None] ) if len(intersection2) == 0 else capIdsToEliminate.append( intersection2 )
return capIdsToEliminate return capIdsToEliminate
@ -347,8 +347,12 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
def __setVRTsDistribution__( self ): def __setVRTsDistribution__( self ):
if self.capacitorsNumber % 2 == 0:
element = [ self.capacitorIds[0:self.capacitorsNumber/2], self.capacitorIds[self.capacitorsNumber/2:self.capacitorsNumber] ] if self.capacitorsNumber % 2 == 0 else [ self.capacitorIds[0:int( self.capacitorsNumber/2 + 1 )], self.capacitorIds[int( self.capacitorsNumber/2 + 1 ):self.capacitorsNumber] ] element = [ self.capacitorIds[0:self.capacitorsNumber//2]
, self.capacitorIds[self.capacitorsNumber//2:self.capacitorsNumber] ]
else:
element = [ self.capacitorIds[0:int( self.capacitorsNumber//2 + 1 )]
, self.capacitorIds[int( self.capacitorsNumber//2 + 1 ):self.capacitorsNumber] ]
u = 0 u = 0
for j in range(0,self.matrixDim["columns"]+1) : for j in range(0,self.matrixDim["columns"]+1) :
self.vRTsDistribution.append( element[u] ) self.vRTsDistribution.append( element[u] )
@ -363,7 +367,12 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
def __setNetsDistribution__( self ): def __setNetsDistribution__( self ):
netsList = self.nets[0:len(self.nets)-1] if self.dummyRing == True and self.dummyElement == False else self.nets netsList = self.nets[0:len(self.nets)-1] if self.dummyRing == True and self.dummyElement == False else self.nets
element = [ netsList[0:len(netsList)/2], netsList[len(netsList)/2:len(netsList)] ] if len(netsList) % 2 == 0 else [ netsList[0:int( len(netsList)/2 + 1 )], netsList[int( len(netsList)/2 + 1 ):len(netsList)] ] if len(netsList) % 2 == 0:
element = [ netsList[0:len(netsList)//2]
, netsList[len(netsList)//2:len(netsList)] ]
else:
element = [ netsList[0:int( len(netsList)//2 + 1 )]
, netsList[int( len(netsList)//2 + 1 ):len(netsList)] ]
u = 0 u = 0
netsDistribution = [] netsDistribution = []
for j in range(0,self.matrixDim["columns"]+1) : for j in range(0,self.matrixDim["columns"]+1) :
@ -382,7 +391,7 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
def __setPlatesDistribution__( self ): def __setPlatesDistribution__( self ):
element = [ self.capacitorIds[0:self.capacitorsNumber/2], self.capacitorIds[self.capacitorsNumber/2:self.capacitorsNumber] ] if self.capacitorsNumber % 2 == 0 else [ self.capacitorIds[0:int( self.capacitorsNumber/2 + 1 )], self.capacitorIds[int( self.capacitorsNumber/2 + 1 ):self.capacitorsNumber] ] element = [ self.capacitorIds[0:self.capacitorsNumber//2], self.capacitorIds[self.capacitorsNumber//2:self.capacitorsNumber] ] if self.capacitorsNumber % 2 == 0 else [ self.capacitorIds[0:int( self.capacitorsNumber//2 + 1 )], self.capacitorIds[int( self.capacitorsNumber//2 + 1 ):self.capacitorsNumber] ]
u = 0 u = 0
for j in range(0,self.matrixDim["columns"]+1) : for j in range(0,self.matrixDim["columns"]+1) :
@ -420,7 +429,7 @@ class VerticalRoutingTracks ( CapacitorUnit, CapacitorStack ):
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()

View File

@ -166,7 +166,7 @@ def layout ( device, bbMode ):
trace( 100, '++' ) trace( 100, '++' )
#paramsMatrix.trace() #paramsMatrix.trace()
except Exception, e: except Exception as e:
helpers.io.catch( e ) helpers.io.catch( e )
trace( 100, '---' ) trace( 100, '---' )

View File

@ -224,7 +224,7 @@ class NonUnitCapacitor(CapacitorUnit):
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()

View File

@ -7,7 +7,7 @@ from Hurricane import Box
from Hurricane import Net from Hurricane import Net
import helpers import helpers
import helpers.io import helpers.io
from helpers import trace from helpers import trace, l, u, n
#helpers.setTraceLevel( 100 ) #helpers.setTraceLevel( 100 )
@ -45,7 +45,12 @@ def layout ( device, bbMode ):
length = device.getParameter( 'L' ).getValue() length = device.getParameter( 'L' ).getValue()
bends = device.getParameter( 'bends' ).getValue() bends = device.getParameter( 'bends' ).getValue()
width = u( 8.0)
length = u(100.0)
bends = 1
trace( 100, '\tpR:{0}\n'.format(device.getParameter('R')) )
trace( 100, '\tpW:{0}\n'.format(device.getParameter('W')) ) trace( 100, '\tpW:{0}\n'.format(device.getParameter('W')) )
trace( 100, '\tpL:{0}\n'.format(device.getParameter('L')) )
trace( 100, '\tresistance:{0}, width:{1}, length:{2}\n'.format(resistance,width,length) ) trace( 100, '\tresistance:{0}, width:{1}, length:{2}\n'.format(resistance,width,length) )
typeArg = 'UnknownType' typeArg = 'UnknownType'
@ -72,7 +77,7 @@ def layout ( device, bbMode ):
trace( 100, '++' ) trace( 100, '++' )
#paramsMatrix.trace() #paramsMatrix.trace()
except Exception, e: except Exception as e:
helpers.io.catch( e ) helpers.io.catch( e )
trace( 100, '---' ) trace( 100, '---' )

View File

@ -1,6 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
import sys import sys
from Hurricane import * from Hurricane import *
from CRL import * from CRL import *
import Constant import Constant
@ -16,8 +16,8 @@ def doBreak( level, message ):
Breakpoint.stop( level, message ) Breakpoint.stop( level, message )
UpdateSession.open() UpdateSession.open()
def toDbU ( l ): return DbU.fromPhysical( l, DbU.UnitPowerMicro ) def toDbU ( l ): return DbU.fromPhysical( l , DbU.UnitPowerMicro )
def toPhy ( l ): return DbU.toPhysical ( l, DbU.UnitPowerMicro ) def toPhy ( l ): return DbU.toPhysical ( int(l), DbU.UnitPowerMicro )
def toFoundryGrid ( l ): def toFoundryGrid ( l ):
twoGrid = DbU.fromGrid( 2.0 ) twoGrid = DbU.fromGrid( 2.0 )
@ -152,7 +152,8 @@ class Resistor ( object ):
self.setSidesDimRules() self.setSidesDimRules()
if resdim.keys() == ["width","length"] and side in ["width","length"]: print( resdim )
if list(resdim.keys()) == ["width","length"] and side in ["width","length"]:
if side == "width" : if side == "width" :
rule = self.minWidth_resistorPlate rule = self.minWidth_resistorPlate
@ -304,7 +305,7 @@ class Resistor ( object ):
if self.resistorType == "RPOLYH" : self.layers["hres" ] = technology.getLayer( "hres" ) if self.resistorType == "RPOLYH" : self.layers["hres" ] = technology.getLayer( "hres" )
if self.resistorType == "RPOLY2PH" : self.layers["restrm"] = technology.getLayer( "restrm" ) if self.resistorType == "RPOLY2PH" : self.layers["restrm"] = technology.getLayer( "restrm" )
return self.layers return self.layers
def create( self, bbMode = False ): def create( self, bbMode = False ):
@ -312,7 +313,7 @@ class Resistor ( object ):
UpdateSession.open() UpdateSession.open()
layerDict = self.getLayers() layerDict = self.getLayers()
self.computeDimensions(bbMode) self.computeDimensions(bbMode)
self.drawAbutmentBox () self.drawAbutmentBox ()
self.device.setAbutmentBox( self.abutmentBox ) self.device.setAbutmentBox( self.abutmentBox )
@ -436,7 +437,7 @@ class Resistor ( object ):
abutmentBoxSide2 = self.resDim ["length"] + 2*self.resPlateExtrimities["length"] + 2*self.enclosure_resistor_abutmentBox abutmentBoxSide2 = self.resDim ["length"] + 2*self.resPlateExtrimities["length"] + 2*self.enclosure_resistor_abutmentBox
if self.snakeMode : if self.snakeMode :
if self.resistorType == "RPOLYH" : resistor_width = self.hresLayerDict.values()[0] if self.resistorType == "RPOLYH" : resistor_width = list(self.hresLayerDict.values())[0]
if self.resistorType == "RPOLY2PH" : resistor_width = (self.bends+1)*self.snakeSegmentDict["width"] + self.bends*self.snakeSegments_spacing if self.resistorType == "RPOLY2PH" : resistor_width = (self.bends+1)*self.snakeSegmentDict["width"] + self.bends*self.snakeSegments_spacing
abutmentBoxSide1 = resistor_width + 2*self.enclosure_resistor_abutmentBox #width abutmentBoxSide1 = resistor_width + 2*self.enclosure_resistor_abutmentBox #width
@ -479,8 +480,8 @@ class Resistor ( object ):
self.resistorPlateDict["width" ] = self.resDim["width" ] self.resistorPlateDict["width" ] = self.resDim["width" ]
self.resistorPlateDict["length" ] = self.resDim["length"] self.resistorPlateDict["length" ] = self.resDim["length"]
if self.direction == "vertical" : keysList = ["XCenter","YMin","YMax","XMin","width" ] if self.direction == "vertical" : keysList = ["XCenter","YMin","YMax","XMin","width" ]
if self.direction == "horizontal" : keysList = ["YCenter","XMin","XMax","YMin","height"] if self.direction == "horizontal" : keysList = ["YCenter","XMin","XMax","YMin","height"]
self.resistorPlateDict[ keysList[0] ] = self.abutmentBoxDict [keysList[3]] + self.abutmentBoxDict [keysList[4]]/2 self.resistorPlateDict[ keysList[0] ] = self.abutmentBoxDict [keysList[3]] + self.abutmentBoxDict [keysList[4]]/2
self.resistorPlateDict[ keysList[1] ] = self.abutmentBoxDict [keysList[1]] + self.enclosure_resistor_abutmentBox + self.resPlateExtrimities["length"] self.resistorPlateDict[ keysList[1] ] = self.abutmentBoxDict [keysList[1]] + self.enclosure_resistor_abutmentBox + self.resPlateExtrimities["length"]
@ -512,7 +513,7 @@ class Resistor ( object ):
## The first bend is the lowest one (horizontally) ## The first bend is the lowest one (horizontally)
def computeFirstSnakeSegmentPosition( self ) : def computeFirstSnakeSegmentPosition( self ) :
if self.direction == "vertical" : if self.direction == "vertical" :
if self.bends > 1 : firstExtrimity_width = self.resPlateExtrimities["width"] if self.bends > 1 : firstExtrimity_width = self.resPlateExtrimities["width"]
if self.bends == 1 : firstExtrimity_width = self.resPlateExtrimity1 ["width"] if self.bends == 1 : firstExtrimity_width = self.resPlateExtrimity1 ["width"]
@ -528,7 +529,7 @@ class Resistor ( object ):
self.snakeSegmentDict ["YMax" ] = self.snakeSegmentDict["YMin"] + self.snakeSegmentDict["length"] self.snakeSegmentDict ["YMax" ] = self.snakeSegmentDict["YMin"] + self.snakeSegmentDict["length"]
if self.direction == "horizontal" : if self.direction == "horizontal" :
if self.bends > 1 : firstExtrimity_length = self.resPlateExtrimities["length"] if self.bends > 1 : firstExtrimity_length = self.resPlateExtrimities["length"]
if self.bends == 1 : firstExtrimity_length = self.resPlateExtrimity1 ["length"] if self.bends == 1 : firstExtrimity_length = self.resPlateExtrimity1 ["length"]
@ -543,26 +544,19 @@ class Resistor ( object ):
self.snakeSegmentDict ["XMax" ] = self.snakeSegmentDict["XMin"] + self.snakeSegmentDict["length"] self.snakeSegmentDict ["XMax" ] = self.snakeSegmentDict["XMin"] + self.snakeSegmentDict["length"]
return
def computeHRESLayerPosition( self ): def computeHRESLayerPosition( self ):
if self.direction == "vertical" :
if self.direction == "vertical" :
self.hresLayerDict["XCenter"] = self.abutmentBox.getXCenter() self.hresLayerDict["XCenter"] = self.abutmentBox.getXCenter()
self.hresLayerDict["YMin" ] = self.abutmentBox.getYMin() + self.enclosure_resistor_abutmentBox self.hresLayerDict["YMin" ] = self.abutmentBox.getYMin() + self.enclosure_resistor_abutmentBox
self.hresLayerDict["YMax" ] = self.abutmentBox.getYMax() - self.enclosure_resistor_abutmentBox self.hresLayerDict["YMax" ] = self.abutmentBox.getYMax() - self.enclosure_resistor_abutmentBox
if self.direction == "horizontal" : if self.direction == "horizontal" :
self.hresLayerDict["YCenter"] = self.abutmentBox.getYCenter() self.hresLayerDict["YCenter"] = self.abutmentBox.getYCenter()
self.hresLayerDict["XMin" ] = self.abutmentBox.getXMin() + self.enclosure_resistor_abutmentBox self.hresLayerDict["XMin" ] = self.abutmentBox.getXMin() + self.enclosure_resistor_abutmentBox
self.hresLayerDict["XMax" ] = self.abutmentBox.getXMax() - self.enclosure_resistor_abutmentBox self.hresLayerDict["XMax" ] = self.abutmentBox.getXMax() - self.enclosure_resistor_abutmentBox
return
def drawLayer( self, layerLabel, layer): def drawLayer( self, layerLabel, layer):
thiknessKey = "width" thiknessKey = "width"
@ -588,25 +582,25 @@ class Resistor ( object ):
if self.direction == "vertical" : if self.direction == "vertical" :
for i in range(0, maxIterations) : for i in range(0, maxIterations) :
print self.nets[0], layer \ print( self.nets[0], layer \
, positionParams["XCenter" ] + i*centerTranslation \ , positionParams["XCenter" ] + i*centerTranslation \
, positionParams[thiknessKey] \ , positionParams[thiknessKey] \
, positionParams["YMin" ] \ , positionParams["YMin" ] \
, positionParams["YMax" ] , positionParams["YMax" ] )
Vertical.create ( self.nets[0], layer Vertical.create ( self.nets[0], layer
, positionParams["XCenter" ] + i*centerTranslation , int(positionParams["XCenter" ] + i*centerTranslation)
, positionParams[thiknessKey] , int(positionParams[thiknessKey])
, positionParams["YMin" ] , int(positionParams["YMin" ])
, positionParams["YMax" ] , int(positionParams["YMax" ])
) )
if self.direction == "horizontal" : if self.direction == "horizontal" :
for i in range(0, maxIterations) : for i in range(0, maxIterations) :
Horizontal.create( self.nets[0], layer Horizontal.create( self.nets[0], layer
, positionParams["YCenter" ] + i*centerTranslation , int(positionParams["YCenter" ] + i*centerTranslation)
, positionParams[thiknessKey] , int(positionParams[thiknessKey])
, positionParams["XMin" ] , int(positionParams["XMin" ])
, positionParams["XMax" ] , int(tositionParams["XMax" ] )
) )
return return
@ -629,18 +623,18 @@ class Resistor ( object ):
if self.direction == "vertical" : if self.direction == "vertical" :
Vertical.create ( self.nets[0], layer Vertical.create ( self.nets[0], layer
, self.resdefLayerDict["XCenter"] , int(self.resdefLayerDict["XCenter"])
, self.resdefLayerDict["width" ] , int(self.resdefLayerDict["width" ])
, self.resdefLayerDict["YMin" ] , int(self.resdefLayerDict["YMin" ])
, self.resdefLayerDict["YMax" ] , int(self.resdefLayerDict["YMax" ])
) )
if self.direction == "horizontal" : if self.direction == "horizontal" :
Horizontal.create( self.nets[0], layer Horizontal.create( self.nets[0], layer
, self.resdefLayerDict["YCenter"] , int(self.resdefLayerDict["YCenter"])
, self.resdefLayerDict["width" ] , int(self.resdefLayerDict["width" ])
, self.resdefLayerDict["XMin" ] , int(self.resdefLayerDict["XMin" ])
, self.resdefLayerDict["XMax" ] , int(self.resdefLayerDict["XMax" ])
) )
print("self.resdefLayerDict['width' ]",self.resdefLayerDict["width" ]) print("self.resdefLayerDict['width' ]",self.resdefLayerDict["width" ])
print("self.resistorPlateDict['width' ]",self.resistorPlateDict["width" ]) print("self.resistorPlateDict['width' ]",self.resistorPlateDict["width" ])
@ -664,10 +658,10 @@ class Resistor ( object ):
factor0 = 0 if ( i == self.bends and self.bends % 2 == 0 ) else 1 factor0 = 0 if ( i == self.bends and self.bends % 2 == 0 ) else 1
factor1 = 0 if ( i == self.bends and self.bends % 2 != 0 ) or i == 0 else 1 factor1 = 0 if ( i == self.bends and self.bends % 2 != 0 ) or i == 0 else 1
Vertical.create ( self.nets[0], layer Vertical.create ( self.nets[0], layer
, self.resdefLayerDict["XCenter"] + i*centerTranslation , int(self.resdefLayerDict["XCenter"] + i*centerTranslation)
, self.resdefLayerDict["width" ] , int(self.resdefLayerDict["width" ])
, self.resdefLayerDict["YMin" ] + factor0*extrimityTranslation , int(self.resdefLayerDict["YMin" ] + factor0*extrimityTranslation)
, self.resdefLayerDict["YMax" ] - factor1*extrimityTranslation , int(self.resdefLayerDict["YMax" ] - factor1*extrimityTranslation)
) )
if self.direction == "horizontal" : if self.direction == "horizontal" :
@ -678,10 +672,10 @@ class Resistor ( object ):
factor0 = 0 if i == 0 or (i == self.bends and self.bends % 2 != 0) else 1 factor0 = 0 if i == 0 or (i == self.bends and self.bends % 2 != 0) else 1
factor1 = 0 if i == self.bends and self.bends % 2 == 0 else 1 factor1 = 0 if i == self.bends and self.bends % 2 == 0 else 1
Horizontal.create( self.nets[0], layer Horizontal.create( self.nets[0], layer
, self.resdefLayerDict["YCenter"] + i*centerTranslation , int(self.resdefLayerDict["YCenter"] + i*centerTranslation)
, self.resdefLayerDict["width" ] , int(self.resdefLayerDict["width" ])
, self.resdefLayerDict["XMin" ] + factor0*extrimityTranslation , int(self.resdefLayerDict["XMin" ] + factor0*extrimityTranslation)
, self.resdefLayerDict["XMax" ] - factor1*extrimityTranslation , int(self.resdefLayerDict["XMax" ] - factor1*extrimityTranslation)
) )
return return
@ -706,10 +700,10 @@ class Resistor ( object ):
for i in range(0,self.bends) : for i in range(0,self.bends) :
Horizontal.create( self.nets[0], layer Horizontal.create( self.nets[0], layer
, snakeCornersYCenters[k] , int(snakeCornersYCenters[k] )
, self.snakeCornerDict["width"] + widthExtension , int(self.snakeCornerDict["width"] + widthExtension )
, self.snakeCornerDict["XMin" ] - self.minWidth_contact/4 + i*translation , int(self.snakeCornerDict["XMin" ] - self.minWidth_contact/4 + i*translation)
, self.snakeCornerDict["XMax" ] + self.minWidth_contact/4 + i*translation , int(self.snakeCornerDict["XMax" ] + self.minWidth_contact/4 + i*translation)
) )
k = k+1 if k<1 else 0 k = k+1 if k<1 else 0
@ -719,10 +713,10 @@ class Resistor ( object ):
for i in range(0,self.bends) : for i in range(0,self.bends) :
Vertical.create ( self.nets[0], layer Vertical.create ( self.nets[0], layer
, snakeCornersXCenters[k] , int(snakeCornersXCenters[k])
, self.snakeCornerDict["width"] + widthExtension , int(self.snakeCornerDict["width"] + widthExtension )
, self.snakeCornerDict["YMin" ] - self.minWidth_contact/4 + i*translation , int(self.snakeCornerDict["YMin" ] - self.minWidth_contact/4 + i*translation)
, self.snakeCornerDict["YMax" ] + self.minWidth_contact/4 + i*translation , int(self.snakeCornerDict["YMax" ] + self.minWidth_contact/4 + i*translation)
) )
k = k+1 if k<1 else 0 k = k+1 if k<1 else 0
@ -769,13 +763,13 @@ class Resistor ( object ):
heightAdjust = height % (2*self.hpitch) heightAdjust = height % (2*self.hpitch)
if heightAdjust: if heightAdjust:
heightAdjust = 2*self.hpitch - heightAdjust heightAdjust = 2*self.hpitch - heightAdjust
ab.inflate( 0, heightAdjust/2 ) ab.inflate( 0, heightAdjust//2 )
width = ab.getWidth() width = ab.getWidth()
widthAdjust = width % (2*self.vpitch) widthAdjust = width % (2*self.vpitch)
if widthAdjust: if widthAdjust:
widthAdjust = 2*self.vpitch - widthAdjust widthAdjust = 2*self.vpitch - widthAdjust
ab.inflate( widthAdjust/2, 0 ) ab.inflate( widthAdjust//2, 0 )
self.abutmentBox = ab self.abutmentBox = ab
return return
@ -848,16 +842,16 @@ class Resistor ( object ):
if self.snakeMode and self.bends % 2 == 0 : [ hTranslation , vTranslation ] = [ translation2 , translation1 ] if self.snakeMode and self.bends % 2 == 0 : [ hTranslation , vTranslation ] = [ translation2 , translation1 ]
if self.snakeMode and self.bends % 2 != 0 : [ hTranslation , vTranslation ] = [ translation2 , 0 ] if self.snakeMode and self.bends % 2 != 0 : [ hTranslation , vTranslation ] = [ translation2 , 0 ]
self.terminal1Box = Box( self.resPlateExtensions["ex1"]["XMin"] self.terminal1Box = Box( int(self.resPlateExtensions["ex1"]["XMin"])
, self.resPlateExtensions["ex1"]["YMin"] , int(self.resPlateExtensions["ex1"]["YMin"])
, self.resPlateExtensions["ex1"]["XMax"] , int(self.resPlateExtensions["ex1"]["XMax"])
, self.resPlateExtensions["ex1"]["YMax"] , int(self.resPlateExtensions["ex1"]["YMax"])
) )
self.terminal2Box = Box( self.resPlateExtensions["ex1"]["XMin"] - hTranslation self.terminal2Box = Box( int(self.resPlateExtensions["ex1"]["XMin"] - hTranslation)
, self.resPlateExtensions["ex1"]["YMin"] + vTranslation , int(self.resPlateExtensions["ex1"]["YMin"] + vTranslation)
, self.resPlateExtensions["ex1"]["XMax"] - hTranslation , int(self.resPlateExtensions["ex1"]["XMax"] - hTranslation)
, self.resPlateExtensions["ex1"]["YMax"] + vTranslation , int(self.resPlateExtensions["ex1"]["YMax"] + vTranslation)
) )
if self.direction == "horizontal" : if self.direction == "horizontal" :
@ -927,18 +921,18 @@ class Resistor ( object ):
if self.direction == "vertical" : if self.direction == "vertical" :
for i in [0,1] : Horizontal.create( self.nets[i], layer for i in [0,1] : Horizontal.create( self.nets[i], layer
, self.pImplant_layerDict["YCenter"] + i*centerTranslation , int(self.pImplant_layerDict["YCenter"] + i*centerTranslation)
, self.pImplant_layerDict["length" ] , int(self.pImplant_layerDict["length" ])
, self.pImplant_layerDict["XMin" ] - i*extrimitiesTranslation , int(self.pImplant_layerDict["XMin" ] - i*extrimitiesTranslation)
, self.pImplant_layerDict["XMax" ] - i*extrimitiesTranslation , int(self.pImplant_layerDict["XMax" ] - i*extrimitiesTranslation)
) )
if self.direction == "horizontal" : if self.direction == "horizontal" :
for i in [0,1] : Vertical.create ( self.nets[i], layer for i in [0,1] : Vertical.create ( self.nets[i], layer
, self.pImplant_layerDict["XCenter"] + i*centerTranslation , int(self.pImplant_layerDict["XCenter"] + i*centerTranslation)
, self.pImplant_layerDict["length" ] , int(self.pImplant_layerDict["length" ])
, self.pImplant_layerDict["YMin" ] + i*extrimitiesTranslation , int(self.pImplant_layerDict["YMin" ] + i*extrimitiesTranslation)
, self.pImplant_layerDict["YMax" ] + i*extrimitiesTranslation , int(self.pImplant_layerDict["YMax" ] + i*extrimitiesTranslation)
) )
@ -1030,16 +1024,17 @@ class Resistor ( object ):
if self.direction == "vertical" : if self.direction == "vertical" :
Horizontal.create( self.nets[0] Horizontal.create( self.nets[0]
, layer, self.t1CutCenterDict["YCenter"] , layer
, layer_width , int(self.t1CutCenterDict["YCenter"])
, source1 , int(layer_width)
, target1 ) , int(source1)
, int(target1) )
Horizontal.create( self.nets[1] Horizontal.create( self.nets[1]
, layer , layer
, self.t2CutCenterDict["YCenter"] , int(self.t2CutCenterDict["YCenter"])
, layer_width , int(layer_width)
, source2 , int(source2)
, target2) , int(target2))
trace( 101, '\tIN PAD self.t1CutCenterDict["XCenter"] = {0}\n'.format(DbU.getValueString(self.t1CutCenterDict["XCenter"])) ) trace( 101, '\tIN PAD self.t1CutCenterDict["XCenter"] = {0}\n'.format(DbU.getValueString(self.t1CutCenterDict["XCenter"])) )
trace( 101, '\tIN PAD source1 = {0}\n'.format(DbU.getValueString(source1)) ) trace( 101, '\tIN PAD source1 = {0}\n'.format(DbU.getValueString(source1)) )
@ -1260,8 +1255,8 @@ class Resistor ( object ):
, [rx8 , ry8 ] , [rx9, ry9 ] , [rx8 , ry8 ] , [rx9, ry9 ]
] ]
for p in rightCorCordinatesList : for p in rightCorCordinatesList :
self.rightCorPointsVector.append(Point(p[0],p[1])) self.rightCorPointsVector.append(Point(int(p[0]),int(p[1])))
self.leftCorPointsVector.append (Point(p[0],p[1])) self.leftCorPointsVector.append (Point(int(p[0]),int(p[1])))
translationList = [ self.snakeSegmentDict["length"] translationList = [ self.snakeSegmentDict["length"]
, self.snakeSegmentDict["length"] + 2*param1 , self.snakeSegmentDict["length"] + 2*param1
@ -1276,9 +1271,9 @@ class Resistor ( object ):
] ]
if self.direction == "vertical" : if self.direction == "vertical" :
for i in range(0, len(self.leftCorPointsVector)) : self.leftCorPointsVector[i].translate( 0 , translationList[i] ) for i in range(0, len(self.leftCorPointsVector)) : self.leftCorPointsVector[i].translate( 0 , int(translationList[i]) )
if self.direction == "horizontal" : if self.direction == "horizontal" :
for i in range(0, len(self.leftCorPointsVector)) : self.leftCorPointsVector[i].translate( - translationList[i] , 0) for i in range(0, len(self.leftCorPointsVector)) : self.leftCorPointsVector[i].translate( int(- translationList[i]) , 0)
return return
@ -1286,8 +1281,8 @@ class Resistor ( object ):
def drawCorners135( self, layer ): def drawCorners135( self, layer ):
self.computeFirstSnakeCornerPosition135() self.computeFirstSnakeCornerPosition135()
if self.bends % 2 == 0 : [ rightCornersNum, leftCornersNum ] = [ self.bends/2 , self.bends/2 ] if self.bends % 2 == 0 : [ rightCornersNum, leftCornersNum ] = [ self.bends//2 , self.bends//2 ]
if self.bends % 2 != 0 : [ rightCornersNum, leftCornersNum ] = [ (self.bends+1)/2 , (self.bends-1)/2 ] if self.bends % 2 != 0 : [ rightCornersNum, leftCornersNum ] = [ (self.bends+1)//2 , (self.bends-1)//2 ]
translationFactor = 2*(self.snakeSegmentDict["width"] + self.snakeSegments_spacing) translationFactor = 2*(self.snakeSegmentDict["width"] + self.snakeSegments_spacing)
@ -1299,12 +1294,12 @@ class Resistor ( object ):
for i in range(0, leftCornersNum ) : for i in range(0, leftCornersNum ) :
if i == 0 : if i == 0 :
if self.direction == "vertical" : Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(dxTranslation/2,dyTranslation) if self.direction == "vertical" : Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(dxTranslation//2,dyTranslation)
if self.direction == "horizontal": Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(dxTranslation,dyTranslation/2) if self.direction == "horizontal": Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(dxTranslation,dyTranslation//2)
if i != 0 : if i != 0 :
if self.direction == "vertical" : Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(i*3*dxTranslation/2,dyTranslation) if self.direction == "vertical" : Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(i*3*dxTranslation//2,dyTranslation)
if self.direction == "horizontal": Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(dxTranslation,i*3*dyTranslation/2) if self.direction == "horizontal": Rectilinear.create(self.nets[0], layer, self.leftCorPointsVector).translate(dxTranslation,i*3*dyTranslation//2)
return return
@ -1332,7 +1327,20 @@ class Resistor ( object ):
def cutLine( self, net, layer, firstCutXCenter, firstCutYCenter, width_cut, height_cut, spacing_cut, cutNumber, direction ): def cutLine( self, net, layer, firstCutXCenter, firstCutYCenter, width_cut, height_cut, spacing_cut, cutNumber, direction ):
for i in range(0, cutNumber) : for i in range(0, cutNumber) :
segment = Contact.create( net, layer, firstCutXCenter + i*(width_cut + spacing_cut), firstCutYCenter, width_cut, height_cut ) if direction == 'horizontal' else Contact.create( net, layer, firstCutXCenter, firstCutYCenter + i*(height_cut + spacing_cut), width_cut, height_cut ) if direction == 'horizontal':
segment = Contact.create( net
, layer
, int(firstCutXCenter + i*(width_cut + spacing_cut))
, int(firstCutYCenter)
, int(width_cut)
, int(height_cut) )
else:
segment = Contact.create( net
, layer
, int(firstCutXCenter)
, int(firstCutYCenter + i*(height_cut + spacing_cut))
, int(width_cut)
, int(height_cut) )
return segment return segment
@ -1389,32 +1397,32 @@ class Resistor ( object ):
edgeDelta = self.minWidth_contact/2 + self.minEnclosure_metal1_cut0 edgeDelta = self.minWidth_contact/2 + self.minEnclosure_metal1_cut0
if t1OnNorth: if t1OnNorth:
t1BoxM1 = Box( 0 t1BoxM1 = Box( int(0)
, self.t1CutCenterDict["YCenter"] - edgeDelta , int(self.t1CutCenterDict["YCenter"] - edgeDelta)
, m1Width , int(m1Width)
, t1YM2 + VIA1overhang , int(t1YM2 + VIA1overhang)
) )
else: else:
t1BoxM1 = Box( 0 t1BoxM1 = Box( int(0)
, t1YM2 - VIA1overhang , int(t1YM2 - VIA1overhang)
, m1Width , int(m1Width)
, self.t1CutCenterDict["YCenter"] + edgeDelta , int(self.t1CutCenterDict["YCenter"] + edgeDelta)
) )
t1BoxM1.translate( self.t1CutCenterDict["XCenter"] - edgeDelta, 0 ) t1BoxM1.translate( int(self.t1CutCenterDict["XCenter"] - edgeDelta), 0 )
if t2OnNorth: if t2OnNorth:
t2BoxM1 = Box( 0 t2BoxM1 = Box( int(0)
, self.t2CutCenterDict["YCenter"] - edgeDelta , int(self.t2CutCenterDict["YCenter"] - edgeDelta)
, m1Width , int(m1Width)
, t2YM2 + VIA1overhang , int(t2YM2 + VIA1overhang)
) )
else: else:
t2BoxM1 = Box( 0 t2BoxM1 = Box( int(0)
, t2YM2 - VIA1overhang , int(t2YM2 - VIA1overhang)
, m1Width , int(m1Width)
, self.t2CutCenterDict["YCenter"] + edgeDelta , int(self.t2CutCenterDict["YCenter"] + edgeDelta)
) )
t2BoxM1.translate( self.t2CutCenterDict["XCenter"] - edgeDelta, 0 ) t2BoxM1.translate( int(self.t2CutCenterDict["XCenter"] - edgeDelta), 0 )
self.drawM2Terminal( t1net, t1BoxM1, t1YM2 ) self.drawM2Terminal( t1net, t1BoxM1, t1YM2 )
self.drawM2Terminal( t2net, t2BoxM1, t2YM2 ) self.drawM2Terminal( t2net, t2BoxM1, t2YM2 )
@ -1426,43 +1434,43 @@ class Resistor ( object ):
ab = self.device.getAbutmentBox() ab = self.device.getAbutmentBox()
minBoxM1 = Box( boxM1.getCenter().getX(), axisM2 ) minBoxM1 = Box( boxM1.getCenter().getX(), axisM2 )
minBoxM1.inflate( self.minWidth_cut1/2 + self.minEnclosure_metal1_cut1 ) minBoxM1.inflate( int(self.minWidth_cut1/2 + self.minEnclosure_metal1_cut1) )
boxM1.merge( minBoxM1 ) boxM1.merge( minBoxM1 )
h = Horizontal.create( net h = Horizontal.create( net
, self.metal2 , self.metal2
, axisM2 , int(axisM2)
, self.metal2Width , int(self.metal2Width)
, ab.getXMin() , int(ab.getXMin())
, ab.getXMax() ) , int(ab.getXMax()) )
NetExternalComponents.setExternal( h ) NetExternalComponents.setExternal( h )
Vertical.create( net Vertical.create( net
, self.metal1 , self.metal1
, boxM1.getCenter().getX() , int(boxM1.getCenter().getX())
, boxM1.getWidth() , int(boxM1.getWidth())
, boxM1.getYMin() , int(boxM1.getYMin())
, boxM1.getYMax() , int(boxM1.getYMax())
) )
cutNumber = ((boxM1.getWidth() - 2*self.minEnclosure_metal1_cut1 - self.minWidth_cut1) \ cutNumber = ((boxM1.getWidth() - 2*self.minEnclosure_metal1_cut1 - self.minWidth_cut1) \
/ (self.minSpacing_cut1 + self.minWidth_cut1)) // (self.minSpacing_cut1 + self.minWidth_cut1))
if cutNumber <= 0: cutNumber = 1 if cutNumber <= 0: cutNumber = 1
centering = (boxM1.getWidth() - 2*self.minEnclosure_metal1_cut1 \ centering = (boxM1.getWidth() - 2*self.minEnclosure_metal1_cut1 \
- cutNumber * self.minWidth_cut1 \ - cutNumber * self.minWidth_cut1 \
- (cutNumber-1) * self.minSpacing_cut1) / 2 - (cutNumber-1) * self.minSpacing_cut1) // 2
xcut1 = boxM1.getXMin() + centering \ xcut1 = boxM1.getXMin() + centering \
+ self.minEnclosure_metal1_cut1 + self.minWidth_cut1/2 + self.minEnclosure_metal1_cut1 + self.minWidth_cut1//2
trace( 101, '\tcutNumber = {0}\n'.format(cutNumber) ) trace( 101, '\tcutNumber = {0}\n'.format(cutNumber) )
for i in range(cutNumber): for i in range(cutNumber):
trace( 101, '\t[{0}]\n'.format(i) ) trace( 101, '\t[{0}]\n'.format(i) )
Contact.create( net Contact.create( net
, self.cut1 , self.cut1
, xcut1 , int(xcut1)
, axisM2 , int(axisM2)
, self.minWidth_cut1 , int(self.minWidth_cut1)
, self.minWidth_cut1 , int(self.minWidth_cut1)
) )
xcut1 += self.minWidth_cut1 + self.minSpacing_cut1 xcut1 += self.minWidth_cut1 + self.minSpacing_cut1
@ -1473,7 +1481,7 @@ class Resistor ( object ):
def scriptMain( **kw ): def scriptMain( **kw ):
editor = None editor = None
if kw.has_key('editor') and kw['editor']: if 'editor' in kw and kw['editor']:
editor = kw['editor'] editor = kw['editor']
UpdateSession.open() UpdateSession.open()