diff --git a/compiler/router/grid.py b/compiler/router/grid.py index 26bc7e88..8f3e54cd 100644 --- a/compiler/router/grid.py +++ b/compiler/router/grid.py @@ -81,7 +81,7 @@ class grid: getattr (self, name).append(vector3d(x,y,z)) def add_blockage(self,ll,ur,z): - debug.info(2,"Adding blockage ll={0} ur={1} z={2}".format(str(ll),str(ur),z)) + debug.info(3,"Adding blockage ll={0} ur={1} z={2}".format(str(ll),str(ur),z)) self.set_property(ll,ur,z,"blocked") def set_source(self,ll,ur,z): diff --git a/compiler/router/router.py b/compiler/router/router.py index ee5f3041..62ce25cd 100644 --- a/compiler/router/router.py +++ b/compiler/router/router.py @@ -71,7 +71,7 @@ class router: """ Create a routing grid that spans given area. Wires cannot exist outside region. """ # We will add a halo around the boundary # of this many tracks - track_halo = 3 + track_halo = 5 # We will offset so ll is at (-track_halo*track_width,-track_halo*track_width) track_width_offset = vector([track_halo*self.track_width]*2) self.offset = self.ll + track_width_offset @@ -81,12 +81,12 @@ class router: debug.info(1,"Size: {0} x {1}".format(width,height)) # pad the tracks on each side by the halo as well - self.width_in_tracks = int(math.ceil(width/self.track_width)) + 2*track_halo - self.height_in_tracks = int(math.ceil(height/self.track_width)) + 2*track_halo + self.width_in_tracks = int(math.ceil(width/self.track_width)) + 2*track_halo + 1 + self.height_in_tracks = int(math.ceil(height/self.track_width)) + 2*track_halo + 1 debug.info(1,"Size (in tracks): {0} x {1}".format(self.width_in_tracks, self.height_in_tracks)) - self.rg = grid.grid(self.width_in_tracks,self.height_in_tracks) + self.rg = grid.grid(self.height_in_tracks,self.width_in_tracks) def find_pin(self,pin): @@ -97,7 +97,7 @@ class router: self.pin_names.append(pin_name) for pin_shape in pin_shapes: - debug.info(3,"Find pin {0} layer {1} shape {2}".format(pin_name,str(pin_layer),str(pin_shape))) + debug.info(2,"Find pin {0} layer {1} shape {2}".format(pin_name,str(pin_layer),str(pin_shape))) # repack the shape as a pair of vectors rather than four values shape=[vector(pin_shape[0],pin_shape[1]),vector(pin_shape[2],pin_shape[3])] new_shape = self.convert_shape_to_tracks(shape,round_bigger=False) @@ -140,8 +140,13 @@ class router: debug.info(1,str(contracted_path)) # convert the path back to absolute units from tracks abs_path = map(self.convert_point_to_units,contracted_path) - debug.info(1,str(abs_path)) - return abs_path + debug.info(1,str(abs_path)) + + # Make sure there's a pin enclosure on the source and dest + src_shape = self.convert_track_to_shape(contracted_path[0]) + dest_shape = self.convert_track_to_shape(contracted_path[-1]) + + return (src_shape,abs_path,dest_shape) def create_steiner_routes(self,pins): """Find a set of steiner points and then return the list of @@ -247,8 +252,6 @@ class router: [ll,ur]=self.convert_shape_to_tracks(shape) zlayer = 0 if boundary.drawingLayer==self.horiz_layer_number else 1 self.rg.add_blockage(ll,ur,zlayer) - else: - debug.info(2,"Skip: "+str(pin_shape_tracks)) # recurse given the mirror, angle, etc. @@ -316,7 +319,21 @@ class router: ll.y=0 return [ll,ur] - + + + def convert_track_to_shape(self,tracks): + """ + Convert a set of track units into a rectangle shape. + """ + + # to scale coordinates to tracks + x = tracks.x*self.track_width - 0.5*self.track_width + y = tracks.y*self.track_width - 0.5*self.track_width + # offset lowest corner object to to (-track halo,-track halo) + ll = snap_to_grid(vector(x,y)-self.offset) + ur = ll + vector(self.track_width,self.track_width) + + return [ll,ur] # FIXME: This should be replaced with vector.snap_to_grid at some point diff --git a/compiler/router/tests/01_no_blockages_test.py b/compiler/router/tests/01_no_blockages_test.py index 99a45645..7d28ac03 100644 --- a/compiler/router/tests/01_no_blockages_test.py +++ b/compiler/router/tests/01_no_blockages_test.py @@ -51,8 +51,16 @@ class no_blockages_test(unittest.TestCase): layer_stack =("metal1","via1","metal2") path=r.route(layer_stack,src="A",dest="B") #r.rg.view() - + self.add_rect(layer=layer_stack[0], + offset=src_rect[0], + width=src_rect[1].x-src_rect[0].x, + height=src_rect[1].y-src_rect[0].y) self.add_wire(layer_stack,path) + self.add_rect(layer=layer_stack[0], + offset=dest_rect[0], + width=dest_rect[1].x-dest_rect[0].x, + height=dest_rect[1].y-dest_rect[0].y) + r = routing("test1", "AB_no_blockages") diff --git a/compiler/router/tests/02_blockages_test.py b/compiler/router/tests/02_blockages_test.py index 2b8226d2..e19f774e 100644 --- a/compiler/router/tests/02_blockages_test.py +++ b/compiler/router/tests/02_blockages_test.py @@ -49,10 +49,18 @@ class no_blockages_test(unittest.TestCase): self.gdsname = "{0}/{1}.gds".format(os.path.dirname(os.path.realpath(__file__)),gdsname) r=router.router(self.gdsname) layer_stack =("metal1","via1","metal2") - path=r.route(layer_stack,src="A",dest="B") + (src_rect,path,dest_rect)=r.route(layer_stack,src="A",dest="B") #r.rg.view() - + self.add_rect(layer=layer_stack[0], + offset=src_rect[0], + width=src_rect[1].x-src_rect[0].x, + height=src_rect[1].y-src_rect[0].y) self.add_wire(layer_stack,path) + self.add_rect(layer=layer_stack[0], + offset=dest_rect[0], + width=dest_rect[1].x-dest_rect[0].x, + height=dest_rect[1].y-dest_rect[0].y) + r = routing("test1", "AB_blockages") diff --git a/compiler/router/tests/03_same_layer_pins_test.py b/compiler/router/tests/03_same_layer_pins_test.py index 808b9af6..04059efb 100644 --- a/compiler/router/tests/03_same_layer_pins_test.py +++ b/compiler/router/tests/03_same_layer_pins_test.py @@ -51,8 +51,16 @@ class no_blockages_test(unittest.TestCase): layer_stack =("metal1","via1","metal2") path=r.route(layer_stack,src="A",dest="B") #r.rg.view() - + self.add_rect(layer=layer_stack[0], + offset=src_rect[0], + width=src_rect[1].x-src_rect[0].x, + height=src_rect[1].y-src_rect[0].y) self.add_wire(layer_stack,path) + self.add_rect(layer=layer_stack[0], + offset=dest_rect[0], + width=dest_rect[1].x-dest_rect[0].x, + height=dest_rect[1].y-dest_rect[0].y) + r = routing("test1", "AB_same_layer_pins") diff --git a/compiler/router/tests/04_diff_layer_pins_test.py b/compiler/router/tests/04_diff_layer_pins_test.py index c7ac7dc4..f9214f5d 100644 --- a/compiler/router/tests/04_diff_layer_pins_test.py +++ b/compiler/router/tests/04_diff_layer_pins_test.py @@ -51,7 +51,16 @@ class no_blockages_test(unittest.TestCase): layer_stack =("metal1","via1","metal2") path=r.route(layer_stack,src="A",dest="B") + self.add_rect(layer=layer_stack[0], + offset=src_rect[0], + width=src_rect[1].x-src_rect[0].x, + height=src_rect[1].y-src_rect[0].y) self.add_wire(layer_stack,path) + self.add_rect(layer=layer_stack[0], + offset=dest_rect[0], + width=dest_rect[1].x-dest_rect[0].x, + height=dest_rect[1].y-dest_rect[0].y) +