From 141a4e3380feb1e499cd0978cf72f2b162e9994c Mon Sep 17 00:00:00 2001 From: Eren Dogan Date: Sun, 27 Aug 2023 15:42:09 -0700 Subject: [PATCH] Don't scale the routing region if no path is found --- compiler/router/graph.py | 6 +--- compiler/router/graph_shape.py | 11 ------ compiler/router/signal_escape_router.py | 46 +++++++++---------------- compiler/router/supply_router.py | 44 ++++++++--------------- 4 files changed, 32 insertions(+), 75 deletions(-) diff --git a/compiler/router/graph.py b/compiler/router/graph.py index 132681c9..68454937 100644 --- a/compiler/router/graph.py +++ b/compiler/router/graph.py @@ -184,7 +184,7 @@ class graph: return False - def create_graph(self, source, target, scale=1): + def create_graph(self, source, target): """ Create the graph to run routing on later. """ debug.info(2, "Creating the graph for source '{}' and target'{}'.".format(source, target)) @@ -195,7 +195,6 @@ class graph: # Find the region to be routed and only include objects inside that region region = deepcopy(source) region.bbox([target]) - region.multiply(scale) region = region.inflated_pin(spacing=self.router.track_space) debug.info(3, "Routing region is {}".format(region.rect)) @@ -221,9 +220,6 @@ class graph: debug.info(3, "Number of vias detected in the routing region: {}".format(len(self.graph_vias))) debug.info(3, "Number of nodes in the routing graph: {}".format(len(self.nodes))) - # Return the region to scale later if no path is found - return region.rect - def find_graph_blockages(self, region): """ Find blockages that overlap the routing region. """ diff --git a/compiler/router/graph_shape.py b/compiler/router/graph_shape.py index 1221dabe..0f950ae4 100644 --- a/compiler/router/graph_shape.py +++ b/compiler/router/graph_shape.py @@ -72,17 +72,6 @@ class graph_shape(pin_layout): return graph_shape(self.name, inflated_area, self.layer, self) - def multiply(self, scale): - """ Multiply the width and height with the scale value. """ - - width = (self.width() * (scale - 1)) / 2 - height = (self.height() * (scale - 1)) / 2 - ll, ur = self.rect - newll = vector(ll.x - width, ll.y - height) - newur = vector(ur.x + width, ur.y + height) - self.rect = [snap(newll), snap(newur)] - - def core_contained_by_any(self, shape_list): """ Return if the core of this shape is contained by any shape's core in the diff --git a/compiler/router/signal_escape_router.py b/compiler/router/signal_escape_router.py index 5e4ae66e..047dcfee 100644 --- a/compiler/router/signal_escape_router.py +++ b/compiler/router/signal_escape_router.py @@ -56,36 +56,22 @@ class signal_escape_router(router): for source, target, _ in self.get_route_pairs(pin_names): # Change fake pin's name so the graph will treat it as routable target.name = source.name - # This is the routing region scale - scale = 1 - while True: - # Create the graph - g = graph(self) - region = g.create_graph(source, target, scale) - # Find the shortest path from source to target - path = g.find_shortest_path() - # If there is no path found, exponentially try again with a - # larger routing region - if path is None: - rll, rur = region - bll, bur = self.bbox - # Stop scaling the region and throw an error - if rll.x < bll.x and rll.y < bll.y and \ - rur.x > bur.x and rur.y > bur.y: - self.write_debug_gds(gds_name="{}error.gds".format(OPTS.openram_temp), g=g, source=source, target=target) - debug.error("Couldn't route from {} to {}.".format(source, target), -1) - # Exponentially scale the region - scale *= 2 - debug.info(0, "Retry routing in larger routing region with scale {}".format(scale)) - continue - # Create the path shapes on layout - new_shapes = self.add_path(path) - self.new_pins[source.name] = new_shapes[0] - # Find the recently added shapes - self.prepare_gds_reader() - self.find_blockages(name) - self.find_vias() - break + # Create the graph + g = graph(self) + g.create_graph(source, target) + # Find the shortest path from source to target + path = g.find_shortest_path() + # If no path is found, throw an error + if path is None: + self.write_debug_gds(gds_name="{}error.gds".format(OPTS.openram_temp), g=g, source=source, target=target) + debug.error("Couldn't route from {} to {}.".format(source, target), -1) + # Create the path shapes on layout + new_shapes = self.add_path(path) + self.new_pins[source.name] = new_shapes[0] + # Find the recently added shapes + self.prepare_gds_reader() + self.find_blockages(name) + self.find_vias() self.replace_layout_pins() diff --git a/compiler/router/supply_router.py b/compiler/router/supply_router.py index f6acd24c..037e8868 100644 --- a/compiler/router/supply_router.py +++ b/compiler/router/supply_router.py @@ -71,35 +71,21 @@ class supply_router(router): pins = self.pins[pin_name] # Route closest pins according to the minimum spanning tree for source, target in self.get_mst_pairs(list(pins)): - # This is the routing region scale - scale = 1 - while True: - # Create the graph - g = graph(self) - region = g.create_graph(source, target, scale) - # Find the shortest path from source to target - path = g.find_shortest_path() - # If there is no path found, exponentially try again with a - # larger routing region - if path is None: - rll, rur = region - bll, bur = self.bbox - # Stop scaling the region and throw an error - if rll.x < bll.x and rll.y < bll.y and \ - rur.x > bur.x and rur.y > bur.y: - self.write_debug_gds(gds_name="{}error.gds".format(OPTS.openram_temp), g=g, source=source, target=target) - debug.error("Couldn't route from {} to {}.".format(source, target), -1) - # Exponentially scale the region - scale *= 2 - debug.info(0, "Retry routing in larger routing region with scale {}".format(scale)) - continue - # Create the path shapes on layout - self.add_path(path) - # Find the recently added shapes - self.prepare_gds_reader() - self.find_blockages(pin_name) - self.find_vias() - break + # Create the graph + g = graph(self) + region = g.create_graph(source, target) + # Find the shortest path from source to target + path = g.find_shortest_path() + # If no path is found, throw an error + if path is None: + self.write_debug_gds(gds_name="{}error.gds".format(OPTS.openram_temp), g=g, source=source, target=target) + debug.error("Couldn't route from {} to {}.".format(source, target), -1) + # Create the path shapes on layout + self.add_path(path) + # Find the recently added shapes + self.prepare_gds_reader() + self.find_blockages(pin_name) + self.find_vias() def add_side_pin(self, pin_name, side, num_vias=3, num_fake_pins=4):