From 7bae37c026a0484c7d35226b34a179a429956267 Mon Sep 17 00:00:00 2001 From: Bin wu Date: Thu, 10 Nov 2016 17:28:06 -0800 Subject: [PATCH] apply vector to hierchay_layout and geometry and contact --- compiler/contact.py | 4 ++-- compiler/geometry.py | 7 ++++--- compiler/hierarchy_layout.py | 23 +++++++++-------------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/compiler/contact.py b/compiler/contact.py index 4553ff91..24ae12b5 100644 --- a/compiler/contact.py +++ b/compiler/contact.py @@ -40,8 +40,8 @@ class contact(design.design): self.offset_attributes(coordinate) self.translate(coordinate) - self.height = max(obj.offset[1] + obj.height for obj in self.objs) - self.width = max(obj.offset[0] + obj.width for obj in self.objs) + self.height = max(obj.offset.y + obj.height for obj in self.objs) + self.width = max(obj.offset.x + obj.width for obj in self.objs) def setup_layers(self): (first_layer, via_layer, second_layer) = self.layer_stack diff --git a/compiler/geometry.py b/compiler/geometry.py index 1585e4a4..14eedade 100644 --- a/compiler/geometry.py +++ b/compiler/geometry.py @@ -5,6 +5,7 @@ This provides a set of useful generic types for the gdsMill interface. import tech import debug from utils import snap_to_grid +from vector import vector class geometry: """ @@ -37,7 +38,7 @@ class instance(geometry): self.mod = mod self.gds = mod.gds self.rotate = rotate - self.offset = snap_to_grid(offset) + self.offset = vector(snap_to_grid(offset)) self.mirror = mirror @@ -104,7 +105,7 @@ class label(geometry): self.name = "label" self.text = text self.layerNumber = layerNumber - self.offset = snap_to_grid(offset) + self.offset = vector(snap_to_grid(offset)) self.zoom = zoom self.size = 0 @@ -134,7 +135,7 @@ class rectangle(geometry): geometry.__init__(self) self.name = "rect" self.layerNumber = layerNumber - self.offset = snap_to_grid(offset) + self.offset = vector(snap_to_grid(offset)) self.size = snap_to_grid([width, height]) self.width = self.size[0] self.height = self.size[1] diff --git a/compiler/hierarchy_layout.py b/compiler/hierarchy_layout.py index 420df8cd..de939792 100644 --- a/compiler/hierarchy_layout.py +++ b/compiler/hierarchy_layout.py @@ -47,13 +47,13 @@ class layout: #***1,000,000 number is used to avoid empty sequences errors*** # FIXME Is this hard coded value ok?? try: - lowestx1 = min(rect.offset[0] for rect in self.objs) - lowesty1 = min(rect.offset[1] for rect in self.objs) + lowestx1 = min(rect.offset.x for rect in self.objs) + lowesty1 = min(rect.offset.y for rect in self.objs) except: [lowestx1, lowesty1] = [1000000.0, 1000000.0] try: - lowestx2 = min(inst.offset[0] for inst in self.insts) - lowesty2 = min(inst.offset[1] for inst in self.insts) + lowestx2 = min(inst.offset.x for inst in self.insts) + lowesty2 = min(inst.offset.y for inst in self.insts) except: [lowestx2, lowesty2] = [1000000.0, 1000000.0] return vector(min(lowestx1, lowestx2), min(lowesty1, lowesty2)) @@ -77,21 +77,18 @@ class layout: for i in range(len(attr_val)): # each unit in the list is a list coordinates if isinstance(attr_val[i], (list,vector)): - attr_val[i] = vector([attr_val[i][0] - coordinate.x, - attr_val[i][1] - coordinate.y]) + attr_val[i] = vector(attr_val[i] - coordinate) # the list itself is a coordinate else: if len(attr_val)!=2: continue for val in attr_val: if not isinstance(val, (int, long, float)): continue - setattr(self,attr_key, vector([attr_val[0] - coordinate.x, - attr_val[1] - coordinate.y])) + setattr(self,attr_key, vector(attr_val - coordinate)) break # if is a vector coordinate if isinstance(attr_val, vector): - setattr(self, attr_key, vector(attr_val[0] - coordinate.x, - attr_val[1] - coordinate.y)) + setattr(self, attr_key, vector(attr_val - coordinate)) @@ -99,11 +96,9 @@ class layout: """Translates all 2d cartesian coordinates in a layout given the (x,y) offset""" for obj in self.objs: - obj.offset = snap_to_grid([obj.offset[0] - coordinate.x, - obj.offset[1] - coordinate.y]) + obj.offset = vector(snap_to_grid(obj.offset - coordinate)) for inst in self.insts: - inst.offset = snap_to_grid([inst.offset[0] - coordinate.x, - inst.offset[1] - coordinate.y]) + inst.offset = vector(snap_to_grid(inst.offset - coordinate)) # 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):