Fix bug to remove pin from conflicts in addition to graph keys

This commit is contained in:
Matt Guthaus 2018-07-25 15:36:16 -07:00
parent a4bfbe3545
commit 6d71c3f790
1 changed files with 26 additions and 17 deletions

View File

@ -717,6 +717,17 @@ class layout(lef.lef):
try to minimize the number of tracks -- instead, it picks an order to avoid the vertical try to minimize the number of tracks -- instead, it picks an order to avoid the vertical
conflicts between pins. conflicts between pins.
""" """
def remove_pin_from_graph(pin, g):
# Remove the pin from the keys
g.pop(pin,None)
# Remove the pin from all conflicts
# This is O(n^2), so maybe optimize it.
for other_pin,conflicts in g.items():
if pin in conflicts:
conflicts.remove(pin)
vcg[other_pin]=conflicts
if not pitch and vertical: if not pitch and vertical:
pitch = self.m2_pitch pitch = self.m2_pitch
elif not pitch and not vertical: elif not pitch and not vertical:
@ -736,13 +747,17 @@ class layout(lef.lef):
vcg[bot_name] = [] vcg[bot_name] = []
# Find the vertical pin conflicts # Find the vertical pin conflicts
for (top_name, bot_name) in route_map: # FIXME: O(n^2) but who cares for now
top_pin = all_pins[top_name] for top_name,top_pin in top_pins.items():
bot_pin = all_pins[bot_name] for bot_name,bot_pin in bottom_pins.items():
if abs(top_pin.center().x-bot_pin.center().x) < pitch: if not vertical and abs(top_pin.center().x-bot_pin.center().x) < pitch:
# The edges only go from top to bottom # The edges only go from top to bottom
# since we will order tracks bottom up # since we will order tracks bottom up
vcg[top_name].append(bot_name) vcg[top_name].append(bot_name)
elif vertical and abs(top_pin.center().y-bot_pin.center().y) < pitch:
# The edges only go from top to bottom
# since we will order tracks bottom up
vcg[top_name].append(bot_name)
# This is the starting offset of the first trunk # This is the starting offset of the first trunk
if vertical: if vertical:
@ -754,18 +769,12 @@ class layout(lef.lef):
# list of routes to do # list of routes to do
while vcg: while vcg:
#print(vcg)
# get a route from conflict graph with empty fanout set # get a route from conflict graph with empty fanout set
route_pin=None route_pin=None
for route_pin,conflicts in vcg.items(): for route_pin,conflicts in vcg.items():
if len(conflicts)==0: if len(conflicts)==0:
# Remove the pin from the keys remove_pin_from_graph(route_pin,vcg)
vcg.pop(route_pin,None)
# Remove the pin from all conflicts
# This is O(n^2), so maybe optimize it.
for pin,conflicts in vcg.items():
if pin in conflicts:
conflicts.remove(route_pin)
vcg[pin]=conflicts
break break
#print("Routing:",route_pin) #print("Routing:",route_pin)
@ -776,8 +785,8 @@ class layout(lef.lef):
#print("Routing:",pin_connections) #print("Routing:",pin_connections)
# Remove the other pins from the conflict graph too # Remove the other pins from the conflict graph too
for pin in pin_connections: for other_pin in pin_connections:
vcg.pop(pin,None) remove_pin_from_graph(other_pin, vcg)
# Create a list of the pins rather than a list of the names # Create a list of the pins rather than a list of the names
pin_list = [all_pins[pin_name] for pin_name in pin_connections] pin_list = [all_pins[pin_name] for pin_name in pin_connections]