Fix fabrication verification and routing diagnostics follow-up

This commit is contained in:
Jan Petykiewicz 2026-11-29 00:09:54 -08:00
commit cea23ef1b4

View file

@ -2,11 +2,11 @@ from dataclasses import replace
import pytest
from shapely import union_all
from shapely.geometry import box
from shapely.geometry import Polygon, box
from inire import (
Bend90Seed, CongestionOptions, NetSpec, PathSeed, Port, RefinementOptions,
RoutingOptions, RoutingProblem, SBendOutline, SearchOptions, StraightSeed, TopologyOptions, route,
RoutingOptions, RoutingProblem, SBendOutline, SBendSeed, SearchOptions, StraightSeed, TopologyOptions, route,
)
from inire.layout import PlacedPort, coplanar_geometry, partition_layers, preserves_length, route_profiles, verify_export_grid
@ -46,6 +46,21 @@ def test_export_verifies_actual_rounded_bend_clearance(outer_radius, grid, valid
assert all(report.dynamic_collision_count == int(not valid) for report in exported.reports_by_net.values())
@pytest.mark.parametrize(("keepout_y", "clearance", "valid"), [(21, 0.2, False), (21.2, 0.4, False), (21.25, 0.2, True)])
def test_export_checks_keepout_clearance_smaller_than_the_grid(keepout_y, clearance, valid) -> None:
net = NetSpec("signal", Port(10, 20, 0), Port(90, 20, 0), 1.4)
keepout = box(20, keepout_y, 30, 24)
problem = RoutingProblem((0, 0, 100, 50), (net,), (keepout,), clearance=clearance)
results = route(problem).results_by_net
assert results[net.net_id].is_valid
export = verify_export_grid(problem, results, grid=1)
assert export.geometry_by_net[net.net_id][0].bounds == (10, 19, 90, 21)
assert export.is_valid is valid
assert export.reports_by_net[net.net_id].static_collision_count == int(not valid)
@pytest.mark.parametrize(("pitch", "valid"), [(28000, False), (32000, False), (36000, True)])
def test_cpw_ground_strip_is_verified_using_gap_envelope(pitch, valid) -> None:
width = 15500
@ -77,6 +92,29 @@ def test_cpw_turn_builds_wider_exclusion_from_the_verified_envelope() -> None:
assert cpw.gaps.area > 0
@pytest.mark.parametrize("gap", [0, 0.5])
def test_cpw_checks_for_side_contact_between_terminal_faces(gap) -> None:
signal_outline = Polygon([(0, -1), (3, -1), (12, 5), (15, 5), (15, 7), (12, 7), (3, 1), (0, 1)])
envelope_outline = Polygon([(0, -2), (3, -1 - gap), (12, 5 - gap), (15, 4), (15, 8), (12, 8), (3, 2), (0, 2)])
net = NetSpec("signal", Port(10, 20, 0), Port(25, 26, 0), 2)
problem = RoutingProblem((0, 0, 100, 50), (net,), initial_paths={net.net_id: PathSeed((SBendSeed(6, 10),))})
options = replace(_REPLAY, search=replace(_REPLAY.search, sbend_outlines=(
SBendOutline(6, 10, 2, signal_outline), SBendOutline(6, 10, 4, envelope_outline),
)))
signal = route(problem, options=options).results_by_net[net.net_id]
envelope = route(replace(problem, nets=(replace(net, width=4),)), options=options).results_by_net[net.net_id]
assert signal.is_valid
assert envelope.is_valid
with pytest.raises(ValueError, match="nonempty gap"):
coplanar_geometry(signal, signal)
if gap:
assert coplanar_geometry(signal, envelope).gaps.area > 0
else:
with pytest.raises(ValueError, match="closes away from the terminal faces"):
coplanar_geometry(signal, envelope)
def test_cpw_coupling_etch_keeps_two_signal_sections_separate() -> None:
# The two nets abut opposite faces of the authored 5 µm interruption.
nets = (
@ -124,6 +162,21 @@ def test_profile_options_apply_to_active_search_and_seed_replay() -> None:
route_profiles(invalid, profiles)
@pytest.mark.parametrize(("second_y", "valid"), [(22, False), (23, True)])
def test_profile_reserves_replayed_net_against_zero_clearance_contact(second_y, valid) -> None:
first = NetSpec("first", Port(10, 20, 0), Port(90, 20, 0))
second = NetSpec("second", Port(10, second_y, 0), Port(90, second_y, 0))
seeds = {net.net_id: PathSeed((StraightSeed(80),)) for net in (first, second)}
problem = RoutingProblem((0, 0, 100, 50), (first, second), initial_paths=seeds, clearance=0)
results = route_profiles(problem, [(("first",), _REPLAY), (("second",), _REPLAY)])
assert results["first"].is_valid
assert results["second"].is_valid is valid
if valid:
assert verify_export_grid(problem, results, grid=1).is_valid
def test_independent_layer_outputs_retain_assignment_and_connectivity() -> None:
silicon = NetSpec("si", Port(1000, 10000, 0), Port(19000, 10000, 0), 500)
nitride = NetSpec("sin", Port(10000, 1000, 90), Port(10000, 19000, 90), 750)