Add back LEF blockages. Remove "absolute" flags from GDS output

This commit is contained in:
Matt Guthaus 2018-09-05 09:28:43 -07:00
parent 8ffdcdf277
commit 0f87ba742f
3 changed files with 71 additions and 59 deletions

View File

@ -34,14 +34,14 @@ class geometry:
# coordinate += [(x, y)]
# return coordinate
# def transform_coords(self, coords, offset, mirr, angle):
# """Calculate coordinates after flip, rotate, and shift"""
# coordinate = []
# for item in coords:
# x = item[0]*math.cos(angle) - item[1]*mirr*math.sin(angle) + offset[0]
# y = item[0]*math.sin(angle) + item[1]*mirr*math.cos(angle) + offset[1]
# coordinate += [[x, y]]
# return coordinate
def transform_coords(self, coords, offset, mirr, angle):
"""Calculate coordinates after flip, rotate, and shift"""
coordinate = []
for item in coords:
x = item[0]*math.cos(angle) - item[1]*mirr*math.sin(angle) + offset[0]
y = item[0]*math.sin(angle) + item[1]*mirr*math.cos(angle) + offset[1]
coordinate += [[x, y]]
return coordinate
def normalize(self):
""" Re-find the LL and UR points after a transform """
@ -148,40 +148,40 @@ class instance(geometry):
debug.info(4, "creating instance: " + self.name)
# def get_blockages(self, layer, top=False):
# """ Retrieve rectangular blockages of all modules in this instance.
# Apply the transform of the instance placement to give absolute blockages."""
# angle = math.radians(float(self.rotate))
# mirr = 1
# if self.mirror=="R90":
# angle += math.radians(90.0)
# elif self.mirror=="R180":
# angle += math.radians(180.0)
# elif self.mirror=="R270":
# angle += math.radians(270.0)
# elif self.mirror=="MX":
# mirr = -1
# elif self.mirror=="MY":
# mirr = -1
# angle += math.radians(180.0)
# elif self.mirror=="XY":
# mirr = 1
# angle += math.radians(180.0)
def get_blockages(self, layer, top=False):
""" Retrieve rectangular blockages of all modules in this instance.
Apply the transform of the instance placement to give absolute blockages."""
angle = math.radians(float(self.rotate))
mirr = 1
if self.mirror=="R90":
angle += math.radians(90.0)
elif self.mirror=="R180":
angle += math.radians(180.0)
elif self.mirror=="R270":
angle += math.radians(270.0)
elif self.mirror=="MX":
mirr = -1
elif self.mirror=="MY":
mirr = -1
angle += math.radians(180.0)
elif self.mirror=="XY":
mirr = 1
angle += math.radians(180.0)
# if self.mod.is_library_cell:
# # For lib cells, block the whole thing except on metal3
# # since they shouldn't use metal3
# if layer==tech.layer["metal1"] or layer==tech.layer["metal2"]:
# return [self.transform_coords(self.mod.get_boundary(), self.offset, mirr, angle)]
# else:
# return []
# else:
if self.mod.is_library_cell:
# For lib cells, block the whole thing except on metal3
# since they shouldn't use metal3
if layer==tech.layer["metal1"] or layer==tech.layer["metal2"]:
return [self.transform_coords(self.mod.get_boundary(), self.offset, mirr, angle)]
else:
return []
else:
# blockages = self.mod.get_blockages(layer)
# new_blockages = []
# for b in blockages:
# new_blockages.append(self.transform_coords(b,self.offset, mirr, angle))
# return new_blockages
blockages = self.mod.get_blockages(layer)
new_blockages = []
for b in blockages:
new_blockages.append(self.transform_coords(b,self.offset, mirr, angle))
return new_blockages
def gds_write_file(self, new_layout):
"""Recursively writes all the sub-modules in this instance"""

View File

@ -280,18 +280,20 @@ class Gds2writer:
if(thisSref.transFlags!=""):
idBits=b'\x1A\x01'
mirrorFlag = int(thisSref.transFlags[0])<<15
# FIXME: For some reason, Calibre doesn't like when this flag is set
# but it will still pay attention to the rotate value!
#rotateFlag = int(thisSref.transFlags[2])<<1
# The rotate and magnify flags specify "absolute" rotate and magnify.
# It is unclear what that is (ignore all further rotates/mags in the
# hierarchy? But anyway, calibre doesn't support it.
rotateFlag=0
magnifyFlag = int(thisSref.transFlags[1])<<2
magnifyFlag = 0
#rotateFlag = int(thisSref.transFlags[2])<<1
#magnifyFlag = int(thisSref.transFlags[1])<<2
transFlags = struct.pack(">H",mirrorFlag|rotateFlag|magnifyFlag)
self.writeRecord(idBits+transFlags)
if(thisSref.transFlags[1]):
if(thisSref.magFactor!=""):
idBits=b'\x1B\x05'
magFactor=self.ibmDataFromIeeeDouble(thisSref.magFactor)
self.writeRecord(idBits+magFactor)
if(thisSref.transFlags[2]):
if(thisSref.rotateAngle!=""):
idBits=b'\x1C\x05'
rotateAngle=self.ibmDataFromIeeeDouble(thisSref.rotateAngle)
self.writeRecord(idBits+rotateAngle)
@ -330,15 +332,20 @@ class Gds2writer:
if(thisAref.transFlags):
idBits=b'\x1A\x01'
mirrorFlag = int(thisAref.transFlags[0])<<15
rotateFlag = int(thisAref.transFlags[2])<<1
magnifyFlag = int(thisAref.transFlags[1])<<2
# The rotate and magnify flags specify "absolute" rotate and magnify.
# It is unclear what that is (ignore all further rotates/mags in the
# hierarchy? But anyway, calibre doesn't support it.
rotateFlag=0
magnifyFlag = 0
#rotateFlag = int(thisAref.transFlags[2])<<1
#magnifyFlag = int(thisAref.transFlags[1])<<2
transFlags = struct.pack(">H",mirrorFlag|rotateFlag|magnifyFlag)
self.writeRecord(idBits+transFlags)
if(thisAref.transFlags[1]):
if(thisAref.magFactor!=""):
idBits=b'\x1B\x05'
magFactor=self.ibmDataFromIeeeDouble(thisAref.magFactor)
self.writeRecord(idBits+magFactor)
if(thisAref.transFlags[2]):
if(thisAref.rotateAngle!=""):
idBits=b'\x1C\x05'
rotateAngle=self.ibmDataFromIeeeDouble(thisAref.rotateAngle)
self.writeRecord(idBits+rotateAngle)
@ -377,15 +384,20 @@ class Gds2writer:
if(thisText.transFlags != ""):
idBits=b'\x1A\x01'
mirrorFlag = int(thisText.transFlags[0])<<15
rotateFlag = int(thisText.transFlags[2])<<1
magnifyFlag = int(thisText.transFlags[1])<<2
# The rotate and magnify flags specify "absolute" rotate and magnify.
# It is unclear what that is (ignore all further rotates/mags in the
# hierarchy? But anyway, calibre doesn't support it.
rotateFlag=0
magnifyFlag = 0
#rotateFlag = int(thisText.transFlags[2])<<1
#magnifyFlag = int(thisText.transFlags[1])<<2
transFlags = struct.pack(">H",mirrorFlag|rotateFlag|magnifyFlag)
self.writeRecord(idBits+transFlags)
if(thisText.transFlags[1]):
if(thisText.magFactor!=""):
idBits=b'\x1B\x05'
magFactor=self.ibmDataFromIeeeDouble(thisText.magFactor)
self.writeRecord(idBits+magFactor)
if(thisText.transFlags[2]):
if(thisText.rotateAngle!=""):
idBits=b'\x1C\x05'
rotateAngle=self.ibmDataFromIeeeDouble(thisText.rotateAngle)
self.writeRecord(idBits+rotateAngle)

View File

@ -328,16 +328,16 @@ class VlsiLayout:
if mirror=="R270":
rotate = 270.0
if rotate:
layoutToAddSref.transFlags[2] = 1
#layoutToAddSref.transFlags[2] = 1
layoutToAddSref.rotateAngle = rotate
if mirror == "x" or mirror == "MX":
layoutToAddSref.transFlags[0] = 1
if mirror == "y" or mirror == "MY": #NOTE: "MY" option will override specified rotate angle
layoutToAddSref.transFlags[0] = 1
layoutToAddSref.transFlags[2] = 1
#layoutToAddSref.transFlags[2] = 1
layoutToAddSref.rotateAngle = 180.0
if mirror == "xy" or mirror == "XY": #NOTE: "XY" option will override specified rotate angle
layoutToAddSref.transFlags[2] = 1
#layoutToAddSref.transFlags[2] = 1
layoutToAddSref.rotateAngle = 180.0
#add the sref to the root structure
@ -404,10 +404,10 @@ class VlsiLayout:
if(len(text)%2 == 1):
text = text + '\x00'
textToAdd.textString = text
textToAdd.transFlags[1] = 1
#textToAdd.transFlags[1] = 1
textToAdd.magFactor = magnification
if rotate:
textToAdd.transFlags[2] = 1
#textToAdd.transFlags[2] = 1
textToAdd.rotateAngle = rotate
#add the sref to the root structure
self.structures[self.rootStructureName].texts.append(textToAdd)