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:
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 )
else:
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:
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 )
else:
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 :
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
if capacitance == unitCap : #compact
[ self.capacitance , self.unitCapDim ] = [ capacitance , self.compactCapDim ]
elif capacitance <> unitCap : #matrice
elif capacitance != unitCap : #matrice
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
@ -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 ):
@ -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]:
[ 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 ) \
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 == 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
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 ):
editor = None
if kw.has_key('editor') and kw['editor']:
if 'editor' in kw and kw['editor']:
editor = kw['editor']
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.
class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks ):
class RoutMatchedCapacitor( VerticalRoutingTracks ):
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, '\tdY: {0}\n'.format( DbU.getValueString(dY) ))
firstVRTId = "t0"
lastVRTId = self.vRoutingTrackXCenter[-1].keys()[-1]
firstVRTId = 't0'
lastVRTId = list(self.vRoutingTrackXCenter[-1].keys())[-1]
firstIndex = int(firstVRTId[1])
lastIndex = int( lastVRTId[1])
print( lastVRTId )
if self.dummyRing:
xMin = self.abutmentBox.getXMin()
xMax = self.abutmentBox.getXMax()
else:
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
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
else:
xMax = self.vRoutingTrackXCenter[-1][ lastVRTId] + trackSpacing
xMax = self.vRoutingTrackXCenter[-1][lastVRTId] + trackSpacing
width = xMax - xMin
widthAdjust = width % (2*self.vpitch)
if widthAdjust:
widthAdjust = 2*self.vpitch - widthAdjust
xMax += widthAdjust/2
xMin -= widthAdjust/2
xMax += widthAdjust//2
xMin -= widthAdjust//2
self.device.setAbutmentBox( Box( xMin
, self.minimumPosition - dY
, xMax
, self.maximumPosition + dY ) )
self.device.setAbutmentBox( Box( int(xMin)
, int(self.minimumPosition - dY)
, int(xMax)
, int(self.maximumPosition + dY )) )
trace( 101, '\tHeight after tracks enclosure: {0}\n'.format( DbU.getValueString(self.device.getAbutmentBox().getHeight()) ))
if not bbMode :
@ -503,7 +506,7 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
def drawHRoutingTracks( self , routingTracksLayer ):
lastVRTId = self.vRoutingTrackXCenter[-1].keys()[-1]
lastVRTId = list(self.vRoutingTrackXCenter[-1].keys())[-1]
firstVRTId = "t0"
#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()
@ -519,10 +522,10 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
horizontal = Horizontal.create( net
, routingTracksLayer
, self.hRoutingtrackYCenter[i][j]
, self.hRoutingTrack_width
, dxSource
, dxTarget )
, int(self.hRoutingtrackYCenter[i][j])
, int(self.hRoutingTrack_width)
, int(dxSource)
, int(dxTarget) )
NetExternalComponents.setExternal( horizontal )
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] ]
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 ( b, xPlateRLayer , self.hRoutingLayerYCenter["bottomPlate"][i][j] , self.hRoutingLayer_width , dxDict["bottomPlate" ][ "source" ] , dxDict["bottomPlate" ][ "target" ] )
Horizontal.create ( t
, 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
@ -570,12 +583,12 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
for j in range( 0, self.matrixDim["columns"] ):
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)]
rightVRTIds = 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[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]
else:
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)]
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)]
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.
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 k in self.vRoutingTrackXCenter[i]:
@ -698,10 +711,10 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
Vertical.create( net
, routingLayer
, topPlateRLayerXCenter
, topPlateRLayer_width
, dySource
, dyTarget )
, int(topPlateRLayerXCenter)
, int(topPlateRLayer_width)
, int(dySource)
, int(dyTarget) )
return
@ -731,12 +744,12 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
dxDict = { "bottomPlate": {}, "topPlate": {} }
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)]
rightVRTIds = 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[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 ]
else:
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)]
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)]
[topPlateLabel, bottomPlateLabel ] = [self.__setPlatesLabels__(i,j)["t"] , self.__setPlatesLabels__(i,j)["b"]]
@ -830,7 +843,7 @@ class RoutMatchedCapacitor( CapacitorUnit, CapacitorStack, VerticalRoutingTracks
def scriptMain( **kw ):
editor = None
if kw.has_key('editor') and kw['editor']:
if 'editor' in kw and kw['editor']:
editor = kw['editor']
UpdateSession.open()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ from Hurricane import Box
from Hurricane import Net
import helpers
import helpers.io
from helpers import trace
from helpers import trace, l, u, n
#helpers.setTraceLevel( 100 )
@ -45,7 +45,12 @@ def layout ( device, bbMode ):
length = device.getParameter( 'L' ).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, '\tpL:{0}\n'.format(device.getParameter('L')) )
trace( 100, '\tresistance:{0}, width:{1}, length:{2}\n'.format(resistance,width,length) )
typeArg = 'UnknownType'
@ -72,7 +77,7 @@ def layout ( device, bbMode ):
trace( 100, '++' )
#paramsMatrix.trace()
except Exception, e:
except Exception as e:
helpers.io.catch( e )
trace( 100, '---' )

View File

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