Skip to content

hal.routing.routing_algo

TierBasedRouter

TierBasedRouter(
    tiers,
    max_bump_transitions_per_coupler,
    max_tsvs_per_coupler,
    routing_edge_order,
    edge_expansion_val,
    routing_algorithm,
    max_coupler_length,
    node_expansion_val=1,
    verbose=False,
)

Encapsulate the multi-tier routing logic for HardwareAwareLayout.

Attributes:

  • tiers (list[Tier]) –

    Working tiers holding graphs and occupancy grids.

  • max_bump_transitions_per_coupler (int | None) –

    Maximum allowed count of face switches on a single coupler.

  • max_tsvs_per_coupler (int | None) –

    Maximum allowed TSVs per coupler; exceeding triggers stop/promotion.

  • routing_edge_order (str) –

    Edge ordering metric determining routing order.

  • edge_expansion_val (int) –

    Expansion radius used when marking routed traces on the grid.

  • routing_algorithm (str) –

    Selected algorithm variant; currently "straightline_astar".

  • max_coupler_length (int | None) –

    Relative length limit with respect to the shortest coupler.

  • verbose (bool) –

    Emit additional logs when True.

  • min_length_coupler (int) –

    Cached shortest coupler length on the base tier.

_check_routing_constraints

_check_routing_constraints(edge, route, switch_info)

Check if the routing satisfies all constraints.

_core_routing_routine

_core_routing_routine(
    edges_to_route, progress_bar=None, reattempt=False
)

Core routing routine that handles multi-tier routing with face switches.

Args: edges_to_route: List of edges to route progress_bar: Optional progress bar for tracking reattempt: Whether this is a reattempt (preserves existing state)

_edge_exists_in_list

_edge_exists_in_list(edge, edge_list)

Check if an edge exists in a list (helper function from original code).

_finalize_tier

_finalize_tier(tier_ind, tier_state)

Finalize a tier with computed metrics and state.

_initialize_tier_state

_initialize_tier_state(tier_ind, reattempt)

Initialize or restore the state for a given tier.

_mark_grid_route

_mark_grid_route(tier, route)

Mark grid cells along a route.

_process_face_switches

_process_face_switches(edge, route, switch_num)

Process face switches in a route and return switch information.

_promote_edges_to_next_tier

_promote_edges_to_next_tier(
    tier_ind, edges_to_route, edge, tier_state
)

Promote edges to the next tier when constraints are violated.

_route_single_edge

_route_single_edge(tier_ind, edge, router, switch_num)

Attempt to route a single edge using straightline first, then A*.

Returns: tuple: (route, switch_info) if successful, None if failed

_update_tier_state_for_successful_route

_update_tier_state_for_successful_route(
    tier_ind, edge, route, switch_info, tier_state
)

Update tier state after a successful route.

attempt_higher_tier_on_base

attempt_higher_tier_on_base()

Attempt to route higher tier edges on the base tier.

Returns: int: Additional route length from successful routes.

route_base_tier

route_base_tier()

Route the base tier using straightline connections.

Returns: int: Total route length for the base tier.

route_higher_tiers

route_higher_tiers()

Route remaining edges on higher tiers using the core routing routine.