Skip to main content
Built-in Elements

<autoroutingphase />

The <autoroutingphase /> element lets you split PCB autorouting into ordered passes. The common use case is to route important connections first so later connections route around them.

Route Specific Connections First

Use connection for one connection or connections for several. Each value is a port selector for either endpoint of a connection.

This example routes the two horizontal connections in phase 0. The vertical connection has no phase assignment, so it routes afterward and treats the completed horizontal routes as obstacles.

export default () => (
<board width="18mm" height="18mm">
<testpoint name="TP_H1" pcbX={-7} pcbY={2} padDiameter="0.8mm" />
<testpoint name="TP_H2" pcbX={7} pcbY={2} padDiameter="0.8mm" />
<testpoint name="TP_H3" pcbX={-7} pcbY={-2} padDiameter="0.8mm" />
<testpoint name="TP_H4" pcbX={7} pcbY={-2} padDiameter="0.8mm" />
<testpoint name="TP_V1" pcbX={0} pcbY={-7} padDiameter="0.8mm" />
<testpoint name="TP_V2" pcbX={0} pcbY={7} padDiameter="0.8mm" />

<autoroutingphase
phaseIndex={0}
connections={["TP_H1.pin1", "TP_H3.pin1"]}
/>

<trace name="H_TOP" from="TP_H1.pin1" to="TP_H2.pin1" />
<trace name="H_BOTTOM" from="TP_H3.pin1" to="TP_H4.pin1" />
<trace name="V_CENTER" from="TP_V1.pin1" to="TP_V2.pin1" />
</board>
)
PCB Circuit Preview
<autoroutingphase
phaseIndex={0}
connections={["TP_H1.pin1", "TP_H3.pin1"]}
/>

Selectors may use normal port selector syntax, such as "U1.pin1" or ".U1 > .pin1". You do not need to add routingPhaseIndex to a trace when an autorouting phase selects it with connection or connections.

Create Multiple Ordered Phases

Phases run in ascending phaseIndex order. Connections without a numbered phase run after all numbered phases.

<autoroutingphase phaseIndex={0} connection="CLK_SOURCE.pin1" />
<autoroutingphase
phaseIndex={1}
connections={["USB_DP_SOURCE.pin1", "USB_DM_SOURCE.pin1"]}
/>

Here the clock connection routes first, the USB connections route second, and all remaining connections route last. Earlier routes are included as obstacles in each later pass.

Assign Traces and Nets Explicitly

As an alternative to selecting connections on <autoroutingphase />, use routingPhaseIndex on a <trace /> to put that trace into a phase:

<autoroutingphase phaseIndex={0} />
<trace from="U1.pin1" to="U2.pin1" routingPhaseIndex={0} />

You can also assign a <net /> to a phase. Traces connected to that net inherit the net's routing phase unless the trace sets its own routingPhaseIndex.

<autoroutingphase phaseIndex={0} />
<net name="GND" routingPhaseIndex={0} />
<trace from="C1.pin1" to="net.GND" />

If a trace has its own routingPhaseIndex, it overrides the phase inherited from a connected net.

Configure Each Phase

Set autorouter on a phase to use a different autorouter configuration for that pass. If you omit it, the phase uses the parent board or subcircuit autorouter.

<autoroutingphase
phaseIndex={0}
connection="J1.pin1"
autorouter={{
algorithmFn: createMyAutorouter,
}}
/>

For custom phase autorouters with algorithmFn, see Create or Use a Custom Autorouter.

Reroute Existing Traces

The reroute API is for changing routes produced by an earlier pass. Most phased-routing use cases do not need it.

Reroute a Region

Add a later phase with reroute and a rectangular region. The phase uses the routes from previous phases, extracts connections that cross the region, and replaces the route inside that rectangle.

The custom autorouter in this example returns a squiggly line so the rerouted right half of each trace is easy to see.

import { createSquigglyAutorouter } from "./demo-autorouter"

export default () => (
<board width="18mm" height="12mm">
<testpoint name="T1" pcbX={-7} pcbY={3} padDiameter="0.8mm" />
<testpoint name="T2" pcbX={7} pcbY={3} padDiameter="0.8mm" />
<testpoint name="M1" pcbX={-7} pcbY={0} padDiameter="0.8mm" />
<testpoint name="M2" pcbX={7} pcbY={0} padDiameter="0.8mm" />
<testpoint name="B1" pcbX={-7} pcbY={-3} padDiameter="0.8mm" />
<testpoint name="B2" pcbX={7} pcbY={-3} padDiameter="0.8mm" />

<autoroutingphase
reroute
region={{
shape: "rect",
minX: 0,
maxX: 8,
minY: -5,
maxY: 5,
}}
autorouter={{
algorithmFn: createSquigglyAutorouter,
}}
/>

<trace from="T1.pin1" to="T2.pin1" />
<trace from="M1.pin1" to="M2.pin1" />
<trace from="B1.pin1" to="B2.pin1" />
</board>
)
PCB Circuit Preview

The reroute phase does not need traces assigned to it. Only routes crossing the rectangle from x=0 to x=8 and y=-5 to y=5 are reconsidered.

Reroute Selected Connections

Combine reroute with connection or connections to reroute specific connections instead of a region. Previously routed traces remain in place and are treated as obstacles.

import { createSquigglyAutorouter } from "./demo-autorouter"

export default () => (
<board width="18mm" height="12mm">
<testpoint name="T1" pcbX={-7} pcbY={3} padDiameter="0.8mm" />
<testpoint name="T2" pcbX={7} pcbY={3} padDiameter="0.8mm" />
<testpoint name="M1" pcbX={-7} pcbY={0} padDiameter="0.8mm" />
<testpoint name="M2" pcbX={7} pcbY={0} padDiameter="0.8mm" />
<testpoint name="B1" pcbX={-7} pcbY={-3} padDiameter="0.8mm" />
<testpoint name="B2" pcbX={7} pcbY={-3} padDiameter="0.8mm" />

<autoroutingphase phaseIndex={0} />
<autoroutingphase
phaseIndex={1}
reroute
connection="M1.pin1"
autorouter={{
algorithmFn: createSquigglyAutorouter,
}}
/>

<trace from="T1.pin1" to="T2.pin1" routingPhaseIndex={0} />
<trace from="M1.pin1" to="M2.pin1" routingPhaseIndex={0} />
<trace from="B1.pin1" to="B2.pin1" routingPhaseIndex={0} />
</board>
)
PCB Circuit Preview
<autoroutingphase
phaseIndex={1}
reroute
connection="M1.pin1"
/>

Use connections to target more than one previously routed connection:

<autoroutingphase
phaseIndex={1}
reroute
connections={["M1.pin1", "B1.pin1"]}
/>

Props

PropTypeDescription
phaseIndexnumberThe routing pass configured by this element. Lower numbered phases run first.
connectionstringPort selector for one connection to route in this phase. With reroute, selects one previously routed connection instead.
connectionsstring[]Port selectors for multiple connections to route in this phase. With reroute, selects previously routed connections instead.
autorouterstring | AutorouterConfigOptional autorouter preset or configuration for this phase. Omit it to use the parent board or subcircuit autorouter.
reroutebooleanReroutes traces produced by earlier phases instead of routing newly assigned traces. Requires region, connection, or connections.
region{ shape?: "rect"; minX: number; maxX: number; minY: number; maxY: number }Rectangular PCB region to reconsider in a reroute phase.