@tscircuit/schematic-trace-solver 0.0.156 → 0.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -2
- package/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts +10 -2
- package/package.json +1 -1
- package/site/components/PipelineDebugger.tsx +4 -2
- package/site/examples/example51.page.tsx +3 -1
- package/tests/bug-reports/bug-report-20260825T045913Z/__snapshots__/bug-report-20260825T045913Z.snap.svg +2 -2
- package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +71 -80
- package/tests/repros/__snapshots__/repro-dc-power-isolated-routing.snap.svg +129 -0
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +1290 -0
- package/tests/repros/__snapshots__/repro-tida00553-j4-cell-divider.snap.svg +130 -0
- package/tests/repros/__snapshots__/repro-usb-power-vbus-label-detour.snap.svg +10 -10
- package/tests/repros/assets/repro-dc-power-isolated-routing.input.json +193 -0
- package/tests/repros/assets/repro-pmp11282-isolated-dcdc.input.json +4570 -0
- package/tests/repros/board-1273-trace-overlap-cycle.test.ts +1 -1
- package/tests/repros/repro-dc-power-isolated-routing.test.ts +13 -0
- package/tests/repros/repro-pmp11282-isolated-dcdc.test.ts +77 -0
- package/tests/repros/repro-tida00553-j4-cell-divider.test.ts +111 -0
|
@@ -24,7 +24,7 @@ test("board 1273 solves within the trace overlap iteration limit", async () => {
|
|
|
24
24
|
|
|
25
25
|
expect(solver.solved).toBe(true)
|
|
26
26
|
expect(solver.failed).toBe(false)
|
|
27
|
-
expect(solver.traceOverlapShiftSolver?.iterations).toBe(
|
|
27
|
+
expect(solver.traceOverlapShiftSolver?.iterations).toBe(27)
|
|
28
28
|
expect(solver.postLabelTraceOverlapShiftSolver?.iterations).toBe(1)
|
|
29
29
|
await expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
30
30
|
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import "tests/fixtures/matcher"
|
|
4
|
+
import inputProblem from "./assets/repro-dc-power-isolated-routing.input.json"
|
|
5
|
+
|
|
6
|
+
test("isolated DC power regulator trace routing", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
8
|
+
|
|
9
|
+
solver.solve()
|
|
10
|
+
|
|
11
|
+
expect(solver.failed).toBe(false)
|
|
12
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
13
|
+
})
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { MspConnectionPairSolver } from "lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver"
|
|
3
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
4
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
5
|
+
import "tests/fixtures/matcher"
|
|
6
|
+
import inputProblemJson from "./assets/repro-pmp11282-isolated-dcdc.input.json"
|
|
7
|
+
|
|
8
|
+
const cloneInputProblem = (): InputProblem =>
|
|
9
|
+
JSON.parse(JSON.stringify(inputProblemJson))
|
|
10
|
+
|
|
11
|
+
test("repro PMP11282 isolated DC/DC traces and endpoint net labels", () => {
|
|
12
|
+
const inputProblem = cloneInputProblem()
|
|
13
|
+
const pairSolver = new MspConnectionPairSolver({ inputProblem })
|
|
14
|
+
|
|
15
|
+
pairSolver.solve()
|
|
16
|
+
|
|
17
|
+
const uniquePairIds = new Set(
|
|
18
|
+
pairSolver.mspConnectionPairs.map((pair) => pair.mspPairId),
|
|
19
|
+
)
|
|
20
|
+
expect(inputProblem.chips).toHaveLength(112)
|
|
21
|
+
expect(inputProblem.directConnections).toHaveLength(163)
|
|
22
|
+
expect(pairSolver.solved).toBe(true)
|
|
23
|
+
expect(pairSolver.mspConnectionPairs).toHaveLength(203)
|
|
24
|
+
expect(uniquePairIds.size).toBe(203)
|
|
25
|
+
|
|
26
|
+
const defaultPipeline = new SchematicTracePipelineSolver(
|
|
27
|
+
cloneInputProblem(),
|
|
28
|
+
{ hideRatsNet: true },
|
|
29
|
+
)
|
|
30
|
+
defaultPipeline.solve()
|
|
31
|
+
|
|
32
|
+
const defaultTraceSolver = defaultPipeline.schematicTraceLinesSolver!
|
|
33
|
+
expect(defaultPipeline.solved).toBe(false)
|
|
34
|
+
expect(defaultPipeline.failed).toBe(true)
|
|
35
|
+
expect(defaultPipeline.error).toBe(
|
|
36
|
+
"SchematicTraceLinesSolver ran out of iterations",
|
|
37
|
+
)
|
|
38
|
+
expect(defaultTraceSolver.solvedTracePaths).toHaveLength(72)
|
|
39
|
+
expect(defaultTraceSolver.failedConnectionPairs).toHaveLength(35)
|
|
40
|
+
expect(defaultTraceSolver.queuedConnectionPairs).toHaveLength(95)
|
|
41
|
+
|
|
42
|
+
// Let the same unmodified production pipeline reach its downstream stages
|
|
43
|
+
// by increasing only this test instance's nested-solver budget. This keeps
|
|
44
|
+
// the reproduction production-code-free while exposing the resulting labels.
|
|
45
|
+
const diagnosticPipeline = new SchematicTracePipelineSolver(
|
|
46
|
+
cloneInputProblem(),
|
|
47
|
+
{ hideRatsNet: true },
|
|
48
|
+
)
|
|
49
|
+
diagnosticPipeline.solveUntilPhase("schematicTraceLinesSolver")
|
|
50
|
+
diagnosticPipeline.step()
|
|
51
|
+
diagnosticPipeline.schematicTraceLinesSolver!.MAX_ITERATIONS *=
|
|
52
|
+
diagnosticPipeline.mspConnectionPairSolver!.mspConnectionPairs.length
|
|
53
|
+
diagnosticPipeline.solve()
|
|
54
|
+
|
|
55
|
+
const finalOutput = diagnosticPipeline.inlineNetLabelSolver!.getOutput()
|
|
56
|
+
const endpointPairLabels = finalOutput.netLabelPlacements.filter((label) =>
|
|
57
|
+
label.netId?.includes(" to "),
|
|
58
|
+
)
|
|
59
|
+
const endpointPairNetIds = new Set(
|
|
60
|
+
endpointPairLabels.map((label) => label.netId!),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
expect(diagnosticPipeline.solved).toBe(true)
|
|
64
|
+
expect(diagnosticPipeline.failed).toBe(false)
|
|
65
|
+
expect(
|
|
66
|
+
diagnosticPipeline.schematicTraceLinesSolver!.solvedTracePaths,
|
|
67
|
+
).toHaveLength(145)
|
|
68
|
+
expect(
|
|
69
|
+
diagnosticPipeline.schematicTraceLinesSolver!.failedConnectionPairs,
|
|
70
|
+
).toHaveLength(58)
|
|
71
|
+
expect(finalOutput.netLabelPlacements).toHaveLength(106)
|
|
72
|
+
expect(endpointPairLabels).toHaveLength(80)
|
|
73
|
+
expect(endpointPairNetIds.size).toBe(62)
|
|
74
|
+
expect(endpointPairNetIds).toContain("U500.pin8 to C501.pin1")
|
|
75
|
+
expect(endpointPairNetIds).toContain("L500.pin1 to L500.pin2")
|
|
76
|
+
expect(diagnosticPipeline).toMatchSolverSnapshot(import.meta.path)
|
|
77
|
+
}, 30_000)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const horizontalResistor = (name: string, x: number) => ({
|
|
7
|
+
chipId: name,
|
|
8
|
+
center: { x, y: 2 },
|
|
9
|
+
width: 0.72,
|
|
10
|
+
height: 0.68,
|
|
11
|
+
pins: [
|
|
12
|
+
{
|
|
13
|
+
pinId: `${name}.1`,
|
|
14
|
+
displayName: "1",
|
|
15
|
+
x: x - 0.36,
|
|
16
|
+
y: 2,
|
|
17
|
+
_facingDirection: "x-" as const,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
pinId: `${name}.2`,
|
|
21
|
+
displayName: "2",
|
|
22
|
+
x: x + 0.36,
|
|
23
|
+
y: 2,
|
|
24
|
+
_facingDirection: "x+" as const,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Isolated from the TIDA-00553 battery-pack cell-count selector. R26-R29
|
|
30
|
+
// form the VFB divider, J4 pins 1/3/5 tap its intermediate nodes, and J4 pins
|
|
31
|
+
// 2/4/6 share the ground end of the divider.
|
|
32
|
+
const inputProblem: InputProblem = {
|
|
33
|
+
chips: [
|
|
34
|
+
horizontalResistor("R26", 7.2),
|
|
35
|
+
horizontalResistor("R27", 8.2),
|
|
36
|
+
horizontalResistor("R28", 9.2),
|
|
37
|
+
horizontalResistor("R29", 10.2),
|
|
38
|
+
{
|
|
39
|
+
chipId: "J4",
|
|
40
|
+
center: { x: 10.4, y: 0.6 },
|
|
41
|
+
width: 1.6,
|
|
42
|
+
height: 0.8,
|
|
43
|
+
pins: [
|
|
44
|
+
{ pinId: "J4.1", displayName: "1", x: 9.6, y: 0.8 },
|
|
45
|
+
{ pinId: "J4.2", displayName: "2", x: 11.2, y: 0.8 },
|
|
46
|
+
{ pinId: "J4.3", displayName: "3", x: 9.6, y: 0.6 },
|
|
47
|
+
{ pinId: "J4.4", displayName: "4", x: 11.2, y: 0.6 },
|
|
48
|
+
{ pinId: "J4.5", displayName: "5", x: 9.6, y: 0.4 },
|
|
49
|
+
{ pinId: "J4.6", displayName: "6", x: 11.2, y: 0.4 },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
directConnections: [
|
|
54
|
+
{
|
|
55
|
+
netId: "4-Cell/J4-R26",
|
|
56
|
+
netLabelText: "J4_5",
|
|
57
|
+
netLabelWidth: 0.6,
|
|
58
|
+
pinIds: ["J4.5", "R26.2"],
|
|
59
|
+
},
|
|
60
|
+
{ netId: "4-Cell/J4-R27", pinIds: ["J4.5", "R27.1"] },
|
|
61
|
+
{ netId: "3-Cell/J4-R27", pinIds: ["J4.3", "R27.2"] },
|
|
62
|
+
{ netId: "3-Cell/J4-R28", pinIds: ["J4.3", "R28.1"] },
|
|
63
|
+
{ netId: "2-Cell/J4-R28", pinIds: ["J4.1", "R28.2"] },
|
|
64
|
+
{ netId: "2-Cell/J4-R29", pinIds: ["J4.1", "R29.1"] },
|
|
65
|
+
],
|
|
66
|
+
netConnections: [
|
|
67
|
+
{
|
|
68
|
+
netId: "U2_VFB",
|
|
69
|
+
netLabelText: "U2_VFB",
|
|
70
|
+
netLabelWidth: 1.12,
|
|
71
|
+
pinIds: ["R26.1"],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
netId: "GND",
|
|
75
|
+
netLabelText: "GND",
|
|
76
|
+
netLabelWidth: 0.42,
|
|
77
|
+
netLabelHeight: 0.48,
|
|
78
|
+
pinIds: ["R29.2", "J4.2", "J4.4", "J4.6"],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
textBoxes: [
|
|
82
|
+
{
|
|
83
|
+
chipId: "J4",
|
|
84
|
+
center: { x: 10.12, y: 0.07 },
|
|
85
|
+
width: 0.24,
|
|
86
|
+
height: 0.18,
|
|
87
|
+
text: "J4",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
chipId: "J4",
|
|
91
|
+
center: { x: 10.12, y: 1.115 },
|
|
92
|
+
width: 0.36,
|
|
93
|
+
height: 0.25,
|
|
94
|
+
text: "J4",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
availableNetLabelOrientations: {
|
|
98
|
+
U2_VFB: ["x-"],
|
|
99
|
+
"4-Cell/J4-R26": ["x-"],
|
|
100
|
+
"4-Cell/J4-R27": ["x-"],
|
|
101
|
+
GND: ["y-"],
|
|
102
|
+
},
|
|
103
|
+
maxMspPairDistance: 2.4,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
test("repro TIDA-00553 J4 cell divider routing", () => {
|
|
107
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
108
|
+
|
|
109
|
+
solver.solve()
|
|
110
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
111
|
+
})
|