Merge remote-tracking branch 'bin/move_snap_to_vector_fix1'

This commit is contained in:
Matt Guthaus 2016-11-23 17:19:55 -08:00
commit 9356d1771f
5 changed files with 27 additions and 33 deletions

View File

@ -1,10 +1,8 @@
""" """
This provides a set of useful generic types for the gdsMill interface. This provides a set of useful generic types for the gdsMill interface.
""" """
import tech import tech
import debug import debug
from utils import snap_to_grid
from vector import vector from vector import vector
class geometry: class geometry:
@ -38,7 +36,7 @@ class instance(geometry):
self.mod = mod self.mod = mod
self.gds = mod.gds self.gds = mod.gds
self.rotate = rotate self.rotate = rotate
self.offset = vector(snap_to_grid(offset)) self.offset = vector(offset).snap_to_grid()
self.mirror = mirror self.mirror = mirror
@ -72,7 +70,7 @@ class path(geometry):
self.name = "path" self.name = "path"
self.layerNumber = layerNumber self.layerNumber = layerNumber
self.coordinates = map(lambda x: [x[0], x[1]], coordinates) self.coordinates = map(lambda x: [x[0], x[1]], coordinates)
self.coordinates = snap_to_grid(self.coordinates) self.coordinates = vector(self.coordinates).snap_to_grid()
self.path_width = path_width self.path_width = path_width
# FIXME figure out the width/height. This type of path is not # FIXME figure out the width/height. This type of path is not
@ -105,7 +103,7 @@ class label(geometry):
self.name = "label" self.name = "label"
self.text = text self.text = text
self.layerNumber = layerNumber self.layerNumber = layerNumber
self.offset = vector(snap_to_grid(offset)) self.offset = vector(offset).snap_to_grid()
self.zoom = zoom self.zoom = zoom
self.size = 0 self.size = 0
@ -135,19 +133,18 @@ class rectangle(geometry):
geometry.__init__(self) geometry.__init__(self)
self.name = "rect" self.name = "rect"
self.layerNumber = layerNumber self.layerNumber = layerNumber
self.offset = vector(snap_to_grid(offset)) self.offset = vector(offset).snap_to_grid()
self.size = snap_to_grid([width, height]) self.size = vector(width, height).snap_to_grid()
self.width = self.size[0] self.width = self.size.x
self.height = self.size[1] self.height = self.size.y
def gds_write_file(self, newLayout): def gds_write_file(self, newLayout):
"""Writes the rectangular shape to GDS""" """Writes the rectangular shape to GDS"""
snapped_offset=snap_to_grid(self.offset)
debug.info(3, "writing rectangle (" + str(self.layerNumber) + "):" debug.info(3, "writing rectangle (" + str(self.layerNumber) + "):"
+ str(self.width) + "x" + str(self.height) + " @ " + str(snapped_offset)) + str(self.width) + "x" + str(self.height) + " @ " + str(self.offset))
newLayout.addBox(layerNumber=self.layerNumber, newLayout.addBox(layerNumber=self.layerNumber,
purposeNumber=0, purposeNumber=0,
offsetInMicrons=snapped_offset, offsetInMicrons=self.offset,
width=self.width, width=self.width,
height=self.height, height=self.height,
center=False) center=False)

View File

@ -5,7 +5,6 @@ import debug
from tech import drc, GDS from tech import drc, GDS
from tech import layer as techlayer from tech import layer as techlayer
import os import os
from utils import snap_to_grid
from vector import vector from vector import vector
class layout: class layout:
@ -96,9 +95,9 @@ class layout:
"""Translates all 2d cartesian coordinates in a layout given """Translates all 2d cartesian coordinates in a layout given
the (x,y) offset""" the (x,y) offset"""
for obj in self.objs: for obj in self.objs:
obj.offset = vector(snap_to_grid(obj.offset - coordinate)) obj.offset = vector(obj.offset - coordinate)
for inst in self.insts: for inst in self.insts:
inst.offset = vector(snap_to_grid(inst.offset - coordinate)) inst.offset = vector(inst.offset - coordinate)
# FIXME: Make name optional and pick a random one if not specified # FIXME: Make name optional and pick a random one if not specified
def add_inst(self, name, mod, offset=[0,0], mirror="R0",rotate=0): def add_inst(self, name, mod, offset=[0,0], mirror="R0",rotate=0):

View File

@ -3,7 +3,6 @@ from tech import layer as techlayer
import debug import debug
import design import design
from vector import vector from vector import vector
from utils import snap_to_grid
class path(design.design): class path(design.design):
""" """

View File

@ -5,27 +5,10 @@ import globals
OPTS = globals.OPTS OPTS = globals.OPTS
def snap_to_grid(offset):
"""
Changes the coodrinate to match the grid settings
"""
grid = tech.drc["grid"]
x = offset[0]
y = offset[1]
# this gets the nearest integer value
xgrid = int(round(round((x / grid), 2), 0))
ygrid = int(round(round((y / grid), 2), 0))
xoff = xgrid * grid
yoff = ygrid * grid
out_offset = [xoff, yoff]
return out_offset
def gdsPinToOffset(gdsPin): def gdsPinToOffset(gdsPin):
boundary = gdsPin[2] boundary = gdsPin[2]
return [0.5 * (boundary[0] + boundary[2]), 0.5 * (boundary[1] + boundary[3])] return [0.5 * (boundary[0] + boundary[2]), 0.5 * (boundary[1] + boundary[3])]
def auto_measure_libcell(pin_list, name, units, layer): def auto_measure_libcell(pin_list, name, units, layer):
cell_gds = OPTS.openram_tech + "gds_lib/" + str(name) + ".gds" cell_gds = OPTS.openram_tech + "gds_lib/" + str(name) + ".gds"
cell_vlsi = gdsMill.VlsiLayout(units=units) cell_vlsi = gdsMill.VlsiLayout(units=units)

View File

@ -1,4 +1,5 @@
import debug import debug
import tech
class vector(): class vector():
@ -82,6 +83,21 @@ class vector():
""" """
return vector(other[0]- self.x, other[1] - self.y) return vector(other[0]- self.x, other[1] - self.y)
def snap_to_grid(self):
self.x = self.snap_offset_to_grid(self.x)
self.y = self.snap_offset_to_grid(self.y)
return self
def snap_offset_to_grid(self, offset):
"""
Changes the coodrinate to match the grid settings
"""
grid = tech.drc["grid"]
# this gets the nearest integer value
off_in_grid = int(round(round((offset / grid), 2), 0))
offset = off_in_grid * grid
return offset
def rotate(self): def rotate(self):
""" pass a copy of rotated vector, without altering the vector! """ """ pass a copy of rotated vector, without altering the vector! """
return vector(self.y,self.x) return vector(self.y,self.x)