diff --git a/compiler/base/hierarchy_layout.py b/compiler/base/hierarchy_layout.py index 4dedd9a9..451d1356 100644 --- a/compiler/base/hierarchy_layout.py +++ b/compiler/base/hierarchy_layout.py @@ -39,6 +39,12 @@ class layout(): self.visited = [] # List of modules we have already visited self.is_library_cell = False # Flag for library cells self.gds_read() + try: + from tech import power_grid + self.pwr_grid_layer = power_grid[0] + except ImportError: + self.pwr_grid_layer = "m3" + ############################################################ # GDS layout @@ -1169,12 +1175,12 @@ class layout(): def copy_power_pins(self, inst, name): """ - This will copy a power pin if it is on M3. + This will copy a power pin if it is on the lowest power_grid layer. If it is on M1, it will add a power via too. """ pins = inst.get_pins(name) for pin in pins: - if pin.layer == "m3": + if pin.layer == self.pwr_grid_layer: self.add_layout_pin(name, pin.layer, pin.ll(), @@ -1183,14 +1189,17 @@ class layout(): elif pin.layer == "m1": self.add_power_pin(name, pin.center()) else: - debug.warning("{0} pins of {1} should be on metal3 or metal1 for supply router.".format(name,inst.name)) + debug.warning("{0} pins of {1} should be on {2} or metal1 for "\ + "supply router." + .format(name,inst.name,self.pwr_grid_layer)) def add_power_pin(self, name, loc, size=[1, 1], vertical=False, start_layer="m1"): """ - Add a single power pin from M3 down to M1 at the given center location. - The starting layer is specified to determine which vias are needed. + Add a single power pin from the lowest power_grid layer down to M1 at + the given center location. The starting layer is specified to determine + which vias are needed. """ if vertical: direction = ("V", "V") @@ -1198,18 +1207,18 @@ class layout(): direction = ("H", "H") via = self.add_via_stack_center(from_layer=start_layer, - to_layer="m3", + to_layer=self.pwr_grid_layer, size=size, offset=loc, direction=direction) - if start_layer == "m3": + if start_layer == self.pwr_grid_layer: self.add_layout_pin_rect_center(text=name, - layer="m3", + layer=self.pwr_grid_layer, offset=loc) else: self.add_layout_pin_rect_center(text=name, - layer="m3", + layer=self.pwr_grid_layer, offset=loc, width=via.width, height=via.height) diff --git a/compiler/router/router_tech.py b/compiler/router/router_tech.py index efae2708..e0f277e9 100644 --- a/compiler/router/router_tech.py +++ b/compiler/router/router_tech.py @@ -5,7 +5,7 @@ # (acting for and on behalf of Oklahoma State University) # All rights reserved. # -from tech import drc, layer +from tech import drc, layer, preferred_directions from contact import contact from vector import vector import debug @@ -26,6 +26,9 @@ class router_tech: self.rail_track_width = rail_track_width if len(self.layers) == 1: + if preferred_directions[self.layers[0]] != "H": + debug.warning("Using '{}' for horizontal routing, but it " \ + "prefers vertical routing".format(self.layers[0])) self.horiz_layer_name = self.vert_layer_name = self.layers[0] self.horiz_lpp = self.vert_lpp = layer[self.layers[0]] @@ -35,7 +38,17 @@ class router_tech: self.horiz_track_width = self.horiz_layer_minwidth + self.horiz_layer_spacing self.vert_track_width = self.vert_layer_minwidth + self.vert_layer_spacing else: - (self.horiz_layer_name, self.via_layer_name, self.vert_layer_name) = self.layers + (try_horiz_layer, self.via_layer_name, try_vert_layer) = self.layers + + # figure out wich of the two layers prefers horizontal/vertical + # routing + if preferred_directions[try_horiz_layer] == "H" and preferred_directions[try_vert_layer] == "V": + self.horiz_layer_name = try_horiz_layer + self.vert_layer_name = try_vert_layer + else: + raise ValueError("Layer '{}' and '{}' are using the wrong " \ + "preferred_directions '{}' and '{}'. Only "\ + "('H', 'V') are supported") via_connect = contact(self.layers, (1, 1)) max_via_size = max(via_connect.width,via_connect.height) diff --git a/compiler/sram/sram_base.py b/compiler/sram/sram_base.py index 65297889..c7c91e90 100644 --- a/compiler/sram/sram_base.py +++ b/compiler/sram/sram_base.py @@ -148,14 +148,21 @@ class sram_base(design, verilog, lef): if not OPTS.route_supplies: # Do not route the power supply (leave as must-connect pins) return - elif "m4" in tech.layer: - # Route a M3/M4 grid - from supply_grid_router import supply_grid_router as router - rtr=router(self.m3_stack, self) - elif "m3" in tech.layer: - from supply_tree_router import supply_tree_router as router - rtr=router(("m3",), self) + grid_stack = set() + try: + from tech import power_grid + grid_stack = power_grid + except ImportError: + # if no power_grid is specified by tech we use sensible defaults + if "m4" in tech.layer: + # Route a M3/M4 grid + grid_stack = self.m3_stack + elif "m3" in tech.layer: + grid_stack =("m3",) + + from supply_grid_router import supply_grid_router as router + rtr=router(grid_stack, self) rtr.route()