Skip to content

Commit

Permalink
Integrate Capacity Autorouter (#656)
Browse files Browse the repository at this point in the history
* add GenericLocalAutorouter

* wip

* wip autorouting

* wip

* wip

* wip making autorouting code much better, removing somewhat unnecessary pcb net island routing

* nets now get subcircuit ids

* add support for using board bounds rather than computed bounds where defined

* easier distances for benchmark led circuit

* wip capacity mesh autorouter

* wip, autorouter working again but traces not showing

* remove log lines

* add vias manually based on routes for now

* checkpoint, autorouting seems to be working

* fixes for backwards compat

* remove accidentally committed data file

* update for current phase fix

* update snapshot, remove log lines

* fix type issues

* skip long test

* fix test

* update other randomly failing snapshots

* fix descendent subcircuit handling

* add todo
  • Loading branch information
seveibar authored Feb 28, 2025
1 parent 85c4453 commit 69565c5
Show file tree
Hide file tree
Showing 44 changed files with 898 additions and 213 deletions.
88 changes: 58 additions & 30 deletions benchmarking/benchmarks/benchmark1-led-matrix.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,60 @@
import { grid } from "@tscircuit/math-utils"
import { sel } from "lib/sel"
import type { BoardProps } from "@tscircuit/props"

export const Benchmark1LedMatrix = () => (
<board width="10mm" height="10mm" routingDisabled>
{grid({ rows: 4, cols: 4, xSpacing: 5, ySpacing: 5 }).map(
({ center, index }) => {
const ledName = `LED${index}`
const resistorName = `R${index}`
return (
<group key={ledName}>
<led
footprint="0603"
name={ledName}
pcbX={center.x}
pcbY={center.y}
/>
<resistor
resistance="1k"
footprint="0402"
name={resistorName}
pcbX={center.x}
pcbY={center.y - 2}
/>
<trace from={`.${ledName} .pos`} to="net.VDD" />
<trace from={`.${ledName} .neg`} to={`.${resistorName} .pos`} />
<trace from={`.${resistorName} .neg`} to="net.GND" />
</group>
)
},
)}
</board>
)
export const Benchmark1LedMatrix = ({
autorouter = undefined,
routingDisabled = undefined,
}: {
autorouter?: BoardProps["autorouter"]
routingDisabled?: boolean
}) => {
if (autorouter === undefined && routingDisabled === undefined) {
routingDisabled = true
}
return (
<board
width="50mm"
height="60mm"
routingDisabled={routingDisabled}
autorouter={autorouter}
>
<pinheader
name="J1"
pinCount={2}
pinLabels={["PWR", "GND"]}
footprint="pinrow2"
pcbY={28}
/>
<trace from={sel.J1.PWR} to={sel.net.PWR} />
<trace from={sel.J1.GND} to={sel.net.GND} />
{grid({ rows: 4, cols: 4, xSpacing: 10, ySpacing: 10 }).map(
({ center, index }) => {
const ledName = `LED${index}`
const resistorName = `R${index}`
return (
<group key={ledName}>
<led
footprint="0603"
color="red"
name={ledName}
pcbX={center.x}
pcbY={center.y}
/>
<resistor
resistance="1k"
footprint="0402"
name={resistorName}
pcbX={center.x}
pcbY={center.y - 2}
/>
<trace from={`.${ledName} .pos`} to={sel.net.PWR} />
<trace from={`.${ledName} .neg`} to={`.${resistorName} .pos`} />
<trace from={`.${resistorName} .neg`} to={sel.net.GND} />
</group>
)
},
)}
</board>
)
}
7 changes: 5 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"name": "@tscircuit/core",
"dependencies": {
"@lume/kiwi": "^0.4.3",
"@tscircuit/capacity-autorouter": "^0.0.12",
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
"@tscircuit/math-utils": "^0.0.9",
"@tscircuit/props": "^0.0.152",
"@tscircuit/schematic-autolayout": "^0.0.6",
"@tscircuit/soup-util": "^0.0.41",
"circuit-json": "^0.0.142",
"circuit-json": "^0.0.144",
"circuit-json-to-connectivity-map": "^0.0.17",
"format-si-unit": "^0.0.3",
"nanoid": "^5.0.7",
Expand Down Expand Up @@ -208,6 +209,8 @@

"@rollup/rollup-win32-x64-msvc": ["@rollup/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-U0FaE5O1BCpZSeE6gBl3c5ObhePQSfk9vDRToMmTkbhCOgW4jqvtS5LGyQ76L1fH8sM0keRp4uDTsbjiUyjk0g=="],

"@tscircuit/capacity-autorouter": ["@tscircuit/[email protected]", "", { "peerDependencies": { "typescript": "^5.7.3" } }, "sha512-K0rT4JlOo3vo4lRLP55hNvlLssbhF5qHWDyj2r3mGN9O91j5vdQJ4yTYJ9LZgGV1lZw2GjCoNZ27Gaz0FOXNEg=="],

"@tscircuit/core": ["@tscircuit/[email protected]", "", { "dependencies": { "@lume/kiwi": "^0.4.3", "@tscircuit/footprinter": "^0.0.135", "@tscircuit/infgrid-ijump-astar": "^0.0.33", "@tscircuit/math-utils": "^0.0.9", "@tscircuit/props": "^0.0.152", "@tscircuit/schematic-autolayout": "^0.0.6", "@tscircuit/soup-util": "^0.0.41", "circuit-json": "^0.0.139", "circuit-json-to-connectivity-map": "^0.0.17", "format-si-unit": "^0.0.3", "nanoid": "^5.0.7", "performance-now": "^2.1.0", "react-reconciler": "^0.31.0", "react-reconciler-18": "npm:[email protected]", "schematic-symbols": "^0.0.121", "transformation-matrix": "^2.16.1", "zod": "^3.23.8" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-rhnPwYyEQxkewis/7W+YC+mXwndras6fyFh3syHfaW5Z8zTC3njbXiGkFPWtExrWAV2+AG0g/uL6NfQ+eDCA8Q=="],

"@tscircuit/footprinter": ["@tscircuit/[email protected]", "", { "dependencies": { "@tscircuit/mm": "^0.0.8", "zod": "^3.23.8" }, "peerDependencies": { "circuit-json": "*" } }, "sha512-M7Tvbp8IAt1JpWRUZr2OS5rRMZxY0stk1frhR80CYQPsyWzwifh9pgdNKOqApCJ0MPmy4rmPey5BVGtAZ+gIDw=="],
Expand Down Expand Up @@ -358,7 +361,7 @@

"chownr": ["[email protected]", "", {}, "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="],

"circuit-json": ["[email protected].142", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-TE4fC91rGuul5oe73LNA3UC/2+LSwXH8qyEmf39Re+YNG5djo1klkm27ECGOzSboTC5XatS9uLNMUsLoFrPC0A=="],
"circuit-json": ["[email protected].144", "", { "dependencies": { "nanoid": "^5.0.7", "zod": "^3.23.6" } }, "sha512-XA0/EmY1nRTl3lrmBJkG9rUljYduVlsat6SiIWPz1h+x/rHzpr2NJYnDJabnC/HPApeie2JfXyd+wuAV/CoF6Q=="],

"circuit-json-to-connectivity-map": ["[email protected]", "", { "dependencies": { "@tscircuit/math-utils": "^0.0.4" }, "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-0IlFTwGWFXzlrYSvXQocXi6pYriF/JKnfihfvnVZ4p60kMC+1QvtJdivW9C4I0VNXEe922xak70v3YZNJrjI1g=="],

Expand Down
5 changes: 4 additions & 1 deletion lib/RootCircuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export type RootCircuitEventName =
| "renderable:renderLifecycle:anyEvent"
| `renderable:renderLifecycle:${RenderPhase}:start`
| `renderable:renderLifecycle:${RenderPhase}:end`
| "external:evalError"
| "external:evalError" // TODO remove
| "autorouting:start"
| "autorouting:end"
| "autorouting:progress"

export class RootCircuit {
firstChild: PrimitiveComponent | null = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ export class NormalComponent<
if (symbol) {
const schematic_component = db.schematic_component.insert({
center,
rotation: props.schRotation ?? 0,
size: symbol.size,
source_component_id: this.source_component_id!,

Expand Down
4 changes: 3 additions & 1 deletion lib/components/normal-components/PinHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class PinHeader extends NormalComponent<typeof pinHeaderProps> {
new Port({
name: `pin${i}`,
pinNumber: i,
aliases: [],
aliases: [this._parsedProps.pinLabels?.[i - 1]].filter(
Boolean,
) as string[],
}),
)
}
Expand Down
Loading

0 comments on commit 69565c5

Please sign in to comment.