From 5e5bba6175b883df8aa2eaed9ca520bb7a130153 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20G=C3=BChring?= <pg@futureware.at>
Date: Thu, 23 Feb 2023 16:44:56 +0100
Subject: [PATCH] Revert "Trying to apply the terminal weights to routing but
 it doesn't work yet"

This reverts commit 6039237853573e6c5ec344ca806855ac94a9be4c.
---
 lclayout/router.py        |  4 ++--
 lclayout/routing_graph.py | 19 +++++++++----------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/lclayout/router.py b/lclayout/router.py
index ca38f90..c43aa67 100644
--- a/lclayout/router.py
+++ b/lclayout/router.py
@@ -440,7 +440,7 @@ class DefaultRouter():
                 l: top_cell.shapes(routing_terminal_debug_layers[l]) for l in tech.routing_layers.keys()
             }
             for net, ts in terminals_by_net:
-                for layer, (x, y), termweight in ts:
+                for layer, (x, y) in ts:
                     d = tech.routing_grid_pitch_x // 16
                     routing_terminal_shapes[layer].insert(pya.Box(pya.Point(x - d, y - d), pya.Point(x + d, y + d)))
 
@@ -575,7 +575,7 @@ class DefaultRouter():
             # (For instance the ends of a gate stripe.)
             reserved_nodes = defaultdict(set)
             for net, pins in terminals_by_net:
-                for layer, p, termweight in pins:
+                for layer, p in pins:
                     n = layer, p
                     reserved = reserved_nodes[net]
                     reserved.add(n)
diff --git a/lclayout/routing_graph.py b/lclayout/routing_graph.py
index f6bed27..0646175 100644
--- a/lclayout/routing_graph.py
+++ b/lclayout/routing_graph.py
@@ -392,7 +392,7 @@ def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, i
         routing_terminals = interacting(routing_nodes[layer], terminal_region, d)
         inner_routing_terminals = inside(routing_nodes[layer], terminal_region, d2)
         for p in routing_terminals:
-            weights[p]=0 if p in inner_routing_terminals else 1500000
+            weights[p]=0 if p in inner_routing_terminals else 1500
         logger.debug(f"terminal weights: {weights}")
 
 
@@ -478,7 +478,7 @@ def extract_terminal_nodes_by_lvs(graph: nx.Graph,
                     routing_nodes[layer] -= set(nodes)
                     # TODO: need to be removed from G also. Better: construct edges in G afterwards.
 
-                    pin_nodes.extend(((layer, t, weights[t]) for t in nodes))
+                    pin_nodes.extend(((layer, t) for t in nodes))
             if pin_nodes:
                 terminals_by_net.append((net, pin_nodes))
 
@@ -487,7 +487,7 @@ def extract_terminal_nodes_by_lvs(graph: nx.Graph,
 
 def extract_terminal_nodes(graph: nx.Graph,
                            shapes: Dict[str, db.Shapes],
-                           tech) -> List[Tuple[str, List, int]]:
+                           tech) -> List[Tuple[str, List]]:
     """ Get terminal nodes for each net.
     Terminal nodes are extracted from the shapes on the layer and their 'net' property.
     :param graph: Routing graph.
@@ -515,7 +515,7 @@ def extract_terminal_nodes(graph: nx.Graph,
                                                            net_shape,
                                                            tech)
 
-                terminals_by_net.append((net, [(layer, t, weights[t]) for t in nodes]))
+                terminals_by_net.append((net, [(layer, t) for t in nodes]))
                 # Don't use terminals for normal routing
                 routing_nodes[layer] -= set(nodes)
                 # TODO: need to be removed from G also. Better: construct edges in G afterwards.
@@ -556,7 +556,7 @@ def extract_terminal_nodes(graph: nx.Graph,
 
 def embed_transistor_terminal_nodes(G: nx.Graph,
                                     transistor_layouts: Dict[Transistor, TransistorLayout],
-                                    tech) -> List[Tuple[str, List[Tuple[str, Tuple[int, int], int]]]]:
+                                    tech) -> List[Tuple[str, List[Tuple[str, Tuple[int, int]]]]]:
     """ Embed the terminal nodes of a the transistors into the routing graph.
     Modifies `G` and `terminals_by_net`
     :param G: The routing graph.
@@ -592,11 +592,10 @@ def embed_transistor_terminal_nodes(G: nx.Graph,
                     neighbour_node = min(x_aligned_nodes, key=lambda n: dist(n, t))
 
                     # TODO: weight proportional to gate width?
-                    logger.debug(f"Embedding t:{t} neighbour:{neighbour_node} with weight:1000")
                     G.add_edge(t, neighbour_node, weight=1000)
 
                     assert layer is not None
-                    coords.append((layer, (x, y),0))
+                    coords.append((layer, (x, y)))
                 else:
                     logger.debug(f"No neighbour node for terminal with net `{net}` of transistor {transistor.name}.")
 
@@ -607,7 +606,7 @@ def embed_transistor_terminal_nodes(G: nx.Graph,
 
 
 def create_virtual_terminal_nodes(G: nx.Graph,
-                                  terminals_by_net: List[Tuple[str, List[Tuple[str, Tuple[int, int], int]]]],
+                                  terminals_by_net: List[Tuple[str, List[Tuple[str, Tuple[int, int]]]]],
                                   io_pins: Iterable,
                                   tech):
     """ Create virtual terminal nodes for each net.
@@ -632,12 +631,12 @@ def create_virtual_terminal_nodes(G: nx.Graph,
             virtual_net_terminal = ('virtual', net, next(cnt))
             virtual_terminal_nodes[net].append(virtual_net_terminal)
 
-            for layer, p, termweight in terminals:
+            for layer, p in terminals:
                 n = layer, p
                 assert n in G.nodes, "Node not present in graph: %s" % str(n)
                 # High weight for virtual edge
                 # TODO: High weight only for low-resistance layers.
-                G.add_edge(virtual_net_terminal, n, weight=weight+termweight)
+                G.add_edge(virtual_net_terminal, n, weight=weight)
 
     cnt = count()
     # Create virtual nodes for I/O pins.
-- 
GitLab