Implement typed and octagonal catalog routing

This commit is contained in:
Jan Petykiewicz 2026-12-04 09:30:14 -08:00
commit 7616b398e9

View file

@ -25,6 +25,45 @@ result = route(problem).results_by_net["input"]
- [Bend radius settings](api-reference.md#searchoptions)
- [Layout input types and defaults](api-reference.md#routingproblem)
## Route a typed Masque layout
The preview adapter lives in `inire.masque`. The integration fixtures exercise Masque 4.0a3. Define named ports on the top-level pattern, using Masque's port mappings to expose ports from preplaced cells. Assign each endpoint its canonical routing profile. The adapter rounds resolved positions to the nearest layout unit before Inire checks exact membership on the routing lattice. Dimensions in the grid, shapes, and catalog use that common layout unit.
```python
from math import pi
from masque import Pattern, Port
from shapely.geometry import box
from inire.masque import Catalog, Connection, Endpoint, Grid, Profile, StraightVariant, route_and_place
layout = Pattern(ports={
"source": Port((10_000, 20_000), rotation=pi),
"destination": Port((90_000, 20_000), rotation=0),
})
catalog = Catalog("process-a", {"ridge-4": Profile("ridge", width=4000)}, {
"ridge-straight": StraightVariant("ridge-4", cost_per_cm=1),
})
result = route_and_place(
layout,
{},
(Connection("input", Endpoint("source", "ridge-4"), Endpoint("destination", "ridge-4")),),
catalog=catalog,
grid=Grid(origin=(0, 0), pitch=100, meters_per_unit=1e-9),
board=box(0, 0, 100_000, 80_000),
layer=1,
)
assert result.placed == ("input",)
```
Pass a mapping from cell names to Masque patterns for fixed variants. Include blocking polygons from the placed layout in `keepouts`. An endpoint can carry an `Attachment` for one of those polygons when its route must join at the fixed port. Both endpoint names are consumed for each placed connection. A fixed cell can omit its physical centerline length. Nonadjacent pieces separated by a cell with unknown length must meet ordinary self-clearance. With `require_complete=True`, every requested connection and active match group must complete before placement begins.
To experiment with lattice selection, pass `AutomaticGrid(preferred_pitch=1000, meters_per_unit=1e-9)`. It uses a divisor of the preferred pitch that fits the rounded terminals and the authored fixed-cell displacements. Read the selected grid from the placement result. Pass `CoarseGuidance(pitch=1000)` to propose routes inside coarse corridors while still placing and verifying moves on the selected routing grid. The fine search can retry outside a corridor within the remaining node budget.
The placement result reports the catalog revision, evaluated routes, consumed terminals, and placement outcome. Each verified route exposes its catalog cost and physical length in layout units when the lengths of all constituent moves are known. Inspect `unavailable_variants` for grid-fit and realization diagnostics.
Give each `MatchGroup` its member offsets, wavelength in meters, and tolerance. Express offsets and tolerance in group optical length in layout units or in seconds. Supply a `DelayModel` for the process indices and characterized cell delays. To enable a tuning detour, supply that net's polygon in `tuning_windows`. A fixed contribution can be a characterized constant, a function of wavelength, or `None` for missing delay data. Bend lead costs use the profile's lowest declared straight rate by default. Set a bend's `lead_cost_per_cm=0` to include the leads in its placement charge.
<a id="connect-a-preplaced-crossing"></a>
## Route between placed crossings