Skip to content
Snippets Groups Projects
Commit d9ab9949 authored by Thomas Kramer's avatar Thomas Kramer
Browse files

compute costs of terminal nodes and apply them to the graph edges

parent 819ce1a6
No related branches found
No related tags found
No related merge requests found
...@@ -462,6 +462,32 @@ class DefaultRouter(): ...@@ -462,6 +462,32 @@ class DefaultRouter():
else: else:
assert False, 'Routing graph is not connected.' assert False, 'Routing graph is not connected.'
# Set via weights based on terminal costs.
regions_by_layer = {
# Convert Shapes objects into db.Region for fast 'inside' checks.
layer: db.Region(s) for layer, s in shapes.items()
}
for net, ts in terminals_by_net:
for terminal_node in ts:
layer, (x, y) = terminal_node
possible_via_layers = (data['layer'] for _, _, data in via_layers.edges(layer, data=True))
for via_layer in possible_via_layers:
via_cost = compute_terminal_cost(
via_layer,
layer,
(x, y),
regions_by_layer[layer],
tech
)
other_node = via_layer, (x, y) # Node on the other side of the via.
if terminal_node in graph and other_node in graph:
# Scale the via cost
graph[terminal_node][other_node]['weight'] *= via_cost + 1
self._routing_graph = graph self._routing_graph = graph
# TODO: SPLIT HERE # TODO: SPLIT HERE
......
...@@ -396,6 +396,36 @@ def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, i ...@@ -396,6 +396,36 @@ def _extract_terminal_nodes_from_shape(routing_nodes: Dict[Any, Set[Tuple[int, i
logger.debug(f"routing_terminals: {routing_terminals}") logger.debug(f"routing_terminals: {routing_terminals}")
return routing_terminals return routing_terminals
def compute_terminal_cost(
via_layer: str,
layer: str,
coord: Tuple[int, int],
layer_region: db.Region,
tech
) -> int:
"""
Compute the cost of placing a via on `via_layer` which connects to `layer` at `(x, y)`.
The cost is derived from the existing geometries on the layer.
TODO: Move to new module 'pin_access_analysis'
Returns an unscaled cost. 0 for vias which can be placed without extending the pin shape,
1 for vias which would extend the pin shape.
"""
enc = tech.minimum_enclosure.get((layer, via_layer), 0)
via_size = tech.via_size[via_layer]
d = enc + via_size // 2
# Test if the via would be completely enclosed in existing shapes.
is_enclosed = is_inside(coord, layer_region, d)
if is_enclosed:
# Via can be placed without extending the pin shape.
return 0
else:
return 1
def extract_terminal_nodes_by_lvs(graph: nx.Graph, def extract_terminal_nodes_by_lvs(graph: nx.Graph,
pin_shapes_by_net: Dict[str, List[List[Tuple[str, db.Polygon]]]], pin_shapes_by_net: Dict[str, List[List[Tuple[str, db.Polygon]]]],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment