multisim2kicad 0.0.0 → 0.1.0
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/LICENSE +15 -0
- package/README.md +126 -1
- package/dist/cli.js +3755 -0
- package/dist/db/ewdb.d.ts +19 -0
- package/dist/db/symbols.d.ts +33 -0
- package/dist/emit/footprint-lib.d.ts +35 -0
- package/dist/emit/kicad-pcb.d.ts +34 -0
- package/dist/emit/kicad-pro.d.ts +18 -0
- package/dist/emit/kicad-sch.d.ts +59 -0
- package/dist/emit/pcb-layers.d.ts +40 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +3791 -0
- package/dist/ir/types.d.ts +391 -0
- package/dist/load.d.ts +18 -0
- package/dist/main.d.ts +38 -0
- package/dist/parse/doc.d.ts +18 -0
- package/dist/parse/ms-hierarchy.d.ts +75 -0
- package/dist/parse/pcb.d.ts +9 -0
- package/dist/parse/sch.d.ts +38 -0
- package/dist/parse/ub-geom.d.ts +38 -0
- package/dist/ref/ci-netlist.d.ts +71 -0
- package/package.json +58 -3
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
export interface Source {
|
|
2
|
+
application: string;
|
|
3
|
+
versionMajor: number;
|
|
4
|
+
versionMinor: number;
|
|
5
|
+
schema: number;
|
|
6
|
+
}
|
|
7
|
+
export interface EwLayer {
|
|
8
|
+
number: number;
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
state: number;
|
|
12
|
+
rgb: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Point {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}
|
|
18
|
+
export type Shape = {
|
|
19
|
+
kind: "polyline";
|
|
20
|
+
layer: number;
|
|
21
|
+
thickness: number;
|
|
22
|
+
points: Point[];
|
|
23
|
+
} | {
|
|
24
|
+
kind: "rectangle";
|
|
25
|
+
layer: number;
|
|
26
|
+
thickness: number;
|
|
27
|
+
points: Point[];
|
|
28
|
+
} | {
|
|
29
|
+
kind: "roundRect";
|
|
30
|
+
layer: number;
|
|
31
|
+
thickness: number;
|
|
32
|
+
points: Point[];
|
|
33
|
+
radius: number;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "ellipse";
|
|
36
|
+
layer: number;
|
|
37
|
+
thickness: number;
|
|
38
|
+
points: Point[];
|
|
39
|
+
} | {
|
|
40
|
+
kind: "arc";
|
|
41
|
+
layer: number;
|
|
42
|
+
thickness: number;
|
|
43
|
+
start: Point;
|
|
44
|
+
end: Point;
|
|
45
|
+
center: Point;
|
|
46
|
+
};
|
|
47
|
+
export interface Track {
|
|
48
|
+
layer: number;
|
|
49
|
+
thickness: number;
|
|
50
|
+
start: Point;
|
|
51
|
+
end: Point;
|
|
52
|
+
}
|
|
53
|
+
export type PadPrimitive = {
|
|
54
|
+
kind: "poly";
|
|
55
|
+
points: Point[];
|
|
56
|
+
} | {
|
|
57
|
+
kind: "arc";
|
|
58
|
+
center: Point;
|
|
59
|
+
start: Point;
|
|
60
|
+
end: Point;
|
|
61
|
+
width: number;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "circle";
|
|
64
|
+
center: Point;
|
|
65
|
+
radius: number;
|
|
66
|
+
width: number;
|
|
67
|
+
fill: boolean;
|
|
68
|
+
};
|
|
69
|
+
export type PadShape = {
|
|
70
|
+
kind: "circle";
|
|
71
|
+
diameter: number;
|
|
72
|
+
} | {
|
|
73
|
+
kind: "rect";
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
} | {
|
|
77
|
+
kind: "roundrect";
|
|
78
|
+
width: number;
|
|
79
|
+
height: number;
|
|
80
|
+
cornerRadius: number;
|
|
81
|
+
} | {
|
|
82
|
+
kind: "custom";
|
|
83
|
+
primitives: PadPrimitive[];
|
|
84
|
+
};
|
|
85
|
+
export interface Pad {
|
|
86
|
+
number: string;
|
|
87
|
+
at: Point;
|
|
88
|
+
rotation: number;
|
|
89
|
+
shape: PadShape;
|
|
90
|
+
drillDiameter: number;
|
|
91
|
+
side: "both" | "top" | "bottom";
|
|
92
|
+
}
|
|
93
|
+
export interface Component {
|
|
94
|
+
reference: string;
|
|
95
|
+
value: string;
|
|
96
|
+
name: string;
|
|
97
|
+
origin: Point;
|
|
98
|
+
/**
|
|
99
|
+
* Millionths of a degree, CCW. Pads and graphics are stored already placed
|
|
100
|
+
* (absolute). Top: placed = origin + R(rotation) * local. Bottom: placed =
|
|
101
|
+
* origin + R(-rotation) * mirrorX(local), from a corpus survey of parts
|
|
102
|
+
* used on both sides (plans/converter.md, C6).
|
|
103
|
+
*/
|
|
104
|
+
rotation: number;
|
|
105
|
+
bottom: boolean;
|
|
106
|
+
pads: Pad[];
|
|
107
|
+
/** Silk / fab / courtyard / 3D outline graphics owned by the part, absolute. */
|
|
108
|
+
graphics: Shape[];
|
|
109
|
+
/** The part's text attributes that KiCad can show (REFDES, VALUE, visible labels). */
|
|
110
|
+
texts: ComponentText[];
|
|
111
|
+
}
|
|
112
|
+
/** A component text attribute; `tag` is EW's attribute name (REFDES, VALUE, ...). */
|
|
113
|
+
export interface ComponentText extends BoardText {
|
|
114
|
+
tag: string;
|
|
115
|
+
visible: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface Via {
|
|
118
|
+
at: Point;
|
|
119
|
+
drillDiameter: number;
|
|
120
|
+
diameter: number;
|
|
121
|
+
netName?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface Hole {
|
|
124
|
+
at: Point;
|
|
125
|
+
drillDiameter: number;
|
|
126
|
+
plated: boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface NetPinRef {
|
|
129
|
+
refdes: string;
|
|
130
|
+
pin: string;
|
|
131
|
+
}
|
|
132
|
+
export interface Net {
|
|
133
|
+
name: string;
|
|
134
|
+
pins: NetPinRef[];
|
|
135
|
+
/** Ultiboard per-net rules (nm); absent = the board default. */
|
|
136
|
+
clearance?: number;
|
|
137
|
+
trackWidth?: number;
|
|
138
|
+
}
|
|
139
|
+
/** Ultiboard board-wide design rules (nm). */
|
|
140
|
+
export interface DesignRules {
|
|
141
|
+
/** Clearance from any copper to a trace / pad / via / copper area. */
|
|
142
|
+
clearance: {
|
|
143
|
+
trace: number;
|
|
144
|
+
pad: number;
|
|
145
|
+
via: number;
|
|
146
|
+
area: number;
|
|
147
|
+
};
|
|
148
|
+
trackWidth: number;
|
|
149
|
+
minTrackWidth: number;
|
|
150
|
+
/** Copper to board outline. */
|
|
151
|
+
edgeClearance: number;
|
|
152
|
+
/** Default via. */
|
|
153
|
+
via: {
|
|
154
|
+
diameter: number;
|
|
155
|
+
drill: number;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Copper stack, top to bottom, as EW layer numbers (0, 1..2N-2, 63). */
|
|
159
|
+
export interface Stackup {
|
|
160
|
+
copper: number[];
|
|
161
|
+
thickness: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A copper pour: EW power plane (`UBPowerPlane`) or board-level copper area
|
|
165
|
+
* (`UBPolygon`, `UBRectangle`, ...). EW stores the outline and fill rules,
|
|
166
|
+
* never the computed fill.
|
|
167
|
+
*/
|
|
168
|
+
export interface Zone {
|
|
169
|
+
kind: "plane" | "area";
|
|
170
|
+
layer: number;
|
|
171
|
+
netName: string;
|
|
172
|
+
outline: Point[];
|
|
173
|
+
clearance: number;
|
|
174
|
+
minThickness: number;
|
|
175
|
+
reliefSpokeWidth: number;
|
|
176
|
+
thermalReliefStyle: number;
|
|
177
|
+
removeIslands: boolean;
|
|
178
|
+
islandArea: number;
|
|
179
|
+
removeNotEdgeConnected: boolean;
|
|
180
|
+
}
|
|
181
|
+
/** Free text on the board (`UBAttribute Tag=TEXT`). */
|
|
182
|
+
export interface BoardText {
|
|
183
|
+
layer: number;
|
|
184
|
+
text: string;
|
|
185
|
+
at: Point;
|
|
186
|
+
angle: number;
|
|
187
|
+
mirror: boolean;
|
|
188
|
+
width: number;
|
|
189
|
+
height: number;
|
|
190
|
+
strokeWidth: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* An Ultiboard rule area (keep-in / keep-out). Semantics of `type` and the
|
|
194
|
+
* net groups are not confirmed; masks are kept raw.
|
|
195
|
+
*/
|
|
196
|
+
export interface RuleArea {
|
|
197
|
+
type: number;
|
|
198
|
+
outline: Point[];
|
|
199
|
+
/** ActiveLayersZero..Seven, bit i of word w = EW layer 64w + i. */
|
|
200
|
+
activeLayers: bigint[];
|
|
201
|
+
allNets: boolean;
|
|
202
|
+
nets: string[];
|
|
203
|
+
}
|
|
204
|
+
export interface Board {
|
|
205
|
+
source: Source;
|
|
206
|
+
projectName: string;
|
|
207
|
+
sheetTitle: string;
|
|
208
|
+
workArea: {
|
|
209
|
+
left: number;
|
|
210
|
+
bottom: number;
|
|
211
|
+
right: number;
|
|
212
|
+
top: number;
|
|
213
|
+
};
|
|
214
|
+
layers: EwLayer[];
|
|
215
|
+
stackup: Stackup;
|
|
216
|
+
zones: Zone[];
|
|
217
|
+
texts: BoardText[];
|
|
218
|
+
ruleAreas: RuleArea[];
|
|
219
|
+
shapes: Shape[];
|
|
220
|
+
tracks: Track[];
|
|
221
|
+
components: Component[];
|
|
222
|
+
holes: Hole[];
|
|
223
|
+
vias: Via[];
|
|
224
|
+
nets: Net[];
|
|
225
|
+
rules?: DesignRules;
|
|
226
|
+
}
|
|
227
|
+
export interface SchPoint {
|
|
228
|
+
x: number;
|
|
229
|
+
y: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* A dihedral transform as a 2x2 integer matrix: p' = (a*x + c*y, b*x + d*y).
|
|
233
|
+
* Maps symbol-local coordinates (Y-down) onto the sheet, before translation.
|
|
234
|
+
*/
|
|
235
|
+
export interface Dihedral {
|
|
236
|
+
a: number;
|
|
237
|
+
b: number;
|
|
238
|
+
c: number;
|
|
239
|
+
d: number;
|
|
240
|
+
}
|
|
241
|
+
export type SchGraphic = {
|
|
242
|
+
kind: "polyline";
|
|
243
|
+
points: SchPoint[];
|
|
244
|
+
width: number;
|
|
245
|
+
fill: boolean;
|
|
246
|
+
} | {
|
|
247
|
+
kind: "rect";
|
|
248
|
+
a: SchPoint;
|
|
249
|
+
b: SchPoint;
|
|
250
|
+
width: number;
|
|
251
|
+
fill: boolean;
|
|
252
|
+
} | {
|
|
253
|
+
kind: "circle";
|
|
254
|
+
center: SchPoint;
|
|
255
|
+
radius: number;
|
|
256
|
+
width: number;
|
|
257
|
+
fill: boolean;
|
|
258
|
+
} | {
|
|
259
|
+
kind: "arc";
|
|
260
|
+
start: SchPoint;
|
|
261
|
+
mid: SchPoint;
|
|
262
|
+
end: SchPoint;
|
|
263
|
+
width: number;
|
|
264
|
+
} | {
|
|
265
|
+
kind: "text";
|
|
266
|
+
at: SchPoint;
|
|
267
|
+
text: string;
|
|
268
|
+
size: number;
|
|
269
|
+
};
|
|
270
|
+
export interface SymbolPin {
|
|
271
|
+
name: string;
|
|
272
|
+
number: string;
|
|
273
|
+
at: SchPoint;
|
|
274
|
+
dir: SchPoint;
|
|
275
|
+
length: number;
|
|
276
|
+
attach?: SchPoint;
|
|
277
|
+
netId?: string;
|
|
278
|
+
connected?: boolean;
|
|
279
|
+
/** Electrical type, when the source says (EW database parts); else passive. */
|
|
280
|
+
electrical?: PinElectrical;
|
|
281
|
+
}
|
|
282
|
+
export type PinElectrical = "input" | "output" | "bidirectional" | "tri_state" | "passive" | "power_in" | "power_out" | "open_collector" | "open_emitter" | "no_connect" | "unspecified";
|
|
283
|
+
export interface SymbolText {
|
|
284
|
+
text: string;
|
|
285
|
+
at: SchPoint;
|
|
286
|
+
hidden: boolean;
|
|
287
|
+
}
|
|
288
|
+
/** A placed part (or power port), in its own local frame plus a placement. */
|
|
289
|
+
export interface SchematicSymbol {
|
|
290
|
+
reference: string;
|
|
291
|
+
value: string;
|
|
292
|
+
kind: "part" | "power";
|
|
293
|
+
at: SchPoint;
|
|
294
|
+
transform: Dihedral;
|
|
295
|
+
graphics: SchGraphic[];
|
|
296
|
+
pins: SymbolPin[];
|
|
297
|
+
refText?: SymbolText;
|
|
298
|
+
valueText?: SymbolText;
|
|
299
|
+
showPinNames: boolean;
|
|
300
|
+
showPinNumbers: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Key for final-refdes lookup: drawn refdes + Multisim section name. The
|
|
303
|
+
* final refdes depends on which hierarchy instance the sheet is in.
|
|
304
|
+
*/
|
|
305
|
+
drawnKey?: string;
|
|
306
|
+
/** Power port that Multisim doesn't connect to anything. */
|
|
307
|
+
floating?: boolean;
|
|
308
|
+
/** The part's name in the EW database (e.g. "BAV23C"), when known. */
|
|
309
|
+
partName?: string;
|
|
310
|
+
}
|
|
311
|
+
export interface SchematicWire {
|
|
312
|
+
points: SchPoint[];
|
|
313
|
+
netId?: string;
|
|
314
|
+
}
|
|
315
|
+
export interface SchematicLabel {
|
|
316
|
+
name: string;
|
|
317
|
+
at: SchPoint;
|
|
318
|
+
kind: "local" | "global" | "hierarchical";
|
|
319
|
+
dir: SchPoint;
|
|
320
|
+
netId?: string;
|
|
321
|
+
floating?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* A Multisim bus line. Drawing only: bus members connect by name, through
|
|
325
|
+
* the labels placed at each bus entry's wire end.
|
|
326
|
+
*/
|
|
327
|
+
export interface SchematicBus {
|
|
328
|
+
points: SchPoint[];
|
|
329
|
+
name: string;
|
|
330
|
+
members: string[];
|
|
331
|
+
}
|
|
332
|
+
/** A bus entry stub: `wire` is where the member's wire attaches, `bus` lies on the bus. */
|
|
333
|
+
export interface SchematicBusEntry {
|
|
334
|
+
wire: SchPoint;
|
|
335
|
+
bus: SchPoint;
|
|
336
|
+
member: string;
|
|
337
|
+
}
|
|
338
|
+
export interface SchematicText {
|
|
339
|
+
text: string;
|
|
340
|
+
at: SchPoint;
|
|
341
|
+
size: number;
|
|
342
|
+
}
|
|
343
|
+
/** A hierarchical block (sub-sheet instance) placed on a page. */
|
|
344
|
+
export interface SheetBlock {
|
|
345
|
+
id: string;
|
|
346
|
+
childSheet: string;
|
|
347
|
+
a: SchPoint;
|
|
348
|
+
b: SchPoint;
|
|
349
|
+
pins: {
|
|
350
|
+
name: string;
|
|
351
|
+
at: SchPoint;
|
|
352
|
+
attach?: SchPoint;
|
|
353
|
+
}[];
|
|
354
|
+
}
|
|
355
|
+
export interface SchematicSheet {
|
|
356
|
+
name: string;
|
|
357
|
+
title: string;
|
|
358
|
+
page: string;
|
|
359
|
+
blocks: SheetBlock[];
|
|
360
|
+
size: {
|
|
361
|
+
width: number;
|
|
362
|
+
height: number;
|
|
363
|
+
};
|
|
364
|
+
symbols: SchematicSymbol[];
|
|
365
|
+
wires: SchematicWire[];
|
|
366
|
+
labels: SchematicLabel[];
|
|
367
|
+
texts: SchematicText[];
|
|
368
|
+
buses: SchematicBus[];
|
|
369
|
+
busEntries: SchematicBusEntry[];
|
|
370
|
+
}
|
|
371
|
+
/** One instantiation of a unique sheet in the design hierarchy. */
|
|
372
|
+
export interface SchInstance {
|
|
373
|
+
sheet: string;
|
|
374
|
+
name: string;
|
|
375
|
+
blockId?: string;
|
|
376
|
+
parentPage?: string;
|
|
377
|
+
/** Final refdes by `${page}|${drawnKey}`; absent -> keep the drawn name. */
|
|
378
|
+
refdes: Record<string, string>;
|
|
379
|
+
/** Drawn -> final pin numbers by `${page}|${drawnKey}`. */
|
|
380
|
+
pinRemaps: Record<string, Record<string, string>>;
|
|
381
|
+
/** 1-based unit of a multi-section part by `${page}|${drawnKey}`. */
|
|
382
|
+
units: Record<string, number>;
|
|
383
|
+
children: SchInstance[];
|
|
384
|
+
}
|
|
385
|
+
export interface Schematic {
|
|
386
|
+
source: Source;
|
|
387
|
+
projectName: string;
|
|
388
|
+
rootSheet: string;
|
|
389
|
+
sheets: SchematicSheet[];
|
|
390
|
+
root: SchInstance;
|
|
391
|
+
}
|
package/dist/load.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DesignKind = "pcb" | "schematic";
|
|
2
|
+
export interface LoadedDesign {
|
|
3
|
+
kind: DesignKind;
|
|
4
|
+
/** Decompressed EW XML text. */
|
|
5
|
+
xml: string;
|
|
6
|
+
/** "binary" when decoded via ewd, "xml" when read as already-decoded text. */
|
|
7
|
+
via: "binary" | "xml";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Read an EW design from disk. Binary `.ewprj` / `.ms1x` containers are
|
|
11
|
+
* detected by magic bytes and decompressed in memory via `ewd`
|
|
12
|
+
* (electronics-workbench-decoder); anything else is treated as the XML that
|
|
13
|
+
* `ewd` would produce. The design kind comes from the XML root element, not
|
|
14
|
+
* the filename.
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadDesign(path: string): Promise<LoadedDesign>;
|
|
17
|
+
/** Output base name: strips `.xml` and the EW design extension. */
|
|
18
|
+
export declare function designBaseName(file: string): string;
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** One KiCad project: an EW schematic and/or board sharing a base name. */
|
|
2
|
+
export interface ProjectInput {
|
|
3
|
+
base: string;
|
|
4
|
+
sch?: {
|
|
5
|
+
input: string;
|
|
6
|
+
xml: string;
|
|
7
|
+
};
|
|
8
|
+
pcb?: {
|
|
9
|
+
input: string;
|
|
10
|
+
xml: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Convert a project. With both halves present the outputs are linked the
|
|
15
|
+
* way KiCad's "Update PCB from Schematic" expects: each footprint carries its
|
|
16
|
+
* symbol's path / sheet name / sheet file, and each symbol names its
|
|
17
|
+
* footprint. See plans/converter.md, phase E.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertProject(p: ProjectInput, outDir: string): Promise<string[]>;
|
|
20
|
+
export declare function convertPcb(input: string, xml: string, outDir: string): Promise<string>;
|
|
21
|
+
export declare function convertSch(input: string, xml: string, outDir: string): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Group design files into projects: a schematic and a board in the same
|
|
24
|
+
* folder with the same base name (Main.ms14 + Main.ewprj) are one project.
|
|
25
|
+
* Directories contribute every design file directly inside them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function groupProjects(paths: string[]): Promise<ProjectInput[]>;
|
|
28
|
+
/** Convert one design file on its own (no pairing). */
|
|
29
|
+
export declare function convertFile(input: string, outDir?: string): Promise<string>;
|
|
30
|
+
/** The command line: `multisim2kicad [-o <outDir>] <inputs...>`. */
|
|
31
|
+
export declare function main(args?: string[]): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* An EW component database (`.prj` / `.usr`) -> KiCad libraries named after
|
|
34
|
+
* it: `<name>.pretty/` (+ fp-lib-table) and `<name>.kicad_sym` (+
|
|
35
|
+
* sym-lib-table), each symbol's Footprint pointing into the `.pretty` when
|
|
36
|
+
* the database holds its package. Phase F.
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertDatabase(input: string, outDir: string): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared access to the EW XML document model from ewd.
|
|
3
|
+
*
|
|
4
|
+
* Every parser takes `XmlInput`: callers that run several parsers over one
|
|
5
|
+
* design parse the XML once (`parseEwXml`) and pass the document around;
|
|
6
|
+
* one-off callers can still pass the XML text.
|
|
7
|
+
*/
|
|
8
|
+
import { type EwDocument, type EwElement } from "electronics-workbench-decoder";
|
|
9
|
+
export type { EwDocument, EwElement };
|
|
10
|
+
export { decodeEwString } from "electronics-workbench-decoder";
|
|
11
|
+
export type XmlInput = string | EwDocument;
|
|
12
|
+
export declare const docOf: (input: XmlInput) => EwDocument;
|
|
13
|
+
/**
|
|
14
|
+
* Text shown on a drawing (values, refdes, notes, pin names). The document
|
|
15
|
+
* model keeps attribute values raw; display text drops surrounding
|
|
16
|
+
* whitespace and uses LF line breaks (EW stores CRLF).
|
|
17
|
+
*/
|
|
18
|
+
export declare const displayText: (s: string) => string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type EwElement, type XmlInput } from "./doc.ts";
|
|
2
|
+
export interface NetPin {
|
|
3
|
+
refdes: string;
|
|
4
|
+
pin: string;
|
|
5
|
+
}
|
|
6
|
+
interface Mod {
|
|
7
|
+
mod: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
interface PinRec {
|
|
11
|
+
id: string;
|
|
12
|
+
owner: string;
|
|
13
|
+
ownerKind: string;
|
|
14
|
+
portId?: string;
|
|
15
|
+
pinNumber: string;
|
|
16
|
+
pinName: string;
|
|
17
|
+
mods: Mod[];
|
|
18
|
+
}
|
|
19
|
+
export interface PageIndex {
|
|
20
|
+
title: string;
|
|
21
|
+
page: string;
|
|
22
|
+
/** The page's DesignSheet element (for drawing extraction). */
|
|
23
|
+
designSheet: EwElement;
|
|
24
|
+
edges: [string, string][];
|
|
25
|
+
pins: PinRec[];
|
|
26
|
+
symbols: Map<string, {
|
|
27
|
+
kind: string;
|
|
28
|
+
ciComp: string;
|
|
29
|
+
obj: EwElement;
|
|
30
|
+
}>;
|
|
31
|
+
links: {
|
|
32
|
+
id: string;
|
|
33
|
+
mods: Mod[];
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
export interface SheetInstance {
|
|
37
|
+
/** "" for the root, else "/SC1/SC4"-style path of drawn instance names. */
|
|
38
|
+
path: string;
|
|
39
|
+
sheet: string;
|
|
40
|
+
/** Drawn instance name (e.g. "SC1") and final name (e.g. "H0"). */
|
|
41
|
+
name: string;
|
|
42
|
+
finalName: string;
|
|
43
|
+
/** Macro element ID on the parent page (for matching the sheet symbol). */
|
|
44
|
+
macroId?: string;
|
|
45
|
+
parentPath?: string;
|
|
46
|
+
parentPage?: string;
|
|
47
|
+
/** CIR path for one of this instance's pages. */
|
|
48
|
+
cirOf: (page: string) => string;
|
|
49
|
+
children: SheetInstance[];
|
|
50
|
+
}
|
|
51
|
+
export interface MultisimDesign {
|
|
52
|
+
rootTitle: string;
|
|
53
|
+
pages: PageIndex[];
|
|
54
|
+
root: SheetInstance;
|
|
55
|
+
/** Final refdes for a drawn part: (instance path, page, drawn refdes + section). */
|
|
56
|
+
finalRefdes(inst: SheetInstance, page: string, drawnKey: string): string | undefined;
|
|
57
|
+
/** CIR -> IR pin-number remap for a part, if any. */
|
|
58
|
+
pinRemap(inst: SheetInstance, page: string, drawnKey: string): Map<string, string> | undefined;
|
|
59
|
+
/** 1-based unit (section) of the final part this drawn symbol is, if multi-section. */
|
|
60
|
+
finalUnit(inst: SheetInstance, page: string, drawnKey: string): number | undefined;
|
|
61
|
+
warnings: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface CiItem {
|
|
64
|
+
cls: string;
|
|
65
|
+
body: EwElement;
|
|
66
|
+
}
|
|
67
|
+
export declare function parseMultisimDesign(input: XmlInput): MultisimDesign & {
|
|
68
|
+
ci: Map<string, CiItem>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Multisim's flattened netlist (final refdes, final pin numbers), built from
|
|
72
|
+
* the drawing ID graph. This is the scorecard's reference.
|
|
73
|
+
*/
|
|
74
|
+
export declare function flattenNetlist(design: ReturnType<typeof parseMultisimDesign>): Map<string, NetPin[]>;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Board, Component } from "../ir/types.ts";
|
|
2
|
+
import { type XmlInput } from "./doc.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The footprint in an Ultiboard library object (an EW database `UBLIB`
|
|
5
|
+
* blob: `<LibraryObject>` holding one `UBComponent` in its own frame, origin
|
|
6
|
+
* at the library RefPoint). Undefined when the object holds no component.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseUbLibraryXml(input: XmlInput): Component | undefined;
|
|
9
|
+
export declare function parsePcbXml(input: XmlInput): Board;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multisim schematic XML -> Schematic IR (Multisim units, Y-down).
|
|
3
|
+
*
|
|
4
|
+
* Model (verified on the corpus, see plans/converter.md "Findings"):
|
|
5
|
+
* - Placed parts are `CIITSymbolComp`. Their drawing objects live in
|
|
6
|
+
* `Objects > Item > <Class>`, each with its own affine `Transformer-M**`
|
|
7
|
+
* (Windows XFORM: x' = x*M00 + y*M10 + M20, y' = x*M01 + y*M11 + M21)
|
|
8
|
+
* into the symbol frame.
|
|
9
|
+
* - Symbol orientation is `OrientationFlip`: bits 0-1 rotate (0, 1 = r270,
|
|
10
|
+
* 2 = r180, 3 = r90 in (x, y) -> (y, -x) terms), 0x100 mirrors y, 0x1000
|
|
11
|
+
* mirrors x; the mirror applies before the rotation. The symbol's own
|
|
12
|
+
* `Transformer` matrix is always identity and its M20/M21 is not a reliable
|
|
13
|
+
* origin, so the translation is recovered from the pins.
|
|
14
|
+
* - Each pin connector's `ConnectList` names a sheet-level `CODPinComp`
|
|
15
|
+
* whose CenterX/Y is where wiring attaches (absolute).
|
|
16
|
+
* - Wires are `CIITLinkComp` polylines. User-named nets carry an
|
|
17
|
+
* `NI_EWB_NET_NAME` modifier.
|
|
18
|
+
* - `CVirtualConnector` = named net connector (`NI_EWB_VIRTUAL_GLOBAL` /
|
|
19
|
+
* `_LOCAL`), emitted as global / local labels.
|
|
20
|
+
* - Ground / supply symbols are `CIITSymbolComp`s whose Ci component is in
|
|
21
|
+
* the POWER_SOURCES family with a single pin; emitted as power ports whose
|
|
22
|
+
* name is the Ci refdes (= the net name, e.g. "0", "VCC").
|
|
23
|
+
*/
|
|
24
|
+
import type { Dihedral, Schematic, SchPoint } from "../ir/types.ts";
|
|
25
|
+
import { type XmlInput } from "./doc.ts";
|
|
26
|
+
export declare const applyD: (t: Dihedral, p: SchPoint) => SchPoint;
|
|
27
|
+
/** OrientationFlip -> dihedral (mirror first, then rotate). */
|
|
28
|
+
export declare function flipToDihedral(flip: number): Dihedral;
|
|
29
|
+
/** Placement stats, for the converter summary and the plan's findings. */
|
|
30
|
+
export declare const placementStats: {
|
|
31
|
+
symbols: number;
|
|
32
|
+
pins: number;
|
|
33
|
+
pinsOnTarget: number;
|
|
34
|
+
raw: number;
|
|
35
|
+
composed: number;
|
|
36
|
+
unattached: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function parseSchematicXml(input: XmlInput): Schematic;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ultiboard drawing primitives (UBPolygon, UBRectangle, UBRoundedRectangle,
|
|
3
|
+
* UBPie, UBArc, UBEllipse) -> geometry in absolute nm, EW's Y-up frame.
|
|
4
|
+
*
|
|
5
|
+
* Conventions verified on corpus samples:
|
|
6
|
+
* - Points live in `Object > Point`.
|
|
7
|
+
* - UBPie / UBArc: points are [start, end, center] plus `Radius`; the sweep
|
|
8
|
+
* runs counter-clockwise (Y-up) from start to end; start == end is a full
|
|
9
|
+
* circle.
|
|
10
|
+
* - UBRectangle / UBRoundedRectangle: the first 4 points are the corners in
|
|
11
|
+
* order (the rectangle may be rotated); a 5th point, when present, is an
|
|
12
|
+
* anchor and is ignored. UBRoundedRectangle adds `Radius`.
|
|
13
|
+
*/
|
|
14
|
+
import type { EwElement } from "./doc.ts";
|
|
15
|
+
import type { PadPrimitive, Point } from "../ir/types.ts";
|
|
16
|
+
export declare function points(item: EwElement | undefined): Point[];
|
|
17
|
+
/** CCW sweep from start to end around center; (0, 2pi], full circle when start == end. */
|
|
18
|
+
export declare function ccwSweep(center: Point, start: Point, end: Point): number;
|
|
19
|
+
/** Points along a CCW arc (inclusive of both ends). */
|
|
20
|
+
export declare function arcPoints(center: Point, radius: number, a0: number, sweep: number): Point[];
|
|
21
|
+
/** Polygon for a rectangle given by 4 corners, with corners rounded by `r`. */
|
|
22
|
+
export declare function roundedPolygon(corners: Point[], r: number): Point[];
|
|
23
|
+
/**
|
|
24
|
+
* A UB primitive as filled/stroked geometry. Returns undefined for tags this
|
|
25
|
+
* module doesn't know. Filled outlines come back as `poly`; UBArc as `arc`
|
|
26
|
+
* (or `circle` when it closes on itself).
|
|
27
|
+
*/
|
|
28
|
+
export declare function ubPrimitive(tag: string, item: EwElement): PadPrimitive | undefined;
|
|
29
|
+
export declare const UB_PRIMITIVE_TAGS: string[];
|
|
30
|
+
/** Filled outline of a primitive (circles flattened); undefined for strokes (arcs). */
|
|
31
|
+
export declare function primitiveOutline(p: PadPrimitive): Point[] | undefined;
|
|
32
|
+
/** Bounding box of a set of primitives. */
|
|
33
|
+
export declare function primitivesBBox(prims: PadPrimitive[]): {
|
|
34
|
+
xMin: number;
|
|
35
|
+
xMax: number;
|
|
36
|
+
yMin: number;
|
|
37
|
+
yMax: number;
|
|
38
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multisim's own netlist, read from the `Ci*` objects in a `.ms1x` file.
|
|
3
|
+
*
|
|
4
|
+
* Each `CiCircuit` (one per unique sheet / subcircuit) owns `CiComponent`s
|
|
5
|
+
* (refdes in `LocalName`), `CiPort`s (one per symbol pin, pointing back at
|
|
6
|
+
* its component and holding the pin-number CSV) and `CiNode`s (nets: name in
|
|
7
|
+
* `LocalName`, member ports in `Ports > Item@CiID`). Hierarchical instances
|
|
8
|
+
* are `CiInstComponent`s; flattening them needs the per-instance refdes map
|
|
9
|
+
* and is Phase D1 work, so for now this returns each circuit separately and
|
|
10
|
+
* reports whether the design is hierarchical.
|
|
11
|
+
*
|
|
12
|
+
* This is EW format knowledge, so it is a candidate to move into ewd (Phase
|
|
13
|
+
* B3) once it settles.
|
|
14
|
+
*/
|
|
15
|
+
import { type EwElement, type XmlInput } from "../parse/doc.ts";
|
|
16
|
+
export interface CiPinRef {
|
|
17
|
+
refdes: string;
|
|
18
|
+
pin: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* - `part`: a real component (has a manufacturer/family record).
|
|
22
|
+
* - `power`: ground / supply symbols (family `POWER_SOURCES`).
|
|
23
|
+
* - `connector`: virtual net joiners (on/off-page connectors, net-label
|
|
24
|
+
* components); their attribute record is a single type code.
|
|
25
|
+
*/
|
|
26
|
+
export type CiComponentKind = "part" | "power" | "connector";
|
|
27
|
+
export interface CiCircuitNetlist {
|
|
28
|
+
id: string;
|
|
29
|
+
/** Net name -> pins on it. Only `part` pins with pin numbers are included. */
|
|
30
|
+
nets: Map<string, CiPinRef[]>;
|
|
31
|
+
/** Refdes of every `part` in this circuit. */
|
|
32
|
+
components: string[];
|
|
33
|
+
/** Refdes -> kind, for every component (parts, power, connectors). */
|
|
34
|
+
kinds: Map<string, CiComponentKind>;
|
|
35
|
+
instances: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface CiNetlist {
|
|
38
|
+
circuits: CiCircuitNetlist[];
|
|
39
|
+
hierarchical: boolean;
|
|
40
|
+
/** CiComponent id (as referenced by a drawing's `CiComponent=` attr) -> refdes + kind. */
|
|
41
|
+
componentsById: Map<string, {
|
|
42
|
+
refdes: string;
|
|
43
|
+
kind: CiComponentKind;
|
|
44
|
+
part?: string;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
/** Every `<Item CiID=.. Class="Ci...">` wrapper's body element, by class, in document order. */
|
|
48
|
+
export declare function collectCiItems(root: EwElement): Map<string, {
|
|
49
|
+
id: string;
|
|
50
|
+
body: EwElement;
|
|
51
|
+
}[]>;
|
|
52
|
+
/** A Ci object's `CiaCollString` records: direct ones, then those wrapped in `Item`s. */
|
|
53
|
+
export declare function ciCollStrings(body: EwElement): EwElement[];
|
|
54
|
+
/** The decoded `Value`s of one `CiaCollString`. */
|
|
55
|
+
export declare const collValues: (coll: EwElement | undefined) => string[];
|
|
56
|
+
/**
|
|
57
|
+
* The part's EW database name. Database parts list `family, name, family`
|
|
58
|
+
* in their attribute strings (`MicroFit, 43650-04-11, MicroFit, ...`;
|
|
59
|
+
* virtual parts the same further in); basic parts (resistors) are all
|
|
60
|
+
* numbers and have none.
|
|
61
|
+
*/
|
|
62
|
+
export declare function dbPartName(body: EwElement): string | undefined;
|
|
63
|
+
/** Pin-number CSV lives at strings[6] of a CiPort's second CiaCollString. */
|
|
64
|
+
export declare function portPinNumbers(port: EwElement): string[];
|
|
65
|
+
/**
|
|
66
|
+
* A pin's drawn number(s) (`CIITPinSymbolComp@PinNumber`). Instruments
|
|
67
|
+
* (multimeters, scopes, analyzers) show "##" as a placeholder; like an empty
|
|
68
|
+
* number, it means "use the pin name".
|
|
69
|
+
*/
|
|
70
|
+
export declare function drawnPinNumbers(raw: string): string[];
|
|
71
|
+
export declare function parseCiNetlist(input: XmlInput): CiNetlist;
|