@tscircuit/schematic-trace-solver 0.0.35 → 0.0.37
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 +3 -0
- package/dist/index.js +46 -14
- package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +13 -0
- package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver.ts +11 -1
- package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/geometry.ts +13 -3
- package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/solvePortOnlyPin.ts +10 -2
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +15 -3
- package/lib/types/InputProblem.ts +1 -0
- package/package.json +1 -1
- package/site/examples/example21.page.tsx +177 -0
- package/tests/examples/__snapshots__/example20.snap.svg +235 -0
- package/tests/examples/__snapshots__/example21.snap.svg +272 -0
- package/tests/examples/example20.test.tsx +190 -0
- package/tests/examples/example21.test.tsx +183 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2,
|
|
15
|
+
height: 1.4,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "U3.8",
|
|
19
|
+
x: -1.4,
|
|
20
|
+
y: 0.42500000000000004,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "U3.4",
|
|
24
|
+
x: -1.4,
|
|
25
|
+
y: -0.42500000000000004,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "U3.1",
|
|
29
|
+
x: 1.4,
|
|
30
|
+
y: 0.5,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "U3.6",
|
|
34
|
+
x: 1.4,
|
|
35
|
+
y: 0.30000000000000004,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pinId: "U3.5",
|
|
39
|
+
x: 1.4,
|
|
40
|
+
y: 0.10000000000000009,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
pinId: "U3.2",
|
|
44
|
+
x: 1.4,
|
|
45
|
+
y: -0.09999999999999998,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pinId: "U3.3",
|
|
49
|
+
x: 1.4,
|
|
50
|
+
y: -0.3,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pinId: "U3.7",
|
|
54
|
+
x: 1.4,
|
|
55
|
+
y: -0.5,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_1",
|
|
61
|
+
center: {
|
|
62
|
+
x: -2.3145833,
|
|
63
|
+
y: 0,
|
|
64
|
+
},
|
|
65
|
+
width: 0.5291665999999999,
|
|
66
|
+
height: 1.0583333000000001,
|
|
67
|
+
pins: [
|
|
68
|
+
{
|
|
69
|
+
pinId: "C20.1",
|
|
70
|
+
x: -2.3148566499999994,
|
|
71
|
+
y: 0.5512093000000002,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "C20.2",
|
|
75
|
+
x: -2.31430995,
|
|
76
|
+
y: -0.5512093000000002,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
chipId: "schematic_component_2",
|
|
82
|
+
center: {
|
|
83
|
+
x: 1.7577928249999983,
|
|
84
|
+
y: 1.7512907000000002,
|
|
85
|
+
},
|
|
86
|
+
width: 0.3155856499999966,
|
|
87
|
+
height: 1.0583332999999997,
|
|
88
|
+
pins: [
|
|
89
|
+
{
|
|
90
|
+
pinId: "R11.1",
|
|
91
|
+
x: 1.7580660749999977,
|
|
92
|
+
y: 2.3025814000000002,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
pinId: "R11.2",
|
|
96
|
+
x: 1.757519574999999,
|
|
97
|
+
y: 1.2,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
chipId: "schematic_component_3",
|
|
103
|
+
center: {
|
|
104
|
+
x: -1.7577928249999983,
|
|
105
|
+
y: -2.7512907000000002,
|
|
106
|
+
},
|
|
107
|
+
width: 0.3155856499999966,
|
|
108
|
+
height: 1.0583332999999997,
|
|
109
|
+
pins: [
|
|
110
|
+
{
|
|
111
|
+
pinId: "R12.1",
|
|
112
|
+
x: -1.7580660749999977,
|
|
113
|
+
y: -3.3025814000000002,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
pinId: "R12.2",
|
|
117
|
+
x: -1.757519574999999,
|
|
118
|
+
y: -2.2,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
chipId: "schematic_component_4",
|
|
124
|
+
center: {
|
|
125
|
+
x: 1.7577928249999983,
|
|
126
|
+
y: -2.7512907000000002,
|
|
127
|
+
},
|
|
128
|
+
width: 0.3155856499999966,
|
|
129
|
+
height: 1.0583332999999997,
|
|
130
|
+
pins: [
|
|
131
|
+
{
|
|
132
|
+
pinId: "R13.1",
|
|
133
|
+
x: 1.7580660749999977,
|
|
134
|
+
y: -3.3025814000000002,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
pinId: "R13.2",
|
|
138
|
+
x: 1.757519574999999,
|
|
139
|
+
y: -2.2,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
directConnections: [
|
|
145
|
+
{
|
|
146
|
+
pinIds: ["C20.1", "U3.8"],
|
|
147
|
+
netId: "capacitor.C20 > port.pin1 to .U3 > .VDD",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
pinIds: ["C20.2", "U3.4"],
|
|
151
|
+
netId: "capacitor.C20 > port.pin2 to .U3 > .GND",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
pinIds: ["R11.2", "U3.1"],
|
|
155
|
+
netId: "resistor.R11 > port.pin2 to .U3 > .N_CS",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
pinIds: ["R13.2", "R12.2"],
|
|
159
|
+
netId: "resistor.R11 > port.pin1 to resistor.R12 > port.pin1",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
netConnections: [
|
|
163
|
+
{
|
|
164
|
+
netId: "V3_3",
|
|
165
|
+
pinIds: ["U3.8", "U3.3", "U3.7", "C20.1", "R11.1"],
|
|
166
|
+
netLabelWidth: 1,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
netId: "GND",
|
|
170
|
+
pinIds: ["U3.4", "C20.2"],
|
|
171
|
+
netLabelWidth: 0.8,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
netId: "FLASH_N_CS",
|
|
175
|
+
pinIds: ["U3.1", "R11.2"],
|
|
176
|
+
netLabelWidth: 0.1,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
availableNetLabelOrientations: {
|
|
180
|
+
V3_3: ["y+"],
|
|
181
|
+
GND: ["y-"],
|
|
182
|
+
},
|
|
183
|
+
maxMspPairDistance: 5,
|
|
184
|
+
} as InputProblem
|
|
185
|
+
|
|
186
|
+
test("example20", () => {
|
|
187
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
188
|
+
solver.solve()
|
|
189
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
190
|
+
})
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2,
|
|
15
|
+
height: 2,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "CORNERS.1",
|
|
19
|
+
x: -1.4,
|
|
20
|
+
y: -0.6,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "CORNERS.2",
|
|
24
|
+
x: -1.4,
|
|
25
|
+
y: 0.6,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "CORNERS.3",
|
|
29
|
+
x: 1.4,
|
|
30
|
+
y: 0.6,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "CORNERS.4",
|
|
34
|
+
x: 1.4,
|
|
35
|
+
y: -0.6,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
chipId: "schematic_component_1",
|
|
41
|
+
center: {
|
|
42
|
+
x: 4.785,
|
|
43
|
+
y: -0.3999999999999999,
|
|
44
|
+
},
|
|
45
|
+
width: 1.2000000000000002,
|
|
46
|
+
height: 1,
|
|
47
|
+
pins: [
|
|
48
|
+
{
|
|
49
|
+
pinId: "U100.1",
|
|
50
|
+
x: 3.785,
|
|
51
|
+
y: -0.29999999999999993,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
pinId: "U100.2",
|
|
55
|
+
x: 4.785,
|
|
56
|
+
y: -1.2999999999999998,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
pinId: "U100.3",
|
|
60
|
+
x: 3.785,
|
|
61
|
+
y: -0.4999999999999999,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
pinId: "U100.5",
|
|
65
|
+
x: 5.785,
|
|
66
|
+
y: -0.3999999999999999,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
chipId: "schematic_component_2",
|
|
72
|
+
center: {
|
|
73
|
+
x: 6.7,
|
|
74
|
+
y: -0.9499999999999993,
|
|
75
|
+
},
|
|
76
|
+
width: 0.53,
|
|
77
|
+
height: 1.06,
|
|
78
|
+
pins: [
|
|
79
|
+
{
|
|
80
|
+
pinId: "C101.1",
|
|
81
|
+
x: 6.7,
|
|
82
|
+
y: -0.39999999999999925,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
pinId: "C101.2",
|
|
86
|
+
x: 6.7,
|
|
87
|
+
y: -1.4999999999999993,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
chipId: "schematic_component_3",
|
|
93
|
+
center: {
|
|
94
|
+
x: 2.8699999999999997,
|
|
95
|
+
y: -1.75,
|
|
96
|
+
},
|
|
97
|
+
width: 0.53,
|
|
98
|
+
height: 1.06,
|
|
99
|
+
pins: [
|
|
100
|
+
{
|
|
101
|
+
pinId: "C100.1",
|
|
102
|
+
x: 2.8699999999999997,
|
|
103
|
+
y: -1.2,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
pinId: "C100.2",
|
|
107
|
+
x: 2.8699999999999997,
|
|
108
|
+
y: -2.3,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
chipId: "schematic_component_4",
|
|
114
|
+
center: {
|
|
115
|
+
x: 2.9752723250000006,
|
|
116
|
+
y: 0.050000000000000266,
|
|
117
|
+
},
|
|
118
|
+
width: 0.3194553499999995,
|
|
119
|
+
height: 1.06,
|
|
120
|
+
pins: [
|
|
121
|
+
{
|
|
122
|
+
pinId: "R100.1",
|
|
123
|
+
x: 2.9752723250000006,
|
|
124
|
+
y: 0.6000000000000001,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
pinId: "R100.2",
|
|
128
|
+
x: 2.9752723250000006,
|
|
129
|
+
y: -0.4999999999999998,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
directConnections: [
|
|
135
|
+
{
|
|
136
|
+
pinIds: ["C101.1", "U100.5"],
|
|
137
|
+
netId: "group > capacitor.C101 > port.pin1 to U100.VOUT",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
pinIds: ["C100.1", "U100.1"],
|
|
141
|
+
netId: "group > capacitor.C100 > port.pin1 to U100.VIN",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
pinIds: ["R100.2", "U100.3"],
|
|
145
|
+
netId: "group > resistor.R100 > port.pin2 to U100.EN",
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
netConnections: [
|
|
149
|
+
{
|
|
150
|
+
netId: "GND",
|
|
151
|
+
pinIds: ["CORNERS.1", "CORNERS.4", "U100.2", "C101.2", "C100.2"],
|
|
152
|
+
netLabelWidth: 0.3,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
netId: "VIN",
|
|
156
|
+
pinIds: ["CORNERS.2", "U100.1", "C100.1", "R100.1"],
|
|
157
|
+
netLabelWidth: 0.3,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
netId: "VOUT",
|
|
161
|
+
pinIds: ["CORNERS.3", "U100.5", "C101.1"],
|
|
162
|
+
netLabelWidth: 0.4,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
netId: "LDO_EN",
|
|
166
|
+
pinIds: ["U100.3", "R100.2"],
|
|
167
|
+
netLabelWidth: 0.6,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
availableNetLabelOrientations: {
|
|
171
|
+
GND: ["y-"],
|
|
172
|
+
VIN: ["y+"],
|
|
173
|
+
VOUT: ["y+"],
|
|
174
|
+
LDO_EN: ["x-", "x+"],
|
|
175
|
+
},
|
|
176
|
+
maxMspPairDistance: 2.4,
|
|
177
|
+
} as InputProblem
|
|
178
|
+
|
|
179
|
+
test("example21", () => {
|
|
180
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
181
|
+
solver.solve()
|
|
182
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
183
|
+
})
|