mirror of https://github.com/VLSIDA/OpenRAM.git
Make default no magnification to text. PEP8 Cleanup
This commit is contained in:
parent
9717794400
commit
0a9a946cd1
|
|
@ -1,4 +1,4 @@
|
||||||
import math
|
|
||||||
|
|
||||||
class GdsStructure:
|
class GdsStructure:
|
||||||
"""Class represent a GDS Structure Object"""
|
"""Class represent a GDS Structure Object"""
|
||||||
|
|
@ -15,6 +15,7 @@ class GdsStructure:
|
||||||
self.nodes=[]
|
self.nodes=[]
|
||||||
self.boxes=[]
|
self.boxes=[]
|
||||||
|
|
||||||
|
|
||||||
class GdsBoundary:
|
class GdsBoundary:
|
||||||
"""Class represent a GDS Boundary Object"""
|
"""Class represent a GDS Boundary Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -24,6 +25,7 @@ class GdsBoundary:
|
||||||
self.purposeLayer=0
|
self.purposeLayer=0
|
||||||
self.coordinates=""
|
self.coordinates=""
|
||||||
|
|
||||||
|
|
||||||
class GdsPath:
|
class GdsPath:
|
||||||
"""Class represent a GDS Path Object"""
|
"""Class represent a GDS Path Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -112,6 +114,7 @@ class GdsPath:
|
||||||
lastY = y
|
lastY = y
|
||||||
return boundaryEquivalent
|
return boundaryEquivalent
|
||||||
|
|
||||||
|
|
||||||
class GdsSref:
|
class GdsSref:
|
||||||
"""Class represent a GDS structure reference Object"""
|
"""Class represent a GDS structure reference Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -123,6 +126,7 @@ class GdsSref:
|
||||||
self.rotateAngle=""
|
self.rotateAngle=""
|
||||||
self.coordinates=""
|
self.coordinates=""
|
||||||
|
|
||||||
|
|
||||||
class GdsAref:
|
class GdsAref:
|
||||||
"""Class represent a GDS array reference Object"""
|
"""Class represent a GDS array reference Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -134,6 +138,7 @@ class GdsAref:
|
||||||
self.rotateAngle=""
|
self.rotateAngle=""
|
||||||
self.coordinates=""
|
self.coordinates=""
|
||||||
|
|
||||||
|
|
||||||
class GdsText:
|
class GdsText:
|
||||||
"""Class represent a GDS text Object"""
|
"""Class represent a GDS text Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -150,6 +155,7 @@ class GdsText:
|
||||||
self.coordinates=""
|
self.coordinates=""
|
||||||
self.textString = ""
|
self.textString = ""
|
||||||
|
|
||||||
|
|
||||||
class GdsNode:
|
class GdsNode:
|
||||||
"""Class represent a GDS Node Object"""
|
"""Class represent a GDS Node Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -159,6 +165,7 @@ class GdsNode:
|
||||||
self.nodeType=""
|
self.nodeType=""
|
||||||
self.coordinates=""
|
self.coordinates=""
|
||||||
|
|
||||||
|
|
||||||
class GdsBox:
|
class GdsBox:
|
||||||
"""Class represent a GDS Box Object"""
|
"""Class represent a GDS Box Object"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
from .gdsPrimitives import *
|
from .gdsPrimitives import *
|
||||||
from datetime import *
|
from datetime import *
|
||||||
#from mpmath import matrix
|
|
||||||
#from numpy import matrix
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
#import gdsPrimitives
|
import math
|
||||||
import debug
|
import debug
|
||||||
|
|
||||||
|
|
||||||
class VlsiLayout:
|
class VlsiLayout:
|
||||||
"""Class represent a hierarchical layout"""
|
"""Class represent a hierarchical layout"""
|
||||||
|
|
||||||
|
|
@ -53,10 +52,11 @@ class VlsiLayout:
|
||||||
self.info['libraryName']=libraryName
|
self.info['libraryName']=libraryName
|
||||||
self.info['gdsVersion']=gdsVersion
|
self.info['gdsVersion']=gdsVersion
|
||||||
|
|
||||||
self.xyTree = [] #This will contain a list of all structure names
|
# This will contain a list of all structure names
|
||||||
# expanded to include srefs / arefs separately.
|
# expanded to include srefs / arefs separately.
|
||||||
# each structure will have an X,Y,offset, and rotate associated
|
# each structure will have an X,Y,offset, and rotate associated
|
||||||
# with it. Populate via traverseTheHierarchy method.
|
# with it. Populate via traverseTheHierarchy method.
|
||||||
|
self.xyTree = []
|
||||||
|
|
||||||
# temp variables used in delegate functions
|
# temp variables used in delegate functions
|
||||||
self.tempCoordinates=None
|
self.tempCoordinates=None
|
||||||
|
|
@ -108,8 +108,6 @@ class VlsiLayout:
|
||||||
self.structures[newName] = GdsStructure()
|
self.structures[newName] = GdsStructure()
|
||||||
self.structures[newName].name = newName
|
self.structures[newName].name = newName
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.rootStructureName = newName
|
self.rootStructureName = newName
|
||||||
|
|
||||||
self.rootStructureName=newName
|
self.rootStructureName=newName
|
||||||
|
|
@ -155,7 +153,6 @@ class VlsiLayout:
|
||||||
debug.check(len(structureNames)==1,"Multiple possible root structures in the layout: {}".format(str(structureNames)))
|
debug.check(len(structureNames)==1,"Multiple possible root structures in the layout: {}".format(str(structureNames)))
|
||||||
self.rootStructureName = structureNames[0]
|
self.rootStructureName = structureNames[0]
|
||||||
|
|
||||||
|
|
||||||
def traverseTheHierarchy(self, startingStructureName=None, delegateFunction=None,
|
def traverseTheHierarchy(self, startingStructureName=None, delegateFunction=None,
|
||||||
transformPath=[], rotateAngle=0, transFlags=[0, 0, 0], coordinates=(0, 0)):
|
transformPath=[], rotateAngle=0, transFlags=[0, 0, 0], coordinates=(0, 0)):
|
||||||
# since this is a recursive function, must deal with the default
|
# since this is a recursive function, must deal with the default
|
||||||
|
|
@ -175,14 +172,18 @@ class VlsiLayout:
|
||||||
# set up the translation matrix
|
# set up the translation matrix
|
||||||
translateX = float(coordinates[0])
|
translateX = float(coordinates[0])
|
||||||
translateY = float(coordinates[1])
|
translateY = float(coordinates[1])
|
||||||
mTranslate = np.array([[1.0,0.0,translateX],[0.0,1.0,translateY],[0.0,0.0,1.0]])
|
mTranslate = np.array([[1.0, 0.0, translateX],
|
||||||
|
[0.0, 1.0, translateY],
|
||||||
|
[0.0, 0.0, 1.0]])
|
||||||
# set up the scale matrix (handles mirror X)
|
# set up the scale matrix (handles mirror X)
|
||||||
scaleX = 1.0
|
scaleX = 1.0
|
||||||
if (transFlags[0]):
|
if (transFlags[0]):
|
||||||
scaleY = -1.0
|
scaleY = -1.0
|
||||||
else:
|
else:
|
||||||
scaleY = 1.0
|
scaleY = 1.0
|
||||||
mScale = np.array([[scaleX,0.0,0.0],[0.0,scaleY,0.0],[0.0,0.0,1.0]])
|
mScale = np.array([[scaleX, 0.0, 0.0],
|
||||||
|
[0.0, scaleY, 0.0],
|
||||||
|
[0.0, 0.0, 1.0]])
|
||||||
# we need to keep track of all transforms in the hierarchy
|
# we need to keep track of all transforms in the hierarchy
|
||||||
# when we add an element to the xy tree, we apply all transforms from the bottom up
|
# when we add an element to the xy tree, we apply all transforms from the bottom up
|
||||||
transformPath.append((mRotate,mScale,mTranslate))
|
transformPath.append((mRotate,mScale,mTranslate))
|
||||||
|
|
@ -218,7 +219,6 @@ class VlsiLayout:
|
||||||
for layerNumber in self.layerNumbersInUse:
|
for layerNumber in self.layerNumbersInUse:
|
||||||
self.processLabelPins((layerNumber, None))
|
self.processLabelPins((layerNumber, None))
|
||||||
|
|
||||||
|
|
||||||
def populateCoordinateMap(self):
|
def populateCoordinateMap(self):
|
||||||
def addToXyTree(startingStructureName = None,transformPath = None):
|
def addToXyTree(startingStructureName = None,transformPath = None):
|
||||||
uVector = np.array([[1.0],[0.0],[0.0]]) #start with normal basis vectors
|
uVector = np.array([[1.0],[0.0],[0.0]]) #start with normal basis vectors
|
||||||
|
|
@ -281,8 +281,6 @@ class VlsiLayout:
|
||||||
self.newLayout(newRoot)
|
self.newLayout(newRoot)
|
||||||
self.rootStructureName = newRoot
|
self.rootStructureName = newRoot
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addInstance(self,layoutToAdd,nameOfLayout=0,offsetInMicrons=(0,0),mirror=None,rotate=None):
|
def addInstance(self,layoutToAdd,nameOfLayout=0,offsetInMicrons=(0,0),mirror=None,rotate=None):
|
||||||
"""
|
"""
|
||||||
Method to insert one layout into another at a particular offset.
|
Method to insert one layout into another at a particular offset.
|
||||||
|
|
@ -406,7 +404,7 @@ class VlsiLayout:
|
||||||
#add the sref to the root structure
|
#add the sref to the root structure
|
||||||
self.structures[self.rootStructureName].paths.append(pathToAdd)
|
self.structures[self.rootStructureName].paths.append(pathToAdd)
|
||||||
|
|
||||||
def addText(self, text, layerNumber=0, purposeNumber=0, offsetInMicrons=(0,0), magnification=0.1, rotate = None):
|
def addText(self, text, layerNumber=0, purposeNumber=0, offsetInMicrons=(0,0), magnification=None, rotate=None):
|
||||||
offsetInLayoutUnits = (self.userUnits(offsetInMicrons[0]),self.userUnits(offsetInMicrons[1]))
|
offsetInLayoutUnits = (self.userUnits(offsetInMicrons[0]),self.userUnits(offsetInMicrons[1]))
|
||||||
textToAdd = GdsText()
|
textToAdd = GdsText()
|
||||||
textToAdd.drawingLayer = layerNumber
|
textToAdd.drawingLayer = layerNumber
|
||||||
|
|
@ -415,6 +413,7 @@ class VlsiLayout:
|
||||||
textToAdd.transFlags = [0,0,0]
|
textToAdd.transFlags = [0,0,0]
|
||||||
textToAdd.textString = self.padText(text)
|
textToAdd.textString = self.padText(text)
|
||||||
#textToAdd.transFlags[1] = 1
|
#textToAdd.transFlags[1] = 1
|
||||||
|
if magnification:
|
||||||
textToAdd.magFactor = magnification
|
textToAdd.magFactor = magnification
|
||||||
if rotate:
|
if rotate:
|
||||||
#textToAdd.transFlags[2] = 1
|
#textToAdd.transFlags[2] = 1
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from gdsMill import gdsMill
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Usage: {0} in.gds out.gds".format(sys.argv[0]))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
in_gds_file = sys.argv[1]
|
||||||
|
out_gds_file = sys.argv[2]
|
||||||
|
layout = gdsMill.VlsiLayout()
|
||||||
|
reader = gdsMill.Gds2reader(layout)
|
||||||
|
reader.loadFromFile(in_gds_file)
|
||||||
|
|
||||||
|
|
||||||
|
struct = layout.structures[layout.rootStructureName]
|
||||||
|
# Do something to the structure
|
||||||
|
for text in struct.texts:
|
||||||
|
print(text.textString)
|
||||||
|
text.magFactor=""
|
||||||
|
|
||||||
|
writer = gdsMill.Gds2writer(layout)
|
||||||
|
writer.writeToFile(out_gds_file)
|
||||||
|
|
||||||
Loading…
Reference in New Issue