@modular-circuit/transpiler 0.0.86 → 0.0.87
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/build/builder/graph_to_kicad/do_convert_graph_to_kicad_project.js +1 -3
- package/build/converter/netlist_to_kicad/netlist_converter.d.ts +1 -1
- package/build/converter/netlist_to_kicad/netlist_converter.d.ts.map +1 -1
- package/build/converter/netlist_to_kicad/netlist_converter.js +104 -182
- package/package.json +2 -2
|
@@ -87,9 +87,7 @@ export function do_convert_graph_to_kicad_project(ctx) {
|
|
|
87
87
|
case 1:
|
|
88
88
|
sheets = (_e.sent()).sheets;
|
|
89
89
|
netlist = new GraphConverter(__assign({}, ctx)).convert_to_netlist();
|
|
90
|
-
|
|
91
|
-
case 2:
|
|
92
|
-
converted_sheets = _e.sent();
|
|
90
|
+
converted_sheets = new NetListConverter(__assign(__assign({}, ctx), { netlist: netlist })).convert_to_kicad();
|
|
93
91
|
sexpr_printer = new SCHEMATIC_PRINTER();
|
|
94
92
|
try {
|
|
95
93
|
for (_a = __values(Object.entries(converted_sheets)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
@@ -9,7 +9,7 @@ export declare class NetListConverter {
|
|
|
9
9
|
constructor(ctx: NetlistToKicadContext);
|
|
10
10
|
pin_is_connected(id: string): boolean;
|
|
11
11
|
get_pin_net_name(id: string): string;
|
|
12
|
-
convert_to_kicad():
|
|
12
|
+
convert_to_kicad(): Record<string, SCHEMATIC>;
|
|
13
13
|
/**
|
|
14
14
|
* Convert a schematic to a kicad schematic
|
|
15
15
|
* @param name The name of the graph ,also the file name of the converted schematic
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"netlist_converter.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/netlist_converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAYtD,qBAAa,gBAAgB;IASR,OAAO,CAAC,GAAG;IAR9B,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,CAAC,QAAQ,CAA6B;IAE7C,OAAO,CAAC,KAAK,CAAiB;gBAEH,GAAG,EAAE,qBAAqB;IAQrD,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAI3B,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAIpB,gBAAgB;IAYvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IA+DnB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA8CnC,OAAO,CAAC,oBAAoB;IAqC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
|
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
1
|
var __values = (this && this.__values) || function(o) {
|
|
38
2
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
3
|
if (m) return m.call(o);
|
|
@@ -67,8 +31,8 @@ import { replaceAll } from '@modular-circuit/utils';
|
|
|
67
31
|
import { gen_hierarchical_label, gen_net_label, gen_sheet_pin } from '../../kicad/label';
|
|
68
32
|
import { gen_sch_sheet } from '../../kicad/sheet';
|
|
69
33
|
import { gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc } from '../../kicad/symbols';
|
|
70
|
-
import {
|
|
71
|
-
import { BLOCK_PIN_GAP, FONT_SIZE,
|
|
34
|
+
import { GENERATOR_NAME, GENERATOR_VERSION, SCH_VERSION } from '../../utils/constraints';
|
|
35
|
+
import { BLOCK_PIN_GAP, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos, } from './layout';
|
|
72
36
|
import { gen_wire } from '../../kicad/wire/gen_wire';
|
|
73
37
|
var NetListConverter = /** @class */ (function () {
|
|
74
38
|
function NetListConverter(ctx) {
|
|
@@ -110,48 +74,24 @@ var NetListConverter = /** @class */ (function () {
|
|
|
110
74
|
return this.net_name[id];
|
|
111
75
|
};
|
|
112
76
|
NetListConverter.prototype.convert_to_kicad = function () {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
_d = all_sch;
|
|
132
|
-
_e = k;
|
|
133
|
-
return [4 /*yield*/, this.convert_sch(k, v)];
|
|
134
|
-
case 3:
|
|
135
|
-
_d[_e] = _g.sent();
|
|
136
|
-
_g.label = 4;
|
|
137
|
-
case 4:
|
|
138
|
-
_b = _a.next();
|
|
139
|
-
return [3 /*break*/, 2];
|
|
140
|
-
case 5: return [3 /*break*/, 8];
|
|
141
|
-
case 6:
|
|
142
|
-
e_3_1 = _g.sent();
|
|
143
|
-
e_3 = { error: e_3_1 };
|
|
144
|
-
return [3 /*break*/, 8];
|
|
145
|
-
case 7:
|
|
146
|
-
try {
|
|
147
|
-
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
148
|
-
}
|
|
149
|
-
finally { if (e_3) throw e_3.error; }
|
|
150
|
-
return [7 /*endfinally*/];
|
|
151
|
-
case 8: return [2 /*return*/, all_sch];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
77
|
+
var e_3, _a;
|
|
78
|
+
var all_sch = {};
|
|
79
|
+
try {
|
|
80
|
+
for (var _b = __values(Object.entries(this.ctx.netlist.schematics)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
81
|
+
var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
|
|
82
|
+
this.sheet_pwr_count = 0;
|
|
83
|
+
this.block_calc = new Layout();
|
|
84
|
+
all_sch[k] = this.convert_sch(k, v);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
88
|
+
finally {
|
|
89
|
+
try {
|
|
90
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
91
|
+
}
|
|
92
|
+
finally { if (e_3) throw e_3.error; }
|
|
93
|
+
}
|
|
94
|
+
return all_sch;
|
|
155
95
|
};
|
|
156
96
|
/**
|
|
157
97
|
* Convert a schematic to a kicad schematic
|
|
@@ -161,111 +101,93 @@ var NetListConverter = /** @class */ (function () {
|
|
|
161
101
|
* @returns
|
|
162
102
|
*/
|
|
163
103
|
NetListConverter.prototype.convert_sch = function (name, schematic) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
(_k = sch.lib_symbols) === null || _k === void 0 ? void 0 : _k.symbols.push(gen_lib_gnd(it_2.value));
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
powers.add(it_2.value);
|
|
208
|
-
this.convert_pwr_symbol(it_2, get_power_pos(this.sheet_pwr_count++), sch);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
213
|
-
finally {
|
|
214
|
-
try {
|
|
215
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
216
|
-
}
|
|
217
|
-
finally { if (e_4) throw e_4.error; }
|
|
218
|
-
}
|
|
219
|
-
sheet_names_count = new Map();
|
|
220
|
-
ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
|
|
221
|
-
return b.pins.length - a.pins.length;
|
|
222
|
-
});
|
|
223
|
-
sheet_box = {};
|
|
224
|
-
try {
|
|
225
|
-
for (ordered_sheets_1 = __values(ordered_sheets), ordered_sheets_1_1 = ordered_sheets_1.next(); !ordered_sheets_1_1.done; ordered_sheets_1_1 = ordered_sheets_1.next()) {
|
|
226
|
-
it_3 = ordered_sheets_1_1.value;
|
|
227
|
-
sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
|
|
228
|
-
block_geo = this.block_calc.get_block_geometry(sheet_padding);
|
|
229
|
-
sheet_box[it_3.uuid] = block_geo.box;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
233
|
-
finally {
|
|
234
|
-
try {
|
|
235
|
-
if (ordered_sheets_1_1 && !ordered_sheets_1_1.done && (_f = ordered_sheets_1.return)) _f.call(ordered_sheets_1);
|
|
236
|
-
}
|
|
237
|
-
finally { if (e_5) throw e_5.error; }
|
|
238
|
-
}
|
|
239
|
-
try {
|
|
240
|
-
for (ordered_sheets_2 = __values(ordered_sheets), ordered_sheets_2_1 = ordered_sheets_2.next(); !ordered_sheets_2_1.done; ordered_sheets_2_1 = ordered_sheets_2.next()) {
|
|
241
|
-
it_4 = ordered_sheets_2_1.value;
|
|
242
|
-
this.convert_sheet_symbol(it_4, sheet_box[it_4.uuid], sch, sheet_names_count);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
246
|
-
finally {
|
|
247
|
-
try {
|
|
248
|
-
if (ordered_sheets_2_1 && !ordered_sheets_2_1.done && (_g = ordered_sheets_2.return)) _g.call(ordered_sheets_2);
|
|
249
|
-
}
|
|
250
|
-
finally { if (e_6) throw e_6.error; }
|
|
251
|
-
}
|
|
252
|
-
try {
|
|
253
|
-
for (_c = __values(schematic.hiera_labels), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
254
|
-
it_5 = _d.value;
|
|
255
|
-
this.convert_hierarchical_label(it_5, sch);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
259
|
-
finally {
|
|
260
|
-
try {
|
|
261
|
-
if (_d && !_d.done && (_h = _c.return)) _h.call(_c);
|
|
104
|
+
var e_4, _a, e_5, _b, e_6, _c;
|
|
105
|
+
var _d, _e;
|
|
106
|
+
var powers = new Set();
|
|
107
|
+
this.wires = [];
|
|
108
|
+
var sch = {
|
|
109
|
+
version: SCH_VERSION,
|
|
110
|
+
generator: GENERATOR_NAME,
|
|
111
|
+
generator_version: GENERATOR_VERSION,
|
|
112
|
+
paper: {
|
|
113
|
+
size: 'A4',
|
|
114
|
+
},
|
|
115
|
+
title_block: {
|
|
116
|
+
title: name.replace(".".concat(MODULAR_CIRCUIT_SCH_EXT), ''),
|
|
117
|
+
date: replaceAll(new Date().toISOString().slice(0, 10), '-', '/'),
|
|
118
|
+
rev: '1.0',
|
|
119
|
+
comment: {
|
|
120
|
+
1: 'https://www.eda.cn',
|
|
121
|
+
2: this.ctx.project.author,
|
|
122
|
+
3: this.ctx.project.name,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
lib_symbols: {
|
|
126
|
+
symbols: [],
|
|
127
|
+
},
|
|
128
|
+
uuid: schematic.uuid,
|
|
129
|
+
symbols: [],
|
|
130
|
+
labels: [],
|
|
131
|
+
sheets: [],
|
|
132
|
+
};
|
|
133
|
+
try {
|
|
134
|
+
for (var _f = __values(schematic.powers), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
135
|
+
var it_2 = _g.value;
|
|
136
|
+
if (!powers.has(it_2.value)) {
|
|
137
|
+
switch (it_2.shape) {
|
|
138
|
+
case PowerShape.VCC:
|
|
139
|
+
(_d = sch.lib_symbols) === null || _d === void 0 ? void 0 : _d.symbols.push(gen_lib_vcc(it_2.value));
|
|
140
|
+
break;
|
|
141
|
+
case PowerShape.GND:
|
|
142
|
+
(_e = sch.lib_symbols) === null || _e === void 0 ? void 0 : _e.symbols.push(gen_lib_gnd(it_2.value));
|
|
143
|
+
break;
|
|
262
144
|
}
|
|
263
|
-
|
|
145
|
+
powers.add(it_2.value);
|
|
146
|
+
this.convert_pwr_symbol(it_2, get_power_pos(this.sheet_pwr_count++), sch);
|
|
264
147
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
151
|
+
finally {
|
|
152
|
+
try {
|
|
153
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
154
|
+
}
|
|
155
|
+
finally { if (e_4) throw e_4.error; }
|
|
156
|
+
}
|
|
157
|
+
var sheet_names_count = new Map();
|
|
158
|
+
var ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
|
|
159
|
+
return b.pins.length - a.pins.length;
|
|
268
160
|
});
|
|
161
|
+
try {
|
|
162
|
+
for (var ordered_sheets_1 = __values(ordered_sheets), ordered_sheets_1_1 = ordered_sheets_1.next(); !ordered_sheets_1_1.done; ordered_sheets_1_1 = ordered_sheets_1.next()) {
|
|
163
|
+
var it_3 = ordered_sheets_1_1.value;
|
|
164
|
+
var sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
|
|
165
|
+
var block_geo = this.block_calc.get_block_geometry(sheet_padding);
|
|
166
|
+
this.convert_sheet_symbol(it_3, block_geo.box, sch, sheet_names_count);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
170
|
+
finally {
|
|
171
|
+
try {
|
|
172
|
+
if (ordered_sheets_1_1 && !ordered_sheets_1_1.done && (_b = ordered_sheets_1.return)) _b.call(ordered_sheets_1);
|
|
173
|
+
}
|
|
174
|
+
finally { if (e_5) throw e_5.error; }
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
for (var _h = __values(schematic.hiera_labels), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
178
|
+
var it_4 = _j.value;
|
|
179
|
+
this.convert_hierarchical_label(it_4, sch);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
183
|
+
finally {
|
|
184
|
+
try {
|
|
185
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
186
|
+
}
|
|
187
|
+
finally { if (e_6) throw e_6.error; }
|
|
188
|
+
}
|
|
189
|
+
sch.wires = this.wires;
|
|
190
|
+
return sch;
|
|
269
191
|
};
|
|
270
192
|
NetListConverter.prototype.convert_hierarchical_label = function (pin, sch) {
|
|
271
193
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/transpiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.87",
|
|
4
4
|
"description": "Intermediate representation of the modular circuit",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"js-base64": "^3.7.7",
|
|
28
28
|
"jszip": "^3.10.1",
|
|
29
|
+
"@modular-circuit/electronics-model": "0.0.54",
|
|
29
30
|
"@modular-circuit/ir": "0.0.61",
|
|
30
31
|
"@modular-circuit/perc": "0.0.61",
|
|
31
|
-
"@modular-circuit/electronics-model": "0.0.54",
|
|
32
32
|
"@modular-circuit/utils": "0.0.40"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|