mirror of https://github.com/VLSIDA/OpenRAM.git
Document vlsiLayout functions in comments
This commit is contained in:
parent
c143f62b25
commit
1c9b5c7372
|
|
@ -2,8 +2,6 @@ from gdsPrimitives import *
|
||||||
from datetime import *
|
from datetime import *
|
||||||
import mpmath
|
import mpmath
|
||||||
import gdsPrimitives
|
import gdsPrimitives
|
||||||
import debug
|
|
||||||
debug_level=4
|
|
||||||
|
|
||||||
class VlsiLayout:
|
class VlsiLayout:
|
||||||
"""Class represent a hierarchical layout"""
|
"""Class represent a hierarchical layout"""
|
||||||
|
|
@ -15,7 +13,7 @@ class VlsiLayout:
|
||||||
modDate = datetime.now()
|
modDate = datetime.now()
|
||||||
self.structures=dict()
|
self.structures=dict()
|
||||||
self.layerNumbersInUse = []
|
self.layerNumbersInUse = []
|
||||||
self.debug = debug
|
self.debug = False
|
||||||
if name:
|
if name:
|
||||||
self.rootStructureName=name
|
self.rootStructureName=name
|
||||||
#create the ROOT structure
|
#create the ROOT structure
|
||||||
|
|
@ -260,14 +258,12 @@ class VlsiLayout:
|
||||||
Method to change the root pointer to another layout.
|
Method to change the root pointer to another layout.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#if self.debug: print "DEBUG: GdsMill vlsiLayout: changeRoot: %s "%newRoot
|
if self.debug: print "DEBUG: GdsMill vlsiLayout: changeRoot: %s "%newRoot
|
||||||
debug.info(debug_level,"DEBUG: GdsMill vlsiLayout: changeRoot: %s "%newRoot)
|
|
||||||
|
|
||||||
# Determine if newRoot exists
|
# Determine if newRoot exists
|
||||||
# layoutToAdd (default) or nameOfLayout
|
# layoutToAdd (default) or nameOfLayout
|
||||||
if (newRoot == 0 | ((newRoot not in self.structures) & ~create)):
|
if (newRoot == 0 | ((newRoot not in self.structures) & ~create)):
|
||||||
#print "ERROR: vlsiLayout.changeRoot: Name of new root [%s] not found and create flag is false"%newRoot
|
print "ERROR: vlsiLayout.changeRoot: Name of new root [%s] not found and create flag is false"%newRoot
|
||||||
debug.error(debug_level,"ERROR: vlsiLayout.changeRoot: Name of new root [%s] not found and create flag is false"+str(newRoot))
|
|
||||||
exit(1)
|
exit(1)
|
||||||
else:
|
else:
|
||||||
if ((newRoot not in self.structures) & create):
|
if ((newRoot not in self.structures) & create):
|
||||||
|
|
@ -281,15 +277,8 @@ class VlsiLayout:
|
||||||
Method to insert one layout into another at a particular offset.
|
Method to insert one layout into another at a particular offset.
|
||||||
"""
|
"""
|
||||||
offsetInLayoutUnits = (self.userUnits(offsetInMicrons[0]),self.userUnits(offsetInMicrons[1]))
|
offsetInLayoutUnits = (self.userUnits(offsetInMicrons[0]),self.userUnits(offsetInMicrons[1]))
|
||||||
#print "addInstance:offsetInLayoutUnits",offsetInLayoutUnits
|
if self.debug==1:
|
||||||
#offsetInLayoutUnits = ((offsetInMicrons[0]),(offsetInMicrons[1]))
|
print "DEBUG: GdsMill vlsiLayout: addInstance: type %s, nameOfLayout "%type(layoutToAdd),nameOfLayout
|
||||||
#print "DEBUG: addInstance offsetInLayoutUnits: %f, %f"%(self.userUnits(offsetInMicrons[0]), self.userUnits(offsetInMicrons[1]))
|
|
||||||
#if self.debug==1:
|
|
||||||
# print "DEBUG: GdsMill vlsiLayout: addInstance: type %s, nameOfLayout "%type(layoutToAdd),nameOfLayout
|
|
||||||
# print offsetInMicrons
|
|
||||||
# print offsetInLayoutUnits
|
|
||||||
debug.info(debug_level,"DEBUG: GdsMill vlsiLayout: addInstance: type "+str(layoutToAdd.rootStructureName))
|
|
||||||
debug.info(debug_level,"offset In Microns:"+str(offsetInMicrons)+"offset In LayoutUnits:"+str(offsetInLayoutUnits))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -302,10 +291,8 @@ class VlsiLayout:
|
||||||
StructureName = nameOfLayout #layoutToAdd
|
StructureName = nameOfLayout #layoutToAdd
|
||||||
StructureFound = False
|
StructureFound = False
|
||||||
for structure in layoutToAdd.structures:
|
for structure in layoutToAdd.structures:
|
||||||
# if self.debug: print structure, "N","N"
|
|
||||||
if StructureName in structure:
|
if StructureName in structure:
|
||||||
debug.info(debug_level,"DEBUG: Structure %s Found"+str(StructureName))
|
if self.debug: print "DEBUG: Structure %s Found"%StructureName
|
||||||
#if self.debug: print "DEBUG: Structure %s Found"%StructureName
|
|
||||||
StructureFound = True
|
StructureFound = True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -538,8 +525,7 @@ class VlsiLayout:
|
||||||
heightInBlocks = int(coverageHeight/effectiveBlock)
|
heightInBlocks = int(coverageHeight/effectiveBlock)
|
||||||
passFailRecord = []
|
passFailRecord = []
|
||||||
|
|
||||||
debug.info(debug_level,"Filling layer:"+str(layerToFill))
|
print "Filling layer:",layerToFill
|
||||||
#print "Filling layer:",layerToFill
|
|
||||||
def isThisBlockOk(startingStructureName,coordinates,rotateAngle=None):
|
def isThisBlockOk(startingStructureName,coordinates,rotateAngle=None):
|
||||||
#go through every boundary and check
|
#go through every boundary and check
|
||||||
for boundary in self.structures[startingStructureName].boundaries:
|
for boundary in self.structures[startingStructureName].boundaries:
|
||||||
|
|
@ -585,7 +571,7 @@ class VlsiLayout:
|
||||||
#if its bad, this global tempPassFail will be false
|
#if its bad, this global tempPassFail will be false
|
||||||
#if true, we can add the block
|
#if true, we can add the block
|
||||||
passFailRecord+=[self.tempPassFail]
|
passFailRecord+=[self.tempPassFail]
|
||||||
debug.info(debug_level,"Percent Complete:"+str(percentDone))
|
print "Percent Complete:"+str(percentDone)
|
||||||
|
|
||||||
|
|
||||||
passFailIndex=0
|
passFailIndex=0
|
||||||
|
|
@ -596,18 +582,18 @@ class VlsiLayout:
|
||||||
if passFailRecord[passFailIndex]:
|
if passFailRecord[passFailIndex]:
|
||||||
self.addBox(layerToFill, (blockX,blockY), width=blockSize, height=blockSize)
|
self.addBox(layerToFill, (blockX,blockY), width=blockSize, height=blockSize)
|
||||||
passFailIndex+=1
|
passFailIndex+=1
|
||||||
debug.info(debug_level,"Done\n\n")
|
print "Done\n\n"
|
||||||
|
|
||||||
def readLayoutBorder(self,borderlayer):
|
def readLayoutBorder(self,borderlayer):
|
||||||
for boundary in self.structures[self.rootStructureName].boundaries:
|
for boundary in self.structures[self.rootStructureName].boundaries:
|
||||||
if boundary.drawingLayer==borderlayer:
|
if boundary.drawingLayer==borderlayer:
|
||||||
debug.info(debug_level,"Find border "+str(boundary.coordinates))
|
if self.debug: print "Find border "+str(boundary.coordinates)
|
||||||
left_bottom=boundary.coordinates[0]
|
left_bottom=boundary.coordinates[0]
|
||||||
right_top=boundary.coordinates[2]
|
right_top=boundary.coordinates[2]
|
||||||
cellSize=[right_top[0]-left_bottom[0],right_top[1]-left_bottom[1]]
|
cellSize=[right_top[0]-left_bottom[0],right_top[1]-left_bottom[1]]
|
||||||
cellSizeMicron=[cellSize[0]*self.units[0],cellSize[1]*self.units[0]]
|
cellSizeMicron=[cellSize[0]*self.units[0],cellSize[1]*self.units[0]]
|
||||||
if not(cellSizeMicron):
|
if not(cellSizeMicron):
|
||||||
debug.error("Error: "+str(self.rootStructureName)+".cell_size information not found yet")
|
print "Error: "+str(self.rootStructureName)+".cell_size information not found yet"
|
||||||
return cellSizeMicron
|
return cellSizeMicron
|
||||||
|
|
||||||
def measureSize(self,startStructure):
|
def measureSize(self,startStructure):
|
||||||
|
|
@ -634,10 +620,10 @@ class VlsiLayout:
|
||||||
StrutureOrgin=[Struture[1][0],Struture[1][1]]
|
StrutureOrgin=[Struture[1][0],Struture[1][1]]
|
||||||
StrutureuVector=[Struture[2][0],Struture[2][1],Struture[2][2]]
|
StrutureuVector=[Struture[2][0],Struture[2][1],Struture[2][2]]
|
||||||
StruturevVector=[Struture[3][0],Struture[3][1],Struture[3][2]]
|
StruturevVector=[Struture[3][0],Struture[3][1],Struture[3][2]]
|
||||||
debug.info(debug_level,"Checking Structure: "+str(StrutureName))
|
#debug.info(debug_level,"Checking Structure: "+str(StrutureName))
|
||||||
debug.info(debug_level,"-Structure Struture Orgin:"+str(StrutureOrgin))
|
#debug.info(debug_level,"-Structure Struture Orgin:"+str(StrutureOrgin))
|
||||||
debug.info(debug_level,"-Structure direction: uVector["+str(StrutureuVector)+"]")
|
#debug.info(debug_level,"-Structure direction: uVector["+str(StrutureuVector)+"]")
|
||||||
debug.info(debug_level,"-Structure direction: vVector["+str(StruturevVector)+"]")
|
#debug.info(debug_level,"-Structure direction: vVector["+str(StruturevVector)+"]")
|
||||||
|
|
||||||
for boundary in self.structures[str(StrutureName)].boundaries:
|
for boundary in self.structures[str(StrutureName)].boundaries:
|
||||||
left_bottom=boundary.coordinates[0]
|
left_bottom=boundary.coordinates[0]
|
||||||
|
|
@ -665,24 +651,28 @@ class VlsiLayout:
|
||||||
return cellBoundary
|
return cellBoundary
|
||||||
|
|
||||||
def readPin(self,label_name,mod="offset"):
|
def readPin(self,label_name,mod="offset"):
|
||||||
|
"""
|
||||||
|
Search for a pin label and return all the largest enclosing rectangle.
|
||||||
|
"""
|
||||||
label_layer = None
|
label_layer = None
|
||||||
label_coordinate = [None, None]
|
label_coordinate = [None, None]
|
||||||
|
|
||||||
for Text in self.structures[self.rootStructureName].texts:
|
for Text in self.structures[self.rootStructureName].texts:
|
||||||
debug.info(debug_level,"Check Text object "+str(Text.textString)+" in "+str(self.rootStructureName))
|
|
||||||
debug.info(debug_level,"Length of text object: "+str(len(Text.textString)))
|
|
||||||
if Text.textString == label_name or Text.textString == label_name+"\x00":
|
if Text.textString == label_name or Text.textString == label_name+"\x00":
|
||||||
label_layer = Text.drawingLayer
|
label_layer = Text.drawingLayer
|
||||||
label_coordinate = Text.coordinates
|
label_coordinate = Text.coordinates
|
||||||
debug.info(debug_level,"Find label "+str(Text.textString)+" at "+str(Text.coordinates))
|
|
||||||
|
|
||||||
pin_boundary=self.readPinInStructureList(label_coordinate, label_layer)
|
pin_boundary=self.readPinInStructureList(label_coordinate, label_layer)
|
||||||
debug.info(debug_level, "Find pin covers "+str(label_name)+" at "+str(pin_boundary))
|
# Convert to user units
|
||||||
pin_boundary=[pin_boundary[0]*self.units[0],pin_boundary[1]*self.units[0],
|
pin_boundary=[pin_boundary[0]*self.units[0],pin_boundary[1]*self.units[0],
|
||||||
pin_boundary[2]*self.units[0],pin_boundary[3]*self.units[0]]
|
pin_boundary[2]*self.units[0],pin_boundary[3]*self.units[0]]
|
||||||
return [label_name, label_layer, pin_boundary]
|
return [label_name, label_layer, pin_boundary]
|
||||||
|
|
||||||
def readPinInStructureList(self,label_coordinates,layer):
|
def readPinInStructureList(self,label_coordinates,layer):
|
||||||
|
"""
|
||||||
|
Given the label coordinate, search for enclosing structures on the given layer.
|
||||||
|
Return the single biggest area rectangle.
|
||||||
|
"""
|
||||||
label_boundary = [None,None,None,None]
|
label_boundary = [None,None,None,None]
|
||||||
for TreeUnit in self.xyTree:
|
for TreeUnit in self.xyTree:
|
||||||
label_boundary=self.readPinInStruture(label_coordinates,layer,TreeUnit,label_boundary)
|
label_boundary=self.readPinInStruture(label_coordinates,layer,TreeUnit,label_boundary)
|
||||||
|
|
@ -690,14 +680,16 @@ class VlsiLayout:
|
||||||
|
|
||||||
|
|
||||||
def readPinInStruture(self,label_coordinates,layer,Struture,label_boundary):
|
def readPinInStruture(self,label_coordinates,layer,Struture,label_boundary):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
StrutureName=Struture[0]
|
StrutureName=Struture[0]
|
||||||
StrutureOrgin=[Struture[1][0],Struture[1][1]]
|
StrutureOrgin=[Struture[1][0],Struture[1][1]]
|
||||||
StrutureuVector=[Struture[2][0],Struture[2][1],Struture[2][2]]
|
StrutureuVector=[Struture[2][0],Struture[2][1],Struture[2][2]]
|
||||||
StruturevVector=[Struture[3][0],Struture[3][1],Struture[3][2]]
|
StruturevVector=[Struture[3][0],Struture[3][1],Struture[3][2]]
|
||||||
debug.info(debug_level,"Checking Structure: "+str(StrutureName))
|
#debug.info(debug_level,"Checking Structure: "+str(StrutureName))
|
||||||
debug.info(debug_level,"-Structure Struture Orgin:"+str(StrutureOrgin))
|
#debug.info(debug_level,"-Structure Struture Orgin:"+str(StrutureOrgin))
|
||||||
debug.info(debug_level,"-Structure direction: uVector["+str(StrutureuVector)+"]")
|
#debug.info(debug_level,"-Structure direction: uVector["+str(StrutureuVector)+"]")
|
||||||
debug.info(debug_level,"-Structure direction: vVector["+str(StruturevVector)+"]")
|
#debug.info(debug_level,"-Structure direction: vVector["+str(StruturevVector)+"]")
|
||||||
|
|
||||||
for boundary in self.structures[str(StrutureName)].boundaries:
|
for boundary in self.structures[str(StrutureName)].boundaries:
|
||||||
if layer==boundary.drawingLayer:
|
if layer==boundary.drawingLayer:
|
||||||
|
|
@ -710,12 +702,16 @@ class VlsiLayout:
|
||||||
|
|
||||||
result = self.labelInRectangle(label_coordinates[0],MetalBoundary)
|
result = self.labelInRectangle(label_coordinates[0],MetalBoundary)
|
||||||
if (result):
|
if (result):
|
||||||
debug.info(debug_level,"Rectangle(layer"+str(layer)+") at "+str(MetalBoundary))
|
#debug.info(debug_level,"Rectangle(layer"+str(layer)+") at "+str(MetalBoundary))
|
||||||
debug.info(debug_level,"covers label (offset"+str(label_coordinates)+")")
|
#debug.info(debug_level,"covers label (offset"+str(label_coordinates)+")")
|
||||||
label_boundary=self.returnBiggerBoundary(MetalBoundary,label_boundary)
|
label_boundary=self.returnBiggerBoundary(MetalBoundary,label_boundary)
|
||||||
return label_boundary
|
return label_boundary
|
||||||
|
|
||||||
def tranformRectangle(self,orignalRectangle,uVector,vVector):
|
def tranformRectangle(self,orignalRectangle,uVector,vVector):
|
||||||
|
"""
|
||||||
|
Transforms the four coordinates of a rectangle in space
|
||||||
|
and recomputes the left, bottom, right, up values.
|
||||||
|
"""
|
||||||
LeftBottom=mpmath.matrix([orignalRectangle[0],orignalRectangle[1]])
|
LeftBottom=mpmath.matrix([orignalRectangle[0],orignalRectangle[1]])
|
||||||
LeftBottom=self.tranformCoordinate(LeftBottom,uVector,vVector)
|
LeftBottom=self.tranformCoordinate(LeftBottom,uVector,vVector)
|
||||||
|
|
||||||
|
|
@ -730,6 +726,9 @@ class VlsiLayout:
|
||||||
return [Left,Bottom,Right,Up]
|
return [Left,Bottom,Right,Up]
|
||||||
|
|
||||||
def tranformCoordinate(self,Coordinate,uVector,vVector):
|
def tranformCoordinate(self,Coordinate,uVector,vVector):
|
||||||
|
"""
|
||||||
|
Rotate a coordinate in space.
|
||||||
|
"""
|
||||||
x=Coordinate[0]*uVector[0]+Coordinate[1]*uVector[1]
|
x=Coordinate[0]*uVector[0]+Coordinate[1]*uVector[1]
|
||||||
y=Coordinate[1]*vVector[1]+Coordinate[0]*vVector[0]
|
y=Coordinate[1]*vVector[1]+Coordinate[0]*vVector[0]
|
||||||
tranformCoordinate=[x,y]
|
tranformCoordinate=[x,y]
|
||||||
|
|
@ -737,6 +736,9 @@ class VlsiLayout:
|
||||||
|
|
||||||
|
|
||||||
def labelInRectangle(self,label_coordinate,Rectangle):
|
def labelInRectangle(self,label_coordinate,Rectangle):
|
||||||
|
"""
|
||||||
|
Checks if a coordinate is within a given rectangle.
|
||||||
|
"""
|
||||||
coordinate_In_Rectangle_x_range=(label_coordinate[0]>=int(Rectangle[0]))&(label_coordinate[0]<=int(Rectangle[2]))
|
coordinate_In_Rectangle_x_range=(label_coordinate[0]>=int(Rectangle[0]))&(label_coordinate[0]<=int(Rectangle[2]))
|
||||||
coordinate_In_Rectangle_y_range=(label_coordinate[1]>=int(Rectangle[1]))&(label_coordinate[1]<=int(Rectangle[3]))
|
coordinate_In_Rectangle_y_range=(label_coordinate[1]>=int(Rectangle[1]))&(label_coordinate[1]<=int(Rectangle[3]))
|
||||||
if coordinate_In_Rectangle_x_range & coordinate_In_Rectangle_y_range:
|
if coordinate_In_Rectangle_x_range & coordinate_In_Rectangle_y_range:
|
||||||
|
|
@ -745,14 +747,17 @@ class VlsiLayout:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def returnBiggerBoundary(self,comparedRectangle,label_boundary):
|
def returnBiggerBoundary(self,comparedRectangle,label_boundary):
|
||||||
|
"""
|
||||||
|
Compares two rectangles and returns the bigger in terms of area.
|
||||||
|
"""
|
||||||
if label_boundary[0]== None:
|
if label_boundary[0]== None:
|
||||||
label_boundary=comparedRectangle
|
label_boundary=comparedRectangle
|
||||||
debug.info(debug_level,"The label_boundary is initialized to "+str(label_boundary))
|
#debug.info(debug_level,"The label_boundary is initialized to "+str(label_boundary))
|
||||||
else:
|
else:
|
||||||
area_label_boundary=(label_boundary[2]-label_boundary[0])*(label_boundary[3]-label_boundary[1])
|
area_label_boundary=(label_boundary[2]-label_boundary[0])*(label_boundary[3]-label_boundary[1])
|
||||||
area_comparedRectangle=(comparedRectangle[2]-comparedRectangle[0])*(comparedRectangle[3]-comparedRectangle[1])
|
area_comparedRectangle=(comparedRectangle[2]-comparedRectangle[0])*(comparedRectangle[3]-comparedRectangle[1])
|
||||||
if area_label_boundary<=area_comparedRectangle:
|
if area_label_boundary<=area_comparedRectangle:
|
||||||
label_boundary = comparedRectangle
|
label_boundary = comparedRectangle
|
||||||
debug.info(debug_level,"The label_boundary is updated to "+str(label_boundary))
|
#debug.info(debug_level,"The label_boundary is updated to "+str(label_boundary))
|
||||||
return label_boundary
|
return label_boundary
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue