@modular-circuit/transpiler 0.1.4 → 0.1.6
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.js +97 -71
- package/dist/index.mjs +102 -73
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -190,35 +190,39 @@ async function collect_sub_sheets(dependencies, module_resolver) {
|
|
|
190
190
|
const module_main_sheet = {};
|
|
191
191
|
const modules = {};
|
|
192
192
|
for (const [k, v] of Object.entries(dependencies)) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
193
|
+
try {
|
|
194
|
+
const zip_archive_url = await module_resolver.get_module_archive({
|
|
195
|
+
...(0, import_utils.parse_module_name)(k),
|
|
196
|
+
version: v
|
|
197
|
+
});
|
|
198
|
+
const module2 = await module_resolver.get_module_circuit({
|
|
199
|
+
...(0, import_utils.parse_module_name)(k),
|
|
200
|
+
version: v
|
|
201
|
+
});
|
|
202
|
+
if (!zip_archive_url || !module2) {
|
|
203
|
+
console.error(`Module ${k}/${v} not found`);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (!module2.main) {
|
|
207
|
+
console.error(`Missing main entry in module ${k}/${v}`);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
module_main_sheet[k] = module2.main;
|
|
211
|
+
modules[k] = module2;
|
|
212
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
213
|
+
const files = await (0, import_utils.unzipFile)(zip_archive);
|
|
214
|
+
for (const [name, content] of Object.entries(files)) {
|
|
215
|
+
if (name.endsWith(import_utils.KICAD_SHC_FILE_EXT)) {
|
|
216
|
+
const fileName = (0, import_utils.remove_filename_path_prefix)(name);
|
|
217
|
+
if (fileName in sheets) {
|
|
218
|
+
console.error(`Duplicate sheet name: ${fileName}`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
sheets[fileName] = content;
|
|
219
222
|
}
|
|
220
|
-
sheets[fileName] = content;
|
|
221
223
|
}
|
|
224
|
+
} catch (e) {
|
|
225
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
return { sheets, module_main_sheet, modules };
|
|
@@ -290,44 +294,48 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
290
294
|
const modules = {};
|
|
291
295
|
const design_blocks = [];
|
|
292
296
|
for (const id of module_ids) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
297
|
+
try {
|
|
298
|
+
const zip_archive_url = await module_resolver.get_module_archive_by_id(id);
|
|
299
|
+
const module_circuit = await module_resolver.get_module_circuit_by_id(id);
|
|
300
|
+
if (!module_circuit) {
|
|
301
|
+
console.error(`Module ${id} not found`);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (!zip_archive_url || !module_circuit) {
|
|
305
|
+
console.error(`Module ${module_circuit.author}/${module_circuit.name} not found`);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (!module_circuit.main) {
|
|
309
|
+
console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
const k = (0, import_utils2.fmt_module_name)(module_circuit);
|
|
313
|
+
module_main_sheet[k] = module_circuit.main;
|
|
314
|
+
modules[k] = module_circuit;
|
|
315
|
+
const design_block = {
|
|
316
|
+
main_sch: module_circuit.main,
|
|
317
|
+
sheets: []
|
|
318
|
+
};
|
|
319
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
320
|
+
const files = await (0, import_utils2.unzipFile)(zip_archive);
|
|
321
|
+
for (const [name, content] of Object.entries(files)) {
|
|
322
|
+
if (name.endsWith(import_utils2.KICAD_SHC_FILE_EXT)) {
|
|
323
|
+
const filename = (0, import_utils2.remove_filename_path_prefix)(name);
|
|
324
|
+
if (filename in sheets) {
|
|
325
|
+
console.error(`Duplicate sheet name: ${filename}`);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
sheets[filename] = content;
|
|
329
|
+
design_block.sheets.push({ filename, content });
|
|
330
|
+
} else if (name.endsWith(import_utils2.KICAD_PCB_FILE_EXT)) {
|
|
331
|
+
const filename = (0, import_utils2.remove_filename_path_prefix)(name);
|
|
332
|
+
design_block.pcb = { filename, content };
|
|
322
333
|
}
|
|
323
|
-
sheets[filename] = content;
|
|
324
|
-
design_block.sheets.push({ filename, content });
|
|
325
|
-
} else if (name.endsWith(import_utils2.KICAD_PCB_FILE_EXT)) {
|
|
326
|
-
const filename = (0, import_utils2.remove_filename_path_prefix)(name);
|
|
327
|
-
design_block.pcb = { filename, content };
|
|
328
334
|
}
|
|
335
|
+
design_blocks.push(design_block);
|
|
336
|
+
} catch (e) {
|
|
337
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
329
338
|
}
|
|
330
|
-
design_blocks.push(design_block);
|
|
331
339
|
}
|
|
332
340
|
return { sheets, module_main_sheet, modules, design_blocks };
|
|
333
341
|
}
|
|
@@ -595,8 +603,7 @@ var LinkConverterBase = class {
|
|
|
595
603
|
}
|
|
596
604
|
gen_net_name(signal_name) {
|
|
597
605
|
const base_net_name = signal_name ? `${this.net_pros.name}-${signal_name}` : `${this.net_pros.name}`;
|
|
598
|
-
if (this.net_pros.is_global_pwr)
|
|
599
|
-
return base_net_name;
|
|
606
|
+
if (this.net_pros.is_global_pwr) return base_net_name;
|
|
600
607
|
if (!this.ctx.net_names_count.has(base_net_name)) {
|
|
601
608
|
this.ctx.net_names_count.set(base_net_name, 0);
|
|
602
609
|
return base_net_name;
|
|
@@ -1655,14 +1662,33 @@ var GraphConverter = class {
|
|
|
1655
1662
|
for (const node of sub.nodes) {
|
|
1656
1663
|
if (node.type === import_electronics_model4.ConnectionNodeType.Port) {
|
|
1657
1664
|
const port_id = node.uuid;
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1665
|
+
const ir_port = node.param;
|
|
1666
|
+
port_map.set(ir_port, port_id);
|
|
1667
|
+
if (node.label_shapes) {
|
|
1668
|
+
for (const [label_name, shape] of Object.entries(node.label_shapes)) {
|
|
1669
|
+
const pin_id = `pin-${++pin_count}`;
|
|
1670
|
+
pin_shapes[pin_id] = shape;
|
|
1671
|
+
if (!(port_id in pin_map)) {
|
|
1672
|
+
pin_map[port_id] = {};
|
|
1673
|
+
}
|
|
1674
|
+
pin_map[port_id][label_name] = pin_id;
|
|
1675
|
+
}
|
|
1676
|
+
} else {
|
|
1677
|
+
if (ir_port.type === import_electronics_model4.PortType.DigitalBidirBundle) {
|
|
1678
|
+
console.error(
|
|
1679
|
+
`DigitalBidirBundle shall be replaced by DigitalBidirs while building connection graph : ${ir_port.name}`
|
|
1680
|
+
);
|
|
1681
|
+
} else {
|
|
1682
|
+
const expected_signals = (0, import_electronics_model4.get_port_type_signals)(ir_port.type);
|
|
1683
|
+
for (const signal of expected_signals) {
|
|
1684
|
+
const pin_id = `pin-${++pin_count}`;
|
|
1685
|
+
pin_shapes[pin_id] = import_electronics_model4.LabelShapes.Passive;
|
|
1686
|
+
if (!(port_id in pin_map)) {
|
|
1687
|
+
pin_map[port_id] = {};
|
|
1688
|
+
}
|
|
1689
|
+
pin_map[port_id][`${ir_port.name}-${signal}`] = pin_id;
|
|
1690
|
+
}
|
|
1664
1691
|
}
|
|
1665
|
-
pin_map[port_id][label_name] = pin_id;
|
|
1666
1692
|
}
|
|
1667
1693
|
}
|
|
1668
1694
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -71,35 +71,39 @@ async function collect_sub_sheets(dependencies, module_resolver) {
|
|
|
71
71
|
const module_main_sheet = {};
|
|
72
72
|
const modules = {};
|
|
73
73
|
for (const [k, v] of Object.entries(dependencies)) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
try {
|
|
75
|
+
const zip_archive_url = await module_resolver.get_module_archive({
|
|
76
|
+
...parse_module_name(k),
|
|
77
|
+
version: v
|
|
78
|
+
});
|
|
79
|
+
const module = await module_resolver.get_module_circuit({
|
|
80
|
+
...parse_module_name(k),
|
|
81
|
+
version: v
|
|
82
|
+
});
|
|
83
|
+
if (!zip_archive_url || !module) {
|
|
84
|
+
console.error(`Module ${k}/${v} not found`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!module.main) {
|
|
88
|
+
console.error(`Missing main entry in module ${k}/${v}`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
module_main_sheet[k] = module.main;
|
|
92
|
+
modules[k] = module;
|
|
93
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
94
|
+
const files = await unzipFile(zip_archive);
|
|
95
|
+
for (const [name, content] of Object.entries(files)) {
|
|
96
|
+
if (name.endsWith(KICAD_SHC_FILE_EXT)) {
|
|
97
|
+
const fileName = remove_filename_path_prefix(name);
|
|
98
|
+
if (fileName in sheets) {
|
|
99
|
+
console.error(`Duplicate sheet name: ${fileName}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
sheets[fileName] = content;
|
|
100
103
|
}
|
|
101
|
-
sheets[fileName] = content;
|
|
102
104
|
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
109
|
return { sheets, module_main_sheet, modules };
|
|
@@ -165,9 +169,9 @@ var StringFormatter = class {
|
|
|
165
169
|
|
|
166
170
|
// src/utils/collect_sub_sheets_by_id.ts
|
|
167
171
|
import {
|
|
168
|
-
fmt_module_name,
|
|
169
172
|
KICAD_PCB_FILE_EXT,
|
|
170
173
|
KICAD_SHC_FILE_EXT as KICAD_SHC_FILE_EXT2,
|
|
174
|
+
fmt_module_name,
|
|
171
175
|
remove_filename_path_prefix as remove_filename_path_prefix2,
|
|
172
176
|
unzipFile as unzipFile2
|
|
173
177
|
} from "@modular-circuit/utils";
|
|
@@ -177,44 +181,48 @@ async function collect_sub_sheets_by_id(module_ids, module_resolver) {
|
|
|
177
181
|
const modules = {};
|
|
178
182
|
const design_blocks = [];
|
|
179
183
|
for (const id of module_ids) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
try {
|
|
185
|
+
const zip_archive_url = await module_resolver.get_module_archive_by_id(id);
|
|
186
|
+
const module_circuit = await module_resolver.get_module_circuit_by_id(id);
|
|
187
|
+
if (!module_circuit) {
|
|
188
|
+
console.error(`Module ${id} not found`);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (!zip_archive_url || !module_circuit) {
|
|
192
|
+
console.error(`Module ${module_circuit.author}/${module_circuit.name} not found`);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (!module_circuit.main) {
|
|
196
|
+
console.error(`Missing main entry in module${module_circuit.author}/${module_circuit.name}`);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const k = fmt_module_name(module_circuit);
|
|
200
|
+
module_main_sheet[k] = module_circuit.main;
|
|
201
|
+
modules[k] = module_circuit;
|
|
202
|
+
const design_block = {
|
|
203
|
+
main_sch: module_circuit.main,
|
|
204
|
+
sheets: []
|
|
205
|
+
};
|
|
206
|
+
const zip_archive = await fetch(zip_archive_url).then((res) => res.arrayBuffer());
|
|
207
|
+
const files = await unzipFile2(zip_archive);
|
|
208
|
+
for (const [name, content] of Object.entries(files)) {
|
|
209
|
+
if (name.endsWith(KICAD_SHC_FILE_EXT2)) {
|
|
210
|
+
const filename = remove_filename_path_prefix2(name);
|
|
211
|
+
if (filename in sheets) {
|
|
212
|
+
console.error(`Duplicate sheet name: ${filename}`);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
sheets[filename] = content;
|
|
216
|
+
design_block.sheets.push({ filename, content });
|
|
217
|
+
} else if (name.endsWith(KICAD_PCB_FILE_EXT)) {
|
|
218
|
+
const filename = remove_filename_path_prefix2(name);
|
|
219
|
+
design_block.pcb = { filename, content };
|
|
209
220
|
}
|
|
210
|
-
sheets[filename] = content;
|
|
211
|
-
design_block.sheets.push({ filename, content });
|
|
212
|
-
} else if (name.endsWith(KICAD_PCB_FILE_EXT)) {
|
|
213
|
-
const filename = remove_filename_path_prefix2(name);
|
|
214
|
-
design_block.pcb = { filename, content };
|
|
215
221
|
}
|
|
222
|
+
design_blocks.push(design_block);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error(`Failed to download zip for module : ${e}`);
|
|
216
225
|
}
|
|
217
|
-
design_blocks.push(design_block);
|
|
218
226
|
}
|
|
219
227
|
return { sheets, module_main_sheet, modules, design_blocks };
|
|
220
228
|
}
|
|
@@ -459,7 +467,10 @@ __decoratorMetadata(_init, SCHEMATIC_PRINTER);
|
|
|
459
467
|
|
|
460
468
|
// src/converter/graph_to_netlist/graph_converter.ts
|
|
461
469
|
import {
|
|
462
|
-
ConnectionNodeType as ConnectionNodeType2
|
|
470
|
+
ConnectionNodeType as ConnectionNodeType2,
|
|
471
|
+
LabelShapes,
|
|
472
|
+
PortType as PortType2,
|
|
473
|
+
get_port_type_signals
|
|
463
474
|
} from "@modular-circuit/electronics-model";
|
|
464
475
|
|
|
465
476
|
// src/converter/link_to_netlist/converter.ts
|
|
@@ -491,8 +502,7 @@ var LinkConverterBase = class {
|
|
|
491
502
|
}
|
|
492
503
|
gen_net_name(signal_name) {
|
|
493
504
|
const base_net_name = signal_name ? `${this.net_pros.name}-${signal_name}` : `${this.net_pros.name}`;
|
|
494
|
-
if (this.net_pros.is_global_pwr)
|
|
495
|
-
return base_net_name;
|
|
505
|
+
if (this.net_pros.is_global_pwr) return base_net_name;
|
|
496
506
|
if (!this.ctx.net_names_count.has(base_net_name)) {
|
|
497
507
|
this.ctx.net_names_count.set(base_net_name, 0);
|
|
498
508
|
return base_net_name;
|
|
@@ -1551,14 +1561,33 @@ var GraphConverter = class {
|
|
|
1551
1561
|
for (const node of sub.nodes) {
|
|
1552
1562
|
if (node.type === ConnectionNodeType2.Port) {
|
|
1553
1563
|
const port_id = node.uuid;
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1564
|
+
const ir_port = node.param;
|
|
1565
|
+
port_map.set(ir_port, port_id);
|
|
1566
|
+
if (node.label_shapes) {
|
|
1567
|
+
for (const [label_name, shape] of Object.entries(node.label_shapes)) {
|
|
1568
|
+
const pin_id = `pin-${++pin_count}`;
|
|
1569
|
+
pin_shapes[pin_id] = shape;
|
|
1570
|
+
if (!(port_id in pin_map)) {
|
|
1571
|
+
pin_map[port_id] = {};
|
|
1572
|
+
}
|
|
1573
|
+
pin_map[port_id][label_name] = pin_id;
|
|
1574
|
+
}
|
|
1575
|
+
} else {
|
|
1576
|
+
if (ir_port.type === PortType2.DigitalBidirBundle) {
|
|
1577
|
+
console.error(
|
|
1578
|
+
`DigitalBidirBundle shall be replaced by DigitalBidirs while building connection graph : ${ir_port.name}`
|
|
1579
|
+
);
|
|
1580
|
+
} else {
|
|
1581
|
+
const expected_signals = get_port_type_signals(ir_port.type);
|
|
1582
|
+
for (const signal of expected_signals) {
|
|
1583
|
+
const pin_id = `pin-${++pin_count}`;
|
|
1584
|
+
pin_shapes[pin_id] = LabelShapes.Passive;
|
|
1585
|
+
if (!(port_id in pin_map)) {
|
|
1586
|
+
pin_map[port_id] = {};
|
|
1587
|
+
}
|
|
1588
|
+
pin_map[port_id][`${ir_port.name}-${signal}`] = pin_id;
|
|
1589
|
+
}
|
|
1560
1590
|
}
|
|
1561
|
-
pin_map[port_id][label_name] = pin_id;
|
|
1562
1591
|
}
|
|
1563
1592
|
}
|
|
1564
1593
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/transpiler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Intermediate representation of the modular circuit",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"import": "./dist/index.mjs",
|
|
17
|
-
"require": "./dist/index.js"
|
|
18
|
-
"types": "./dist/index.d.ts"
|
|
17
|
+
"require": "./dist/index.js"
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
@@ -30,10 +29,10 @@
|
|
|
30
29
|
"elkjs": "^0.11.0",
|
|
31
30
|
"js-base64": "^3.7.7",
|
|
32
31
|
"jszip": "^3.10.1",
|
|
33
|
-
"@modular-circuit/
|
|
34
|
-
"@modular-circuit/
|
|
35
|
-
"@modular-circuit/
|
|
36
|
-
"@modular-circuit/utils": "0.1.
|
|
32
|
+
"@modular-circuit/ir": "0.1.2",
|
|
33
|
+
"@modular-circuit/perc": "0.1.4",
|
|
34
|
+
"@modular-circuit/electronics-model": "0.1.1",
|
|
35
|
+
"@modular-circuit/utils": "0.1.2"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|
|
39
38
|
"clean": "rimraf dist",
|