@tscircuit/schematic-trace-solver 0.0.146 → 0.0.147
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 +7 -2
- package/dist/index.js +96 -74
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +38 -30
- package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +6 -21
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +7 -23
- package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/candidates.ts +7 -14
- package/lib/types/InputProblem.ts +8 -0
- package/lib/utils/getNetLabelWidthForConnection.ts +63 -0
- package/package.json +1 -1
- package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +80 -0
- package/tests/repros/repro-ti-power-output-section.input.ts +341 -0
- package/tests/repros/repro-ti-power-output-section.test.ts +13 -0
- package/tests/solvers/InlineNetLabelSolver/__snapshots__/fallback-net-label-width.snap.svg +69 -0
- package/tests/solvers/InlineNetLabelSolver/fallback-net-label-width.test.ts +152 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import type {
|
|
4
|
+
InputDirectConnection,
|
|
5
|
+
InputProblem,
|
|
6
|
+
} from "lib/types/InputProblem"
|
|
7
|
+
import "tests/fixtures/matcher"
|
|
8
|
+
|
|
9
|
+
const inlineConnection = (
|
|
10
|
+
netId: string,
|
|
11
|
+
pinIds: [string, string],
|
|
12
|
+
fallbackNetLabelWidth: number,
|
|
13
|
+
inlineNetLabelWidth: number,
|
|
14
|
+
): InputDirectConnection => ({
|
|
15
|
+
netId,
|
|
16
|
+
pinIds,
|
|
17
|
+
allowInlineNetLabel: true,
|
|
18
|
+
fallbackNetLabelWidth,
|
|
19
|
+
inlineNetLabelWidth,
|
|
20
|
+
inlineNetLabelHeight: 0.12,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const routedInputProblem: InputProblem = {
|
|
24
|
+
chips: [
|
|
25
|
+
{
|
|
26
|
+
chipId: "U1",
|
|
27
|
+
center: { x: 0, y: 0 },
|
|
28
|
+
width: 3.29,
|
|
29
|
+
height: 6.35,
|
|
30
|
+
sectionId: "driver",
|
|
31
|
+
pins: [
|
|
32
|
+
{ pinId: "U1.4", x: 2.045, y: 2.6, _facingDirection: "x+" },
|
|
33
|
+
{ pinId: "U1.6", x: 2.045, y: 2.4, _facingDirection: "x+" },
|
|
34
|
+
{ pinId: "U1.7", x: 2.045, y: 2.2, _facingDirection: "x+" },
|
|
35
|
+
{ pinId: "U1.9", x: 2.045, y: 2, _facingDirection: "x+" },
|
|
36
|
+
{ pinId: "U1.48", x: 2.045, y: 0.7, _facingDirection: "x+" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
chipId: "J4",
|
|
41
|
+
center: { x: 7, y: -0.4 },
|
|
42
|
+
width: 2.05,
|
|
43
|
+
height: 4,
|
|
44
|
+
sectionId: "driver",
|
|
45
|
+
pins: [
|
|
46
|
+
{ pinId: "J4.1", x: 5.575, y: 1.4, _facingDirection: "x-" },
|
|
47
|
+
{ pinId: "J4.2", x: 5.575, y: 1.2, _facingDirection: "x-" },
|
|
48
|
+
{ pinId: "J4.3", x: 5.575, y: 1, _facingDirection: "x-" },
|
|
49
|
+
{ pinId: "J4.4", x: 5.575, y: 0.8, _facingDirection: "x-" },
|
|
50
|
+
{ pinId: "J4.5", x: 5.575, y: 0.6, _facingDirection: "x-" },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
directConnections: [
|
|
55
|
+
inlineConnection("OUT_A_P", ["J4.1", "U1.4"], 0.96, 0.64),
|
|
56
|
+
inlineConnection("OUT_A_N", ["J4.2", "U1.6"], 0.96, 0.64),
|
|
57
|
+
inlineConnection("OUT_B_N", ["J4.3", "U1.7"], 0.96, 0.64),
|
|
58
|
+
inlineConnection("OUT_B_P", ["J4.4", "U1.9"], 0.96, 0.64),
|
|
59
|
+
inlineConnection("SERIAL_IN", ["J4.5", "U1.48"], 1.2, 0.8),
|
|
60
|
+
],
|
|
61
|
+
netConnections: [],
|
|
62
|
+
textBoxes: [
|
|
63
|
+
{
|
|
64
|
+
chipId: "U1",
|
|
65
|
+
center: { x: 2.405, y: 3.525 },
|
|
66
|
+
width: 1.32,
|
|
67
|
+
height: 0.18,
|
|
68
|
+
text: "TB67S579FTG",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
chipId: "U1",
|
|
72
|
+
center: { x: 1.865, y: 3.29 },
|
|
73
|
+
width: 0.36,
|
|
74
|
+
height: 0.25,
|
|
75
|
+
text: "U1",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
chipId: "J4",
|
|
79
|
+
center: { x: 6.095, y: 1.715 },
|
|
80
|
+
width: 0.36,
|
|
81
|
+
height: 0.25,
|
|
82
|
+
text: "J4",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
availableNetLabelOrientations: {},
|
|
86
|
+
maxMspPairDistance: 20,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
test("fallback label width does not split routable inline connections", () => {
|
|
90
|
+
const solver = new SchematicTracePipelineSolver(routedInputProblem)
|
|
91
|
+
|
|
92
|
+
solver.solve()
|
|
93
|
+
|
|
94
|
+
expect(solver.schematicTraceLinesSolver!.solvedTracePaths).toHaveLength(5)
|
|
95
|
+
expect(solver.schematicTraceLinesSolver!.failedConnectionPairs).toHaveLength(
|
|
96
|
+
0,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const output = solver.inlineNetLabelSolver!.getOutput()
|
|
100
|
+
expect(output.traces).toHaveLength(5)
|
|
101
|
+
expect(output.inlineNetLabelPlacements).toHaveLength(5)
|
|
102
|
+
expect(
|
|
103
|
+
output.inlineNetLabelPlacements.every(
|
|
104
|
+
(placement) => placement.stubTracePath === undefined,
|
|
105
|
+
),
|
|
106
|
+
).toBe(true)
|
|
107
|
+
|
|
108
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
test("fallback label width sizes anchored labels when routing is skipped", () => {
|
|
112
|
+
const inputProblem: InputProblem = {
|
|
113
|
+
chips: [
|
|
114
|
+
{
|
|
115
|
+
chipId: "U1",
|
|
116
|
+
center: { x: -3, y: 0 },
|
|
117
|
+
width: 1,
|
|
118
|
+
height: 1,
|
|
119
|
+
pins: [{ pinId: "U1.1", x: -2.5, y: 0, _facingDirection: "x+" }],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
chipId: "U2",
|
|
123
|
+
center: { x: 3, y: 0 },
|
|
124
|
+
width: 1,
|
|
125
|
+
height: 1,
|
|
126
|
+
pins: [{ pinId: "U2.1", x: 2.5, y: 0, _facingDirection: "x-" }],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
directConnections: [
|
|
130
|
+
{
|
|
131
|
+
netId: "SIGNAL",
|
|
132
|
+
pinIds: ["U1.1", "U2.1"],
|
|
133
|
+
allowInlineNetLabel: true,
|
|
134
|
+
fallbackNetLabelWidth: 0.96,
|
|
135
|
+
inlineNetLabelWidth: 0.64,
|
|
136
|
+
inlineNetLabelHeight: 0.12,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
netConnections: [],
|
|
140
|
+
availableNetLabelOrientations: {},
|
|
141
|
+
maxMspPairDistance: 1,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
145
|
+
solver.solve()
|
|
146
|
+
|
|
147
|
+
const [fallbackPlacement] = solver.netLabelPlacementSolver!.netLabelPlacements
|
|
148
|
+
expect(fallbackPlacement).toBeDefined()
|
|
149
|
+
expect(Math.max(fallbackPlacement!.width, fallbackPlacement!.height)).toBe(
|
|
150
|
+
0.96,
|
|
151
|
+
)
|
|
152
|
+
})
|