From 74c3de2812587526f21629f903bed377499ec8bd Mon Sep 17 00:00:00 2001 From: Matt Guthaus Date: Fri, 2 Nov 2018 14:57:40 -0700 Subject: [PATCH] Remove diagonal routing bug. Cleanup. --- compiler/base/route.py | 8 ++----- compiler/router/direction.py | 11 +++++---- compiler/router/grid_cell.py | 9 ++++---- compiler/router/grid_path.py | 6 ++--- compiler/router/router.py | 45 +++++++++++++++++++++--------------- 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/compiler/base/route.py b/compiler/base/route.py index 0b596a1a..09925e07 100644 --- a/compiler/base/route.py +++ b/compiler/base/route.py @@ -62,14 +62,10 @@ class route(design): plist = list(pairwise(self.path)) for p0,p1 in plist: if p0.z != p1.z: # via - # offset if not rotated - #via_offset = vector(p0.x+0.5*self.c.width,p0.y+0.5*self.c.height) - # offset if rotated - via_offset = vector(p0.x+0.5*self.c.height,p0.y-0.5*self.c.width) via_size = [self.num_vias]*2 - self.obj.add_via(self.layer_stack,via_offset,size=via_size,rotate=90) + self.obj.add_via_center(self.layer_stack,vector(p0.x,p0.y),size=via_size,rotate=90) elif p0.x != p1.x and p0.y != p1.y: # diagonal! - debug.error("Non-changing direction! {}".format(self.path)) + debug.error("Diagonal route! {}".format(self.path),-3) else: # this will draw an extra corner at the end but that is ok self.draw_corner_wire(p1) diff --git a/compiler/router/direction.py b/compiler/router/direction.py index 52d4207f..8a6681a7 100644 --- a/compiler/router/direction.py +++ b/compiler/router/direction.py @@ -43,11 +43,14 @@ class direction(Enum): return offset - def cardinal_directions(): - return [direction.NORTH, direction.EAST, direction.SOUTH, direction.WEST] + def cardinal_directions(up_down_too=False): + temp_dirs = [direction.NORTH, direction.EAST, direction.SOUTH, direction.WEST] + if up_down_too: + temp_dirs.extend([direction.UP, direction.DOWN]) + return temp_dirs - def cardinal_offsets(): - return [direction.get_offset(d) for d in direction.cardinal_directions()] + def cardinal_offsets(up_down_too=False): + return [direction.get_offset(d) for d in direction.cardinal_directions(up_down_too)] def all_directions(): return [direction.NORTH, direction.EAST, direction.SOUTH, direction.WEST, diff --git a/compiler/router/grid_cell.py b/compiler/router/grid_cell.py index 3f145ef4..cb78116c 100644 --- a/compiler/router/grid_cell.py +++ b/compiler/router/grid_cell.py @@ -22,6 +22,11 @@ class grid_cell: self.source=False self.target=False + def get_cost(self): + # We can display the cost of the frontier + if self.min_cost > 0: + return self.min_cost + def get_type(self): if self.blocked: @@ -36,8 +41,4 @@ class grid_cell: if self.path: return "P" - # We can display the cost of the frontier - if self.min_cost > 0: - return self.min_cost - return None diff --git a/compiler/router/grid_path.py b/compiler/router/grid_path.py index 250e485d..cbe739ef 100644 --- a/compiler/router/grid_path.py +++ b/compiler/router/grid_path.py @@ -150,7 +150,7 @@ class grid_path: return cost - def expand_dirs(self,up_down_too=True): + def expand_dirs(self): """ Expand from the end in each of the four cardinal directions plus up or down but not expanding to blocked cells. Expands in all @@ -162,9 +162,7 @@ class grid_path: """ neighbors = [] - for d in list(direction): - if not up_down_too and (d==direction.UP or d==direction.DOWN): - continue + for d in direction.cardinal_directions(True): n = self.neighbor(d) if n: neighbors.append(n) diff --git a/compiler/router/router.py b/compiler/router/router.py index 2432e8c2..b9aa2518 100644 --- a/compiler/router/router.py +++ b/compiler/router/router.py @@ -337,7 +337,7 @@ class router(router_tech): # FIXME: These duplicate a bit of work # These are the paths that have already been routed. - self.set_path_blockages() + self.set_blockages(self.path_blockages) # Don't mark the other components as targets since we want to route # directly to a rail, but unblock all the source components so we can @@ -404,13 +404,6 @@ class router(router_tech): """ Flag the blockages in the grid """ self.rg.set_blocked(blockages, value) - def set_path_blockages(self,value=True): - """ Flag the paths as blockages """ - # These are the paths that have already been routed. - for path_set in self.path_blockages: - for c in path_set: - self.rg.set_blocked(c,value) - def get_blockage_tracks(self, ll, ur, z): debug.info(3,"Converting blockage ll={0} ur={1} z={2}".format(str(ll),str(ur),z)) @@ -924,11 +917,13 @@ class router(router_tech): if path: debug.info(2,"Found path: cost={0} ".format(cost)) debug.info(3,str(path)) + self.paths.append(path) + self.add_route(path) + path_set = grid_utils.flatten_set(path) inflated_path = grid_utils.inflate_set(path_set,self.supply_rail_space_width) self.path_blockages.append(inflated_path) - self.add_route(path) else: self.write_debug_gds("failed_route.gds") # clean up so we can try a reroute @@ -985,16 +980,30 @@ class router(router_tech): # midpoint offset off=vector((shape[1].x+shape[0].x)/2, (shape[1].y+shape[0].y)/2) - if g[2]==1: - # Upper layer is upper right label - type_off=off+partial_track - else: - # Lower layer is lower left label - type_off=off-partial_track if t!=None: + if g[2]==1: + # Upper layer is upper right label + type_off=off+partial_track + else: + # Lower layer is lower left label + type_off=off-partial_track self.cell.add_label(text=str(t), layer="text", offset=type_off) + + t=self.rg.map[g].get_cost() + partial_track=vector(self.track_width/6.0,0) + if t!=None: + if g[2]==1: + # Upper layer is right label + type_off=off+partial_track + else: + # Lower layer is left label + type_off=off-partial_track + self.cell.add_label(text=str(t), + layer="text", + offset=type_off) + self.cell.add_label(text="{0},{1}".format(g[0],g[1]), layer="text", offset=shape[0], @@ -1008,9 +1017,9 @@ class router(router_tech): """ debug.info(0,"Adding router info") - show_blockages = True - show_blockage_grids = True - show_enclosures = True + show_blockages = False + show_blockage_grids = False + show_enclosures = False show_all_grids = True if show_all_grids: