diff --git a/src/lclayout/graphrouter/inspect.py b/src/lclayout/graphrouter/inspect.py index 61b7fbe65ac13ff36d06d5efd3d28de56fb7c8fe..56f6945ddd45987219cc62498ae30f295bc98693 100644 --- a/src/lclayout/graphrouter/inspect.py +++ b/src/lclayout/graphrouter/inspect.py @@ -6,6 +6,7 @@ Wrap a graph router and add visual inspection capabilities. """ import os +import math import networkx as nx from typing import * @@ -68,10 +69,21 @@ class InspectRouter(GraphRouter): layer, (x, y) = n pos[n] = (x, y) + def hue2rgb(hue: float) -> str: + assert 0. <= hue <= 1. + + a = 2 * math.pi / 3 + [r,g,b] = [int(255* math.cos(hue*math.pi + i*a) ** 2) for i in range(3)] + + return f"#{r:02x}{g:02x}{b:02x}" + + net_names = sorted(routes.keys()) + num_routes = len(routes) + colors = (hue2rgb(i/(num_routes+1)) for i in range(num_routes)) - for (name, tree) in routes.items(): + for name, color in zip(net_names, colors): + tree = routes[name] edges = tree.edges - color = "black" edges = [e for e in edges if not self._is_virtual_node_fn(e[0]) and not self._is_virtual_node_fn(e[1])] nx.draw_networkx_edges(self._graph, pos, edgelist=edges, width=4, edge_color=color) diff --git a/src/lclayout/standalone.py b/src/lclayout/standalone.py index a45ccf94d84e920d1c87fc78cbc938c9efe3a277..edd50c8874f1d5055cd16051b2a0ce345907a34b 100644 --- a/src/lclayout/standalone.py +++ b/src/lclayout/standalone.py @@ -878,6 +878,8 @@ def main(): parser.add_argument('--debug-routing-graph', action='store_true', help='write full routing graph to the layout instead of wires') + parser.add_argument('--debug-visual', action='store_true', + help='write visual debug information to the debug output directory') parser.add_argument('--debug-smt-solver', action='store_true', help='enable debug mode: display routing nodes in layout, \ show unsatisfiable core if SMT DRC cleaning fails.') @@ -952,7 +954,8 @@ def main(): orientation_change_penalty=tech.orientation_change_penalty ) - router = InspectRouter(router) + if args.debug_visual: + router = InspectRouter(router, output_dir = args.debug_output_dir) layouter = LcLayout(tech=tech, layout=layout,