Add more comments for gridless router

This commit is contained in:
Eren Dogan 2023-07-13 11:29:51 -07:00
parent 6b0b4c2def
commit 813a67fea9
2 changed files with 35 additions and 14 deletions

View File

@ -55,7 +55,7 @@ class hanan_graph:
def create_graph(self, source, target): def create_graph(self, source, target):
""" Create the Hanan graph to run routing on later. """ """ Create the Hanan graph to run routing on later. """
debug.info(0, "Creating the Hanan graph for source '{0}' and target'{1}'.".format(source, target)) debug.info(2, "Creating the Hanan graph for source '{}' and target'{}'.".format(source, target))
self.source = source self.source = source
self.target = target self.target = target
@ -64,7 +64,7 @@ class hanan_graph:
region = deepcopy(source) region = deepcopy(source)
region.bbox([target]) region.bbox([target])
region = region.inflated_pin(multiple=1) region = region.inflated_pin(multiple=1)
debug.info(0, "Routing region is {}".format(region.rect)) debug.info(3, "Routing region is {}".format(region.rect))
# Find the blockages that are in the routing area # Find the blockages that are in the routing area
self.graph_blockages = [] self.graph_blockages = []
@ -77,13 +77,13 @@ class hanan_graph:
region.lpp = blockage.lpp region.lpp = blockage.lpp
if region.overlaps(blockage): if region.overlaps(blockage):
self.graph_blockages.append(blockage) self.graph_blockages.append(blockage)
debug.info(0, "Number of blockages detected in the routing region: {}".format(len(self.graph_blockages))) debug.info(3, "Number of blockages detected in the routing region: {}".format(len(self.graph_blockages)))
# Create the Hanan graph # Create the Hanan graph
x_values, y_values = self.generate_cartesian_values() x_values, y_values = self.generate_cartesian_values()
self.generate_hanan_nodes(x_values, y_values) self.generate_hanan_nodes(x_values, y_values)
self.remove_blocked_nodes() self.remove_blocked_nodes()
debug.info(0, "Number of nodes in the routing graph: {}".format(len(self.nodes))) debug.info(3, "Number of nodes in the routing graph: {}".format(len(self.nodes)))
def generate_cartesian_values(self): def generate_cartesian_values(self):

View File

@ -22,16 +22,29 @@ class hanan_router(router_tech):
def __init__(self, layers, design, bbox=None, pin_type=None): def __init__(self, layers, design, bbox=None, pin_type=None):
# `router_tech` contains tech constants for the router
router_tech.__init__(self, layers, route_track_width=1) router_tech.__init__(self, layers, route_track_width=1)
# Layers that can be used for routing
self.layers = layers self.layers = layers
# This is the `hierarchy_layout` object
self.design = design self.design = design
# Side supply pin type
# (can be "top", "bottom", "right", "left", and "ring")
self.pin_type = pin_type self.pin_type = pin_type
# Temporary GDSII file name to find pins and blockages
self.gds_filename = OPTS.openram_temp + "temp.gds" self.gds_filename = OPTS.openram_temp + "temp.gds"
# Dictionary for vdd and gnd pins
self.pins = {} self.pins = {}
# Set of all the pins
self.all_pins = set() self.all_pins = set()
# This is all the blockages including the pins. The graph class handles
# pins as blockages while considering their routability
self.blockages = [] self.blockages = []
# New pins are the side supply pins
self.new_pins = {} self.new_pins = {}
# Fake pins are imaginary pins on the side supply pins to route other
# pins to them
self.fake_pins = [] self.fake_pins = []
# Set the offset here # Set the offset here
@ -40,9 +53,11 @@ class hanan_router(router_tech):
def route(self, vdd_name="vdd", gnd_name="gnd"): def route(self, vdd_name="vdd", gnd_name="gnd"):
""" Route the given pins in the given order. """ """ Route the given pins in the given order. """
#debug.info(1, "Running router for {}...".format(pins)) debug.info(1, "Running router for {} and {}...".format(vdd_name, gnd_name))
# FIXME: Comment-out later
self.write_debug_gds(gds_name="before.gds") self.write_debug_gds(gds_name="before.gds")
# Save pin names
self.vdd_name = vdd_name self.vdd_name = vdd_name
self.gnd_name = gnd_name self.gnd_name = gnd_name
@ -66,17 +81,20 @@ class hanan_router(router_tech):
else: else:
debug.warning("Side supply pins aren't created.") debug.warning("Side supply pins aren't created.")
# FIXME: Comment-out later
self.write_debug_gds(gds_name="after.gds") self.write_debug_gds(gds_name="after.gds")
# Add vdd and gnd pins as blockages as well # Add vdd and gnd pins as blockages as well
# NOTE: This is done to make vdd and gnd pins DRC-safe # NOTE: This is done to make vdd and gnd pins DRC-safe
for pin in self.all_pins: for pin in self.all_pins:
self.blockages.append(pin.inflated_pin(multiple=1, extra_spacing=self.offset, keep_link=True)) self.blockages.append(pin.inflated_pin(multiple=1,
extra_spacing=self.offset,
keep_link=True))
# Route vdd and gnd # Route vdd and gnd
for pin_name in [vdd_name, gnd_name]: for pin_name in [vdd_name, gnd_name]:
pins = self.pins[pin_name] pins = self.pins[pin_name]
# Create minimum spanning tree connecting all pins # Route closest pins according to the minimum spanning tree
for source, target in self.get_mst_pairs(list(pins)): for source, target in self.get_mst_pairs(list(pins)):
# Create the Hanan graph # Create the Hanan graph
hg = hanan_graph(self) hg = hanan_graph(self)
@ -90,11 +108,12 @@ class hanan_router(router_tech):
self.prepare_gds_reader() self.prepare_gds_reader()
self.find_blockages(pin_name) self.find_blockages(pin_name)
# FIXME: Comment-out later
self.write_debug_gds(gds_name="after.gds") self.write_debug_gds(gds_name="after.gds")
def prepare_gds_reader(self): def prepare_gds_reader(self):
""" """ """ Write the current layout to a temporary file to read the layout. """
self.design.gds_write(self.gds_filename) self.design.gds_write(self.gds_filename)
self.layout = gdsMill.VlsiLayout(units=GDS["unit"]) self.layout = gdsMill.VlsiLayout(units=GDS["unit"])
@ -103,8 +122,8 @@ class hanan_router(router_tech):
def find_pins(self, pin_name): def find_pins(self, pin_name):
""" """ """ Find the pins with the given name. """
debug.info(1, "Finding all pins for {}".format(pin_name)) debug.info(2, "Finding all pins for {}".format(pin_name))
shape_list = self.layout.getAllPinShapes(str(pin_name)) shape_list = self.layout.getAllPinShapes(str(pin_name))
pin_set = set() pin_set = set()
@ -133,9 +152,10 @@ class hanan_router(router_tech):
def find_blockages(self, shape_name=None): def find_blockages(self, shape_name=None):
""" """ """ Find all blockages in the routing layers. """
debug.info(1, "Finding blockages...") debug.info(1, "Finding blockages...")
# Keep current blockages here
prev_blockages = self.blockages[:] prev_blockages = self.blockages[:]
blockages = [] blockages = []
@ -213,6 +233,7 @@ class hanan_router(router_tech):
else: else:
margin = 0 margin = 0
# Calculate the lower left coordinate
if side == "top": if side == "top":
offset = vector(ll.x + margin, ur.y - wideness - margin) offset = vector(ll.x + margin, ur.y - wideness - margin)
elif side == "bottom": elif side == "bottom":
@ -222,15 +243,14 @@ class hanan_router(router_tech):
elif side == "right": elif side == "right":
offset = vector(ur.x - wideness - margin, ll.y + margin) offset = vector(ur.x - wideness - margin, ll.y + margin)
# Calculate width and height
shape = ur - ll shape = ur - ll
if vertical: if vertical:
shape_width = wideness shape_width = wideness
shape_height = shape.y shape_height = shape.y
else: else:
shape_width = shape.x shape_width = shape.x
shape_height = wideness shape_height = wideness
if inner: if inner:
if vertical: if vertical:
shape_height -= margin * 2 shape_height -= margin * 2
@ -244,6 +264,7 @@ class hanan_router(router_tech):
offset=offset, offset=offset,
width=shape_width, width=shape_width,
height=shape_height) height=shape_height)
# Add fake pins on this new pin evenly # Add fake pins on this new pin evenly
fake_pins = [] fake_pins = []
if vertical: if vertical:
@ -270,7 +291,7 @@ class hanan_router(router_tech):
def add_ring_pin(self, pin_name, width=3, num_connects=4): def add_ring_pin(self, pin_name, width=3, num_connects=4):
""" Add suply ring to the layout. """ """ Add the supply ring to the layout. """
bbox = self.design.get_bbox() bbox = self.design.get_bbox()