diff --git a/lclayout/routing_graph.py b/lclayout/routing_graph.py index 23541789a2428f36d3e6cb90cc20b4d9d1574104..73e8042e78b258a9c0bb294db02a5d533a1aa76f 100644 --- a/lclayout/routing_graph.py +++ b/lclayout/routing_graph.py @@ -345,7 +345,7 @@ def remove_existing_routing_edges(G: nx.Graph, shapes: Dict[Any, db.Shapes], tec def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, int]]], layer: str, shape: db.Shape, - tech) -> List[Tuple[int, int]]: + tech) -> Tuple[List[Tuple[int, int]],Dict[Tuple[int,int],int]]: """ Get coordinates of routing nodes that lie inside the shape. :param graph: @@ -372,6 +372,8 @@ def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, i logger.debug(f"max_via_size: {max_via_size}") # TODO: How to convert db.Shape into db.Region in a clean way??? + weights=dict() + if isinstance(shape, db.Shape): s = db.Shapes() s.insert(shape) @@ -383,10 +385,17 @@ def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, i if layer in tech.routing_layers: # On routing layers enclosure can be added, so nodes are not required to be properly enclosed. d = 1 + d2 = enc + max_via_size // 2 logger.debug(f"d: {d}") logger.debug(f"routing_nodes: {routing_nodes[layer]}") logger.debug(f"terminal_region: {terminal_region}") 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 1500 + logger.debug(f"terminal weights: {weights}") + + else: # A routing node must be properly enclosed to be used. d = enc + max_via_size // 2 @@ -394,7 +403,7 @@ def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, i routing_terminals = inside(routing_nodes[layer], terminal_region, d) logger.debug(f"routing_terminals: {routing_terminals}") - return routing_terminals + return routing_terminals,weights def extract_terminal_nodes_by_lvs(graph: nx.Graph, @@ -429,7 +438,7 @@ def extract_terminal_nodes_by_lvs(graph: nx.Graph, if layer in routing_nodes: assert isinstance(polygon, db.Polygon) - nodes = _extract_terminal_nodes_from_shape(routing_nodes, + nodes,weights = _extract_terminal_nodes_from_shape(routing_nodes, layer, polygon, tech) @@ -471,7 +480,7 @@ def extract_terminal_nodes(graph: nx.Graph, net = net_shape.property('net') logger.debug(f"net: {net}") if net is not None: - nodes = _extract_terminal_nodes_from_shape(routing_nodes, + nodes,weights = _extract_terminal_nodes_from_shape(routing_nodes, layer, net_shape, tech)