@modular-circuit/transpiler 0.0.95 → 0.0.96
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 +3 -1
- package/build/converter/netlist_to_kicad/layout.d.ts +10 -2
- package/build/converter/netlist_to_kicad/layout.d.ts.map +1 -1
- package/build/converter/netlist_to_kicad/layout.js +150 -1
- 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 +206 -111
- package/package.json +4 -3
|
@@ -87,7 +87,9 @@ 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
|
-
|
|
90
|
+
return [4 /*yield*/, new NetListConverter(__assign(__assign({}, ctx), { netlist: netlist })).convert_to_kicad()];
|
|
91
|
+
case 2:
|
|
92
|
+
converted_sheets = _e.sent();
|
|
91
93
|
sexpr_printer = new SCHEMATIC_PRINTER();
|
|
92
94
|
try {
|
|
93
95
|
for (_a = __values(Object.entries(converted_sheets)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BOX2 } from '@modular-circuit/electronics-model';
|
|
1
|
+
import type { BOX2, VECTOR2 } from '@modular-circuit/electronics-model';
|
|
2
2
|
export declare const GRID_SIZE: number;
|
|
3
3
|
export declare const FONT_SIZE: number;
|
|
4
4
|
export declare function get_power_pos(pwr_number: number): {
|
|
@@ -21,10 +21,18 @@ export interface BoxGeometry {
|
|
|
21
21
|
box: BOX2;
|
|
22
22
|
bounding_box: BOX2;
|
|
23
23
|
}
|
|
24
|
+
export interface BlockSize {
|
|
25
|
+
size: VECTOR2;
|
|
26
|
+
bounding_size: VECTOR2;
|
|
27
|
+
}
|
|
24
28
|
export declare class Layout {
|
|
25
29
|
private width;
|
|
26
30
|
private height;
|
|
27
31
|
private max_height;
|
|
28
|
-
|
|
32
|
+
private block_geo;
|
|
33
|
+
private elk;
|
|
34
|
+
add_block(id: string, factor: BlockLabelPadding): void;
|
|
35
|
+
finalize(): Promise<Record<string, BOX2>>;
|
|
36
|
+
private calc_block_size;
|
|
29
37
|
}
|
|
30
38
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/converter/netlist_to_kicad/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAMvE,eAAO,MAAM,SAAS,QAAiB,CAAA;AAEvC,eAAO,MAAM,SAAS,QAAY,CAAA;AAQlC,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM;;;EAE/C;AAKD,eAAO,MAAM,aAAa,QAAgB,CAAA;AAE1C,eAAO,MAAM,mBAAmB,QAAgB,CAAA;AAQhD,eAAO,MAAM,YAAY,QAAY,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,YAAY,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,IAAI,CAAA;IACT,YAAY,EAAE,IAAI,CAAA;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAA;IACb,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEtB,OAAO,CAAC,SAAS,CAAkC;IAEnD,OAAO,CAAC,GAAG,CAAY;IAEhB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB;IAIzC,QAAQ;IAwDrB,OAAO,CAAC,eAAe;CAoDxB"}
|
|
@@ -1,3 +1,67 @@
|
|
|
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
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
64
|
+
import ELK, {} from 'elkjs/lib/elk.bundled.js';
|
|
1
65
|
import { PAPER_SIZE } from '../../utils/constraints';
|
|
2
66
|
var MIL_TO_MM = 0.0254;
|
|
3
67
|
export var GRID_SIZE = 50 * MIL_TO_MM;
|
|
@@ -23,8 +87,93 @@ var Layout = /** @class */ (function () {
|
|
|
23
87
|
this.width = BLOCK_START_X;
|
|
24
88
|
this.height = BLOCK_START_Y;
|
|
25
89
|
this.max_height = 0;
|
|
90
|
+
this.block_geo = {};
|
|
91
|
+
this.elk = new ELK();
|
|
26
92
|
}
|
|
27
|
-
Layout.prototype.
|
|
93
|
+
Layout.prototype.add_block = function (id, factor) {
|
|
94
|
+
this.block_geo[id] = this.calc_block_size(factor);
|
|
95
|
+
};
|
|
96
|
+
Layout.prototype.finalize = function () {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var bbox, graph, _a, _b, _c, id, geo, bounding_size, res, _d, _e, child, geo, pos, block_offset, final_pos;
|
|
99
|
+
var e_1, _f, e_2, _g;
|
|
100
|
+
var _h, _j;
|
|
101
|
+
return __generator(this, function (_k) {
|
|
102
|
+
switch (_k.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
bbox = {};
|
|
105
|
+
graph = {
|
|
106
|
+
id: 'root',
|
|
107
|
+
layoutOptions: {
|
|
108
|
+
'elk.algorithm': 'box',
|
|
109
|
+
'elk.contentAlignment': 'H_LEFT | V_TOP',
|
|
110
|
+
'elk.fixedGraphSize': 'true',
|
|
111
|
+
'elk.spacing.nodeNode': "".concat(GRID_SIZE),
|
|
112
|
+
'elk.padding': "[top=".concat(GRID_SIZE, ",left=").concat(GRID_SIZE, ",bottom=").concat(GRID_SIZE, ",right=").concat(GRID_SIZE, "]"),
|
|
113
|
+
'elk.childAreaWidth': "".concat(PAPER_SIZE.A4.width * MIL_TO_MM - GRID_SIZE * 2),
|
|
114
|
+
'elk.childAreaHeight': "".concat(PAPER_SIZE.A4.height * MIL_TO_MM - GRID_SIZE * 2),
|
|
115
|
+
},
|
|
116
|
+
children: [],
|
|
117
|
+
edges: [],
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
for (_a = __values(Object.entries(this.block_geo)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
121
|
+
_c = __read(_b.value, 2), id = _c[0], geo = _c[1];
|
|
122
|
+
bounding_size = geo.bounding_box.size;
|
|
123
|
+
graph.children.push({
|
|
124
|
+
id: id,
|
|
125
|
+
width: bounding_size.x,
|
|
126
|
+
height: bounding_size.y,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
131
|
+
finally {
|
|
132
|
+
try {
|
|
133
|
+
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
134
|
+
}
|
|
135
|
+
finally { if (e_1) throw e_1.error; }
|
|
136
|
+
}
|
|
137
|
+
return [4 /*yield*/, this.elk.layout(graph)];
|
|
138
|
+
case 1:
|
|
139
|
+
res = _k.sent();
|
|
140
|
+
if (res.children) {
|
|
141
|
+
try {
|
|
142
|
+
for (_d = __values(res.children), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
143
|
+
child = _e.value;
|
|
144
|
+
geo = this.block_geo[child.id];
|
|
145
|
+
pos = {
|
|
146
|
+
x: (_h = child.x) !== null && _h !== void 0 ? _h : 0,
|
|
147
|
+
y: (_j = child.y) !== null && _j !== void 0 ? _j : 0,
|
|
148
|
+
};
|
|
149
|
+
block_offset = {
|
|
150
|
+
x: geo.bounding_box.pos.x - geo.box.pos.x,
|
|
151
|
+
y: geo.bounding_box.pos.y - geo.box.pos.y,
|
|
152
|
+
};
|
|
153
|
+
final_pos = {
|
|
154
|
+
x: pos.x - block_offset.x,
|
|
155
|
+
y: pos.y - block_offset.y,
|
|
156
|
+
};
|
|
157
|
+
bbox[child.id] = {
|
|
158
|
+
pos: final_pos,
|
|
159
|
+
size: geo.box.size,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
164
|
+
finally {
|
|
165
|
+
try {
|
|
166
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
167
|
+
}
|
|
168
|
+
finally { if (e_2) throw e_2.error; }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return [2 /*return*/, bbox];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
Layout.prototype.calc_block_size = function (factor) {
|
|
28
177
|
var block_height = Math.floor(factor.total_pin_num / 2) * BLOCK_PIN_GAP + 2 * BLOCK_PIN_TB_MARGIN;
|
|
29
178
|
var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
|
|
30
179
|
var block_bounding_width = Math.max(block_width, factor.internal.l_side +
|
|
@@ -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(): Record<string, SCHEMATIC
|
|
12
|
+
convert_to_kicad(): Promise<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;AAmBtD,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;IAId,gBAAgB;IAY7B;;;;;;OAMG;YACW,WAAW;IAwEzB,OAAO,CAAC,0BAA0B;IAMlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
|
|
@@ -1,3 +1,39 @@
|
|
|
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
|
+
};
|
|
1
37
|
var __values = (this && this.__values) || function(o) {
|
|
2
38
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
39
|
if (m) return m.call(o);
|
|
@@ -32,8 +68,13 @@ import { gen_hierarchical_label, gen_net_label, gen_sheet_pin } from '../../kica
|
|
|
32
68
|
import { gen_sch_sheet } from '../../kicad/sheet';
|
|
33
69
|
import { gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc } from '../../kicad/symbols';
|
|
34
70
|
import { GENERATOR_NAME, GENERATOR_VERSION, SCH_VERSION } from '../../utils/constraints';
|
|
35
|
-
import { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos } from './layout';
|
|
71
|
+
import { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos, } from './layout';
|
|
36
72
|
import { gen_wire } from '../../kicad/wire/gen_wire';
|
|
73
|
+
var H_LABEL_FACTOR = {
|
|
74
|
+
internal: { l_side: 0, r_side: 0 },
|
|
75
|
+
outer: { l_side: 0, r_side: 0 },
|
|
76
|
+
total_pin_num: 1,
|
|
77
|
+
};
|
|
37
78
|
var NetListConverter = /** @class */ (function () {
|
|
38
79
|
function NetListConverter(ctx) {
|
|
39
80
|
var e_1, _a, e_2, _b;
|
|
@@ -74,24 +115,47 @@ var NetListConverter = /** @class */ (function () {
|
|
|
74
115
|
return this.net_name[id];
|
|
75
116
|
};
|
|
76
117
|
NetListConverter.prototype.convert_to_kicad = function () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
var all_sch, _a, _b, _c, k, v, _d, _e, e_3_1;
|
|
120
|
+
var e_3, _f;
|
|
121
|
+
return __generator(this, function (_g) {
|
|
122
|
+
switch (_g.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
all_sch = {};
|
|
125
|
+
_g.label = 1;
|
|
126
|
+
case 1:
|
|
127
|
+
_g.trys.push([1, 6, 7, 8]);
|
|
128
|
+
_a = __values(Object.entries(this.ctx.netlist.schematics)), _b = _a.next();
|
|
129
|
+
_g.label = 2;
|
|
130
|
+
case 2:
|
|
131
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
132
|
+
_c = __read(_b.value, 2), k = _c[0], v = _c[1];
|
|
133
|
+
this.sheet_pwr_count = 0;
|
|
134
|
+
this.block_calc = new Layout();
|
|
135
|
+
_d = all_sch;
|
|
136
|
+
_e = k;
|
|
137
|
+
return [4 /*yield*/, this.convert_sch(k, v)];
|
|
138
|
+
case 3:
|
|
139
|
+
_d[_e] = _g.sent();
|
|
140
|
+
_g.label = 4;
|
|
141
|
+
case 4:
|
|
142
|
+
_b = _a.next();
|
|
143
|
+
return [3 /*break*/, 2];
|
|
144
|
+
case 5: return [3 /*break*/, 8];
|
|
145
|
+
case 6:
|
|
146
|
+
e_3_1 = _g.sent();
|
|
147
|
+
e_3 = { error: e_3_1 };
|
|
148
|
+
return [3 /*break*/, 8];
|
|
149
|
+
case 7:
|
|
150
|
+
try {
|
|
151
|
+
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
152
|
+
}
|
|
153
|
+
finally { if (e_3) throw e_3.error; }
|
|
154
|
+
return [7 /*endfinally*/];
|
|
155
|
+
case 8: return [2 /*return*/, all_sch];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
95
159
|
};
|
|
96
160
|
/**
|
|
97
161
|
* Convert a schematic to a kicad schematic
|
|
@@ -101,102 +165,133 @@ var NetListConverter = /** @class */ (function () {
|
|
|
101
165
|
* @returns
|
|
102
166
|
*/
|
|
103
167
|
NetListConverter.prototype.convert_sch = function (name, schematic) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
168
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
+
var powers, sch, _a, _b, it_2, sheet_names_count, ordered_sheets, ordered_sheets_1, ordered_sheets_1_1, it_3, sheet_padding, _c, _d, it_4, res, ordered_sheets_2, ordered_sheets_2_1, it_5, _e, _f, it_6;
|
|
170
|
+
var e_4, _g, e_5, _h, e_6, _j, e_7, _k, e_8, _l;
|
|
171
|
+
var _m, _o;
|
|
172
|
+
return __generator(this, function (_p) {
|
|
173
|
+
switch (_p.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
powers = new Set();
|
|
176
|
+
this.wires = [];
|
|
177
|
+
sch = {
|
|
178
|
+
version: SCH_VERSION,
|
|
179
|
+
generator: GENERATOR_NAME,
|
|
180
|
+
generator_version: GENERATOR_VERSION,
|
|
181
|
+
paper: {
|
|
182
|
+
size: 'A4',
|
|
183
|
+
},
|
|
184
|
+
title_block: {
|
|
185
|
+
title: name.replace(".".concat(MODULAR_CIRCUIT_SCH_EXT), ''),
|
|
186
|
+
date: replaceAll(new Date().toISOString().slice(0, 10), '-', '/'),
|
|
187
|
+
rev: '1.0',
|
|
188
|
+
comment: {
|
|
189
|
+
1: 'https://www.eda.cn',
|
|
190
|
+
2: this.ctx.project.author,
|
|
191
|
+
3: this.ctx.project.name,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
lib_symbols: {
|
|
195
|
+
symbols: [],
|
|
196
|
+
},
|
|
197
|
+
uuid: schematic.uuid,
|
|
198
|
+
symbols: [],
|
|
199
|
+
labels: [],
|
|
200
|
+
sheets: [],
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
for (_a = __values(schematic.powers), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
204
|
+
it_2 = _b.value;
|
|
205
|
+
if (!powers.has(it_2.value)) {
|
|
206
|
+
switch (it_2.shape) {
|
|
207
|
+
case PowerShape.VCC:
|
|
208
|
+
(_m = sch.lib_symbols) === null || _m === void 0 ? void 0 : _m.symbols.push(gen_lib_vcc(it_2.value));
|
|
209
|
+
break;
|
|
210
|
+
case PowerShape.GND:
|
|
211
|
+
(_o = sch.lib_symbols) === null || _o === void 0 ? void 0 : _o.symbols.push(gen_lib_gnd(it_2.value));
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
powers.add(it_2.value);
|
|
215
|
+
this.convert_pwr_symbol(it_2, get_power_pos(this.sheet_pwr_count++), sch);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
220
|
+
finally {
|
|
221
|
+
try {
|
|
222
|
+
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
223
|
+
}
|
|
224
|
+
finally { if (e_4) throw e_4.error; }
|
|
225
|
+
}
|
|
226
|
+
sheet_names_count = new Map();
|
|
227
|
+
ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
|
|
228
|
+
return b.pins.length - a.pins.length;
|
|
229
|
+
});
|
|
230
|
+
try {
|
|
231
|
+
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()) {
|
|
232
|
+
it_3 = ordered_sheets_1_1.value;
|
|
233
|
+
sheet_padding = this.get_sheet_symbol_lb_padding(it_3);
|
|
234
|
+
this.block_calc.add_block(it_3.uuid, sheet_padding);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
238
|
+
finally {
|
|
239
|
+
try {
|
|
240
|
+
if (ordered_sheets_1_1 && !ordered_sheets_1_1.done && (_h = ordered_sheets_1.return)) _h.call(ordered_sheets_1);
|
|
241
|
+
}
|
|
242
|
+
finally { if (e_5) throw e_5.error; }
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
for (_c = __values(schematic.hiera_labels), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
246
|
+
it_4 = _d.value;
|
|
247
|
+
this.block_calc.add_block(it_4.uuid, H_LABEL_FACTOR);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
251
|
+
finally {
|
|
252
|
+
try {
|
|
253
|
+
if (_d && !_d.done && (_j = _c.return)) _j.call(_c);
|
|
254
|
+
}
|
|
255
|
+
finally { if (e_6) throw e_6.error; }
|
|
256
|
+
}
|
|
257
|
+
return [4 /*yield*/, this.block_calc.finalize()];
|
|
258
|
+
case 1:
|
|
259
|
+
res = _p.sent();
|
|
260
|
+
try {
|
|
261
|
+
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()) {
|
|
262
|
+
it_5 = ordered_sheets_2_1.value;
|
|
263
|
+
this.convert_sheet_symbol(it_5, res[it_5.uuid], sch, sheet_names_count);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
267
|
+
finally {
|
|
268
|
+
try {
|
|
269
|
+
if (ordered_sheets_2_1 && !ordered_sheets_2_1.done && (_k = ordered_sheets_2.return)) _k.call(ordered_sheets_2);
|
|
270
|
+
}
|
|
271
|
+
finally { if (e_7) throw e_7.error; }
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
for (_e = __values(schematic.hiera_labels), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
275
|
+
it_6 = _f.value;
|
|
276
|
+
this.convert_hierarchical_label(it_6, res[it_6.uuid], sch);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
280
|
+
finally {
|
|
281
|
+
try {
|
|
282
|
+
if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
|
|
283
|
+
}
|
|
284
|
+
finally { if (e_8) throw e_8.error; }
|
|
285
|
+
}
|
|
286
|
+
sch.wires = this.wires;
|
|
287
|
+
return [2 /*return*/, sch];
|
|
147
288
|
}
|
|
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;
|
|
289
|
+
});
|
|
160
290
|
});
|
|
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;
|
|
191
291
|
};
|
|
192
|
-
NetListConverter.prototype.convert_hierarchical_label = function (pin, sch) {
|
|
292
|
+
NetListConverter.prototype.convert_hierarchical_label = function (pin, bbox, sch) {
|
|
193
293
|
var _a;
|
|
194
|
-
|
|
195
|
-
internal: { l_side: 0, r_side: 0 },
|
|
196
|
-
outer: { l_side: 0, r_side: 0 },
|
|
197
|
-
total_pin_num: 1,
|
|
198
|
-
}).box.pos;
|
|
199
|
-
(_a = sch.labels) === null || _a === void 0 ? void 0 : _a.push(gen_hierarchical_label(pin.name, pin_pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
|
|
294
|
+
(_a = sch.labels) === null || _a === void 0 ? void 0 : _a.push(gen_hierarchical_label(pin.name, bbox.pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
|
|
200
295
|
};
|
|
201
296
|
NetListConverter.prototype.convert_pwr_symbol = function (pwr, at, sch) {
|
|
202
297
|
// NOTE : The power uuid is used as the uuid of its pin ,cause all power symbols have only one pin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/transpiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.96",
|
|
4
4
|
"description": "Intermediate representation of the modular circuit",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
"typescript": "^5.4.5"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"elkjs": "^0.11.0",
|
|
27
28
|
"js-base64": "^3.7.7",
|
|
28
29
|
"jszip": "^3.10.1",
|
|
29
30
|
"@modular-circuit/electronics-model": "0.0.54",
|
|
30
31
|
"@modular-circuit/ir": "0.0.63",
|
|
31
|
-
"@modular-circuit/
|
|
32
|
-
"@modular-circuit/
|
|
32
|
+
"@modular-circuit/perc": "0.0.61",
|
|
33
|
+
"@modular-circuit/utils": "0.0.41"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"clean": "rimraf build",
|