@modular-circuit/transpiler 0.0.75 → 0.0.77
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 +19 -106
- package/build/builder/graph_to_kicad/index.js +4 -59
- package/build/converter/graph_to_netlist/graph_converter.js +51 -171
- package/build/converter/kicad_sexpr/eeschema/drawing_sheet/sch_default_drawing_sheet.js +1 -1
- package/build/converter/kicad_sexpr/eeschema/printer.js +245 -290
- package/build/converter/link_to_netlist/converter.js +77 -135
- package/build/converter/link_to_netlist/links/converter_base.js +38 -131
- package/build/converter/link_to_netlist/links/converters.js +316 -554
- package/build/converter/netlist_to_kicad/calc_boxes_pos.js +17 -39
- package/build/converter/netlist_to_kicad/layout.js +28 -32
- package/build/converter/netlist_to_kicad/netlist_converter.js +98 -201
- package/build/kicad/constraints/index.js +1 -1
- package/build/kicad/label/net_label.js +2 -2
- package/build/kicad/label/sheet_pin.js +11 -19
- package/build/kicad/project/kicad_prl.js +3 -3
- package/build/kicad/project/kicad_pro.js +4 -4
- package/build/kicad/project/kicad_project_achieve.js +31 -45
- package/build/kicad/project/wildcards_and_files_ext.js +61 -61
- package/build/kicad/sheet/sheet.js +3 -3
- package/build/kicad/symbols/lib_symbol/gnd.js +6 -6
- package/build/kicad/symbols/lib_symbol/vcc.js +7 -7
- package/build/kicad/symbols/sch_symbol/gnd.js +9 -9
- package/build/kicad/symbols/sch_symbol/vcc.js +9 -9
- package/build/kicad/symbols/symbol_utils.js +1 -1
- package/build/kicad/wire/gen_wire.js +4 -4
- package/build/utils/collect_sub_sheets.js +37 -151
- package/build/utils/constraints.js +6 -6
- package/build/utils/filter_null_undefined.js +2 -31
- package/build/utils/string_formatter.js +23 -29
- package/package.json +5 -5
|
@@ -1,54 +1,32 @@
|
|
|
1
|
-
var __values = (this && this.__values) || function(o) {
|
|
2
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
-
if (m) return m.call(o);
|
|
4
|
-
if (o && typeof o.length === "number") return {
|
|
5
|
-
next: function () {
|
|
6
|
-
if (o && i >= o.length) o = void 0;
|
|
7
|
-
return { value: o && o[i++], done: !o };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
1
|
import Yoga from 'yoga-layout';
|
|
13
2
|
import { DEFAULT_PAPER_SIZE } from '../../utils';
|
|
14
3
|
import { GRID_SIZE } from './layout';
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
var node = Yoga.Node.create();
|
|
4
|
+
export const calc_boxes_pos = (boxes) => {
|
|
5
|
+
const node = Yoga.Node.create();
|
|
18
6
|
node.setAlignContent(Yoga.ALIGN_CENTER);
|
|
19
7
|
node.setWidth(DEFAULT_PAPER_SIZE.width / GRID_SIZE);
|
|
20
8
|
node.setHeight(DEFAULT_PAPER_SIZE.height / GRID_SIZE);
|
|
21
9
|
node.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
22
10
|
node.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
23
11
|
node.setPadding(Yoga.EDGE_ALL, 1);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
child.setMargin(Yoga.EDGE_ALL, 2);
|
|
36
|
-
node.insertChild(child, node.getChildCount());
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
40
|
-
finally {
|
|
41
|
-
try {
|
|
42
|
-
if (idList_1_1 && !idList_1_1.done && (_a = idList_1.return)) _a.call(idList_1);
|
|
43
|
-
}
|
|
44
|
-
finally { if (e_1) throw e_1.error; }
|
|
12
|
+
const idList = Object.keys(boxes);
|
|
13
|
+
for (const id of idList) {
|
|
14
|
+
const box = boxes[id];
|
|
15
|
+
const child = Yoga.Node.create();
|
|
16
|
+
// Use box.x and box.y as width and height (assuming VECTOR2 is { x, y })
|
|
17
|
+
const width = box.x / GRID_SIZE;
|
|
18
|
+
const height = box.y / GRID_SIZE;
|
|
19
|
+
child.setWidth(width);
|
|
20
|
+
child.setHeight(height);
|
|
21
|
+
child.setMargin(Yoga.EDGE_ALL, 2);
|
|
22
|
+
node.insertChild(child, node.getChildCount());
|
|
45
23
|
}
|
|
46
24
|
node.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
|
47
25
|
// Map layout result by id
|
|
48
|
-
|
|
49
|
-
for (
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
const result = {};
|
|
27
|
+
for (let i = 0; i < idList.length; i++) {
|
|
28
|
+
const id = idList[i];
|
|
29
|
+
const child = node.getChild(i);
|
|
52
30
|
result[id] = {
|
|
53
31
|
x: child.getComputedLeft() * GRID_SIZE,
|
|
54
32
|
y: child.getComputedTop() * GRID_SIZE,
|
|
@@ -1,38 +1,36 @@
|
|
|
1
1
|
import { PAPER_SIZE } from '../../utils/constraints';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const MIL_TO_MM = 0.0254;
|
|
3
|
+
export const GRID_SIZE = 50 * MIL_TO_MM;
|
|
4
|
+
export const FONT_SIZE = GRID_SIZE;
|
|
5
|
+
const POWER_START_Y = 30 * GRID_SIZE;
|
|
6
|
+
const POWER_START_X = (PAPER_SIZE.A4.height - 30) * GRID_SIZE;
|
|
7
|
+
const POWER_Y_STEP = 16 * GRID_SIZE;
|
|
8
8
|
export function get_power_pos(pwr_number) {
|
|
9
9
|
return { x: POWER_START_X, y: POWER_START_Y + POWER_Y_STEP * pwr_number };
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
|
|
29
|
-
var block_bounding_width = Math.max(block_width, factor.internal.l_side +
|
|
11
|
+
const BLOCK_START_Y = 36 * GRID_SIZE;
|
|
12
|
+
const BLOCK_START_X = BLOCK_START_Y;
|
|
13
|
+
export const BLOCK_PIN_GAP = 3 * GRID_SIZE;
|
|
14
|
+
const BLOCK_MARGIN_TOP = 8 * GRID_SIZE;
|
|
15
|
+
const MIN_BLOCK_WIDTH = 8 * GRID_SIZE;
|
|
16
|
+
const BLOCK_MARGIN_LEFT = 16 * GRID_SIZE;
|
|
17
|
+
const BLOCK_MARGIN_RIGHT = BLOCK_MARGIN_LEFT;
|
|
18
|
+
const INTERNAL_LABEL_MARGIN = 8 * FONT_SIZE;
|
|
19
|
+
export const WIRE_PADDING = GRID_SIZE;
|
|
20
|
+
export class Layout {
|
|
21
|
+
width = BLOCK_START_X;
|
|
22
|
+
height = BLOCK_START_Y;
|
|
23
|
+
max_height = 0;
|
|
24
|
+
get_block_geometry(factor) {
|
|
25
|
+
const block_height = (BLOCK_PIN_GAP * factor.total_pin_num) / 2 + BLOCK_PIN_GAP * 2;
|
|
26
|
+
const block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
|
|
27
|
+
const block_bounding_width = Math.max(block_width, factor.internal.l_side +
|
|
30
28
|
factor.internal.r_side +
|
|
31
29
|
factor.outer.l_side +
|
|
32
30
|
factor.outer.r_side +
|
|
33
31
|
// | txt | | txt |
|
|
34
32
|
WIRE_PADDING * 4);
|
|
35
|
-
|
|
33
|
+
const box = {
|
|
36
34
|
pos: {
|
|
37
35
|
x: this.width,
|
|
38
36
|
y: this.height,
|
|
@@ -42,7 +40,7 @@ var Layout = /** @class */ (function () {
|
|
|
42
40
|
y: block_height,
|
|
43
41
|
},
|
|
44
42
|
};
|
|
45
|
-
|
|
43
|
+
const bounding_box = {
|
|
46
44
|
pos: {
|
|
47
45
|
x: this.width,
|
|
48
46
|
y: this.height,
|
|
@@ -59,8 +57,6 @@ var Layout = /** @class */ (function () {
|
|
|
59
57
|
this.height += this.max_height + BLOCK_MARGIN_TOP;
|
|
60
58
|
this.max_height = 0;
|
|
61
59
|
}
|
|
62
|
-
return { box
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}());
|
|
66
|
-
export { Layout };
|
|
60
|
+
return { box, bounding_box };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
var __values = (this && this.__values) || function(o) {
|
|
2
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
-
if (m) return m.call(o);
|
|
4
|
-
if (o && typeof o.length === "number") return {
|
|
5
|
-
next: function () {
|
|
6
|
-
if (o && i >= o.length) o = void 0;
|
|
7
|
-
return { value: o && o[i++], done: !o };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
1
|
import { PowerShape } from '@modular-circuit/electronics-model';
|
|
29
2
|
import { MODULAR_CIRCUIT_SCH_EXT, } from '@modular-circuit/ir';
|
|
30
3
|
import { replaceAll } from '@modular-circuit/utils';
|
|
@@ -35,66 +8,36 @@ import { GENERATOR_NAME, GENERATOR_VERSION, SCH_VERSION } from '../../utils/cons
|
|
|
35
8
|
import { BLOCK_PIN_GAP, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos } from './layout';
|
|
36
9
|
import { gen_wire } from '../../kicad/wire/gen_wire';
|
|
37
10
|
import { calc_boxes_pos } from './calc_boxes_pos';
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
export class NetListConverter {
|
|
12
|
+
ctx;
|
|
13
|
+
block_calc;
|
|
14
|
+
sheet_pwr_count = 0;
|
|
15
|
+
net_name = {};
|
|
16
|
+
wires = [];
|
|
17
|
+
constructor(ctx) {
|
|
41
18
|
this.ctx = ctx;
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
for (var _c = __values(this.ctx.netlist.nets), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
47
|
-
var net = _d.value;
|
|
48
|
-
try {
|
|
49
|
-
for (var _e = (e_2 = void 0, __values(net.pins)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
50
|
-
var it_1 = _f.value;
|
|
51
|
-
this.net_name[it_1] = net.name;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
55
|
-
finally {
|
|
56
|
-
try {
|
|
57
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
58
|
-
}
|
|
59
|
-
finally { if (e_2) throw e_2.error; }
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64
|
-
finally {
|
|
65
|
-
try {
|
|
66
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
19
|
+
for (const net of this.ctx.netlist.nets) {
|
|
20
|
+
for (const it of net.pins) {
|
|
21
|
+
this.net_name[it] = net.name;
|
|
67
22
|
}
|
|
68
|
-
finally { if (e_1) throw e_1.error; }
|
|
69
23
|
}
|
|
70
24
|
}
|
|
71
|
-
|
|
25
|
+
pin_is_connected(id) {
|
|
72
26
|
return this.net_name[id] !== undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
27
|
+
}
|
|
28
|
+
get_pin_net_name(id) {
|
|
75
29
|
return this.net_name[id];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.block_calc = new Layout();
|
|
85
|
-
this.wires = [];
|
|
86
|
-
all_sch[k] = this.convert_sch(k, v);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
90
|
-
finally {
|
|
91
|
-
try {
|
|
92
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
93
|
-
}
|
|
94
|
-
finally { if (e_3) throw e_3.error; }
|
|
30
|
+
}
|
|
31
|
+
convert_to_kicad() {
|
|
32
|
+
const all_sch = {};
|
|
33
|
+
for (const [k, v] of Object.entries(this.ctx.netlist.schematics)) {
|
|
34
|
+
this.sheet_pwr_count = 0;
|
|
35
|
+
this.block_calc = new Layout();
|
|
36
|
+
this.wires = [];
|
|
37
|
+
all_sch[k] = this.convert_sch(k, v);
|
|
95
38
|
}
|
|
96
39
|
return all_sch;
|
|
97
|
-
}
|
|
40
|
+
}
|
|
98
41
|
/**
|
|
99
42
|
* Convert a schematic to a kicad schematic
|
|
100
43
|
* @param name The name of the graph ,also the file name of the converted schematic
|
|
@@ -102,11 +45,9 @@ var NetListConverter = /** @class */ (function () {
|
|
|
102
45
|
* no need to handle them before the other types of label are introduced, e.g. global or hierarchical
|
|
103
46
|
* @returns
|
|
104
47
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var powers = new Set();
|
|
109
|
-
var sch = {
|
|
48
|
+
convert_sch(name, schematic) {
|
|
49
|
+
const powers = new Set();
|
|
50
|
+
const sch = {
|
|
110
51
|
version: SCH_VERSION,
|
|
111
52
|
generator: GENERATOR_NAME,
|
|
112
53
|
generator_version: GENERATOR_VERSION,
|
|
@@ -114,7 +55,7 @@ var NetListConverter = /** @class */ (function () {
|
|
|
114
55
|
size: 'A4',
|
|
115
56
|
},
|
|
116
57
|
title_block: {
|
|
117
|
-
title: name.replace(
|
|
58
|
+
title: name.replace(`.${MODULAR_CIRCUIT_SCH_EXT}`, ''),
|
|
118
59
|
date: replaceAll(new Date().toISOString().slice(0, 10), '-', '/'),
|
|
119
60
|
rev: '1.0',
|
|
120
61
|
comment: {
|
|
@@ -131,106 +72,65 @@ var NetListConverter = /** @class */ (function () {
|
|
|
131
72
|
labels: [],
|
|
132
73
|
sheets: [],
|
|
133
74
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
(_f = sch.lib_symbols) === null || _f === void 0 ? void 0 : _f.symbols.push(gen_lib_gnd(it_2.value));
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
powers.add(it_2.value);
|
|
147
|
-
this.convert_pwr_symbol(it_2, get_power_pos(this.sheet_pwr_count++), sch);
|
|
75
|
+
for (const it of schematic.powers) {
|
|
76
|
+
if (!powers.has(it.value)) {
|
|
77
|
+
switch (it.shape) {
|
|
78
|
+
case PowerShape.VCC:
|
|
79
|
+
sch.lib_symbols?.symbols.push(gen_lib_vcc(it.value));
|
|
80
|
+
break;
|
|
81
|
+
case PowerShape.GND:
|
|
82
|
+
sch.lib_symbols?.symbols.push(gen_lib_gnd(it.value));
|
|
83
|
+
break;
|
|
148
84
|
}
|
|
85
|
+
powers.add(it.value);
|
|
86
|
+
this.convert_pwr_symbol(it, get_power_pos(this.sheet_pwr_count++), sch);
|
|
149
87
|
}
|
|
150
88
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
try {
|
|
154
|
-
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
155
|
-
}
|
|
156
|
-
finally { if (e_4) throw e_4.error; }
|
|
157
|
-
}
|
|
158
|
-
var sheet_names_count = new Map();
|
|
159
|
-
var ordered_sheets = schematic.sheet_symbols.sort(function (a, b) {
|
|
89
|
+
const sheet_names_count = new Map();
|
|
90
|
+
const ordered_sheets = schematic.sheet_symbols.sort((a, b) => {
|
|
160
91
|
return b.pins.length - a.pins.length;
|
|
161
92
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
var sheet_pos = calc_boxes_pos(sheet_bounding_boxes);
|
|
181
|
-
try {
|
|
182
|
-
for (var 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()) {
|
|
183
|
-
var it_4 = ordered_sheets_2_1.value;
|
|
184
|
-
this.convert_sheet_symbol(it_4, {
|
|
185
|
-
pos: sheet_pos[it_4.uuid],
|
|
186
|
-
size: sheet_size[it_4.uuid],
|
|
187
|
-
}, sch, sheet_names_count);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
191
|
-
finally {
|
|
192
|
-
try {
|
|
193
|
-
if (ordered_sheets_2_1 && !ordered_sheets_2_1.done && (_c = ordered_sheets_2.return)) _c.call(ordered_sheets_2);
|
|
194
|
-
}
|
|
195
|
-
finally { if (e_6) throw e_6.error; }
|
|
196
|
-
}
|
|
197
|
-
try {
|
|
198
|
-
for (var _j = __values(schematic.hiera_labels), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
199
|
-
var it_5 = _k.value;
|
|
200
|
-
this.convert_hierarchical_label(it_5, sch);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
204
|
-
finally {
|
|
205
|
-
try {
|
|
206
|
-
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
207
|
-
}
|
|
208
|
-
finally { if (e_7) throw e_7.error; }
|
|
93
|
+
const sheet_bounding_boxes = {};
|
|
94
|
+
const sheet_size = {};
|
|
95
|
+
for (const it of ordered_sheets) {
|
|
96
|
+
const sheet_padding = this.get_sheet_symbol_lb_padding(it);
|
|
97
|
+
const block_geo = this.block_calc.get_block_geometry(sheet_padding);
|
|
98
|
+
sheet_bounding_boxes[it.uuid] = block_geo.bounding_box.size;
|
|
99
|
+
sheet_size[it.uuid] = block_geo.box.size;
|
|
100
|
+
}
|
|
101
|
+
const sheet_pos = calc_boxes_pos(sheet_bounding_boxes);
|
|
102
|
+
for (const it of ordered_sheets) {
|
|
103
|
+
this.convert_sheet_symbol(it, {
|
|
104
|
+
pos: sheet_pos[it.uuid],
|
|
105
|
+
size: sheet_size[it.uuid],
|
|
106
|
+
}, sch, sheet_names_count);
|
|
107
|
+
}
|
|
108
|
+
for (const it of schematic.hiera_labels) {
|
|
109
|
+
this.convert_hierarchical_label(it, sch);
|
|
209
110
|
}
|
|
210
111
|
sch.wires = this.wires;
|
|
211
112
|
return sch;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
var _a;
|
|
113
|
+
}
|
|
114
|
+
convert_hierarchical_label(pin, sch) {
|
|
215
115
|
// FIXME: layout them in the Yoga layout
|
|
216
|
-
|
|
116
|
+
const pin_pos = this.block_calc.get_block_geometry({
|
|
217
117
|
internal: { l_side: 0, r_side: 0 },
|
|
218
118
|
outer: { l_side: 0, r_side: 0 },
|
|
219
119
|
total_pin_num: 1,
|
|
220
120
|
}).box.pos;
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
121
|
+
sch.labels?.push(gen_hierarchical_label(pin.name, pin_pos, { horizontal: 'left', vertical: 'bottom' }, 0, pin.shape));
|
|
122
|
+
}
|
|
123
|
+
convert_pwr_symbol(pwr, at, sch) {
|
|
224
124
|
// NOTE : The power uuid is used as the uuid of its pin ,cause all power symbols have only one pin
|
|
225
|
-
|
|
226
|
-
|
|
125
|
+
const pin_id = pwr.uuid;
|
|
126
|
+
const sch_pwr_symbol = pwr.shape === PowerShape.VCC
|
|
227
127
|
? gen_sch_vcc(pwr.value, this.sheet_pwr_count, pin_id, at)
|
|
228
128
|
: gen_sch_gnd(pwr.value, this.sheet_pwr_count, pin_id, at);
|
|
229
129
|
sch.symbols.push(sch_pwr_symbol);
|
|
230
130
|
this.convert_net_label(pwr.value, at, sch);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
131
|
+
}
|
|
132
|
+
get_sheet_symbol_lb_padding(sheet_sym) {
|
|
133
|
+
const factor = {
|
|
234
134
|
internal: {
|
|
235
135
|
l_side: 0,
|
|
236
136
|
r_side: 0,
|
|
@@ -241,10 +141,10 @@ var NetListConverter = /** @class */ (function () {
|
|
|
241
141
|
},
|
|
242
142
|
total_pin_num: sheet_sym.pins.length,
|
|
243
143
|
};
|
|
244
|
-
|
|
245
|
-
for (
|
|
246
|
-
|
|
247
|
-
|
|
144
|
+
const port_count = sheet_sym.pins.length;
|
|
145
|
+
for (let i = 0; i < port_count; i++) {
|
|
146
|
+
const is_left = i < port_count / 2;
|
|
147
|
+
const cur_pin = sheet_sym.pins[i];
|
|
248
148
|
if (is_left) {
|
|
249
149
|
factor.internal.l_side = Math.max(factor.internal.l_side, cur_pin.name.length);
|
|
250
150
|
}
|
|
@@ -252,7 +152,7 @@ var NetListConverter = /** @class */ (function () {
|
|
|
252
152
|
factor.internal.r_side = Math.max(factor.internal.r_side, cur_pin.name.length);
|
|
253
153
|
}
|
|
254
154
|
if (this.pin_is_connected(cur_pin.uuid)) {
|
|
255
|
-
|
|
155
|
+
const net_name = this.get_pin_net_name(cur_pin.uuid);
|
|
256
156
|
if (is_left) {
|
|
257
157
|
factor.outer.l_side = Math.max(factor.outer.l_side, net_name.length);
|
|
258
158
|
}
|
|
@@ -272,22 +172,22 @@ var NetListConverter = /** @class */ (function () {
|
|
|
272
172
|
},
|
|
273
173
|
total_pin_num: sheet_sym.pins.length,
|
|
274
174
|
};
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
for (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x
|
|
286
|
-
}
|
|
287
|
-
|
|
175
|
+
}
|
|
176
|
+
convert_sheet_symbol(sheet_sym, rect, sch, sheet_names_count) {
|
|
177
|
+
const port_count = sheet_sym.pins.length;
|
|
178
|
+
const pins = [];
|
|
179
|
+
for (let i = 0; i < port_count; i++) {
|
|
180
|
+
const is_left = i < port_count / 2;
|
|
181
|
+
const x = is_left ? rect.pos.x : rect.pos.x + rect.size.x;
|
|
182
|
+
const y = rect.pos.y + BLOCK_PIN_GAP * ((i < port_count / 2 ? i : i - port_count / 2) + 1);
|
|
183
|
+
const justify = is_left ? 'left' : 'right';
|
|
184
|
+
const rotation = is_left ? 180 : 0;
|
|
185
|
+
pins.push(this.convert_sheet_pin(sheet_sym.pins[i], { x, y }, sch, justify, rotation, is_left));
|
|
186
|
+
}
|
|
187
|
+
let sheet_name = sheet_sym.sheet_name;
|
|
288
188
|
if (sheet_names_count.has(sheet_name)) {
|
|
289
|
-
|
|
290
|
-
sheet_name +=
|
|
189
|
+
const count = sheet_names_count.get(sheet_name);
|
|
190
|
+
sheet_name += `_${count}`;
|
|
291
191
|
sheet_names_count.set(sheet_name, count + 1);
|
|
292
192
|
}
|
|
293
193
|
else {
|
|
@@ -297,27 +197,24 @@ var NetListConverter = /** @class */ (function () {
|
|
|
297
197
|
Sheetfile: sheet_sym.sheet_file_name,
|
|
298
198
|
Sheetname: sheet_name,
|
|
299
199
|
}));
|
|
300
|
-
}
|
|
301
|
-
|
|
200
|
+
}
|
|
201
|
+
convert_sheet_pin(pin, pin_pos, sch, horizontal, rotation, is_left) {
|
|
302
202
|
if (this.pin_is_connected(pin.uuid)) {
|
|
303
|
-
|
|
203
|
+
const nt_name = this.get_pin_net_name(pin.uuid);
|
|
304
204
|
this.convert_net_label(nt_name, {
|
|
305
205
|
x: pin_pos.x + (is_left ? -WIRE_PADDING : WIRE_PADDING),
|
|
306
206
|
y: pin_pos.y,
|
|
307
207
|
}, sch, horizontal === 'left' ? 'right' : 'left');
|
|
308
|
-
|
|
309
|
-
|
|
208
|
+
const lb_txt_len = nt_name.length * FONT_SIZE;
|
|
209
|
+
const wire_padding = lb_txt_len + 2 * WIRE_PADDING;
|
|
310
210
|
this.wires.push(gen_wire(pin_pos, {
|
|
311
211
|
x: pin_pos.x + (is_left ? -wire_padding : wire_padding),
|
|
312
212
|
y: pin_pos.y,
|
|
313
213
|
}));
|
|
314
214
|
}
|
|
315
|
-
return gen_sheet_pin(pin.name, pin_pos, { horizontal
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return NetListConverter;
|
|
322
|
-
}());
|
|
323
|
-
export { NetListConverter };
|
|
215
|
+
return gen_sheet_pin(pin.name, pin_pos, { horizontal, vertical: 'bottom' }, rotation, pin.shape);
|
|
216
|
+
}
|
|
217
|
+
convert_net_label(net_name, pin_pos, sch, horizontal = 'right') {
|
|
218
|
+
sch.labels.push(gen_net_label(net_name, pin_pos, { horizontal, vertical: 'bottom' }));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
2
2
|
import { DEFAULT_FONT_SIZE } from '../constraints';
|
|
3
|
-
export
|
|
3
|
+
export const gen_net_label = (name, at, justify) => ({
|
|
4
4
|
label_type: 'label',
|
|
5
5
|
text: name,
|
|
6
6
|
fields: [],
|
|
@@ -11,4 +11,4 @@ export var gen_net_label = function (name, at, justify) { return ({
|
|
|
11
11
|
justify: justify,
|
|
12
12
|
},
|
|
13
13
|
uuid: gen_uuid(),
|
|
14
|
-
});
|
|
14
|
+
});
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { gen_uuid } from '@modular-circuit/utils';
|
|
13
2
|
import { DEFAULT_FONT_SIZE } from '../constraints';
|
|
14
|
-
|
|
15
|
-
shape
|
|
3
|
+
const gen_base_hierarchical_label = (text, at, justify, rotation, shape) => ({
|
|
4
|
+
shape,
|
|
16
5
|
effects: {
|
|
17
6
|
font: { size: DEFAULT_FONT_SIZE },
|
|
18
|
-
justify
|
|
7
|
+
justify,
|
|
19
8
|
},
|
|
20
|
-
text
|
|
21
|
-
at: { position: at, rotation
|
|
9
|
+
text,
|
|
10
|
+
at: { position: at, rotation },
|
|
22
11
|
uuid: gen_uuid(),
|
|
23
|
-
});
|
|
24
|
-
export
|
|
25
|
-
|
|
12
|
+
});
|
|
13
|
+
export const gen_sheet_pin = (text, at, justify, rotation, shape) => ({
|
|
14
|
+
label_type: 'hierarchical_label',
|
|
15
|
+
...gen_base_hierarchical_label(text, at, justify, rotation, shape),
|
|
16
|
+
});
|
|
17
|
+
export const gen_hierarchical_label = gen_sheet_pin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const kicad_prl = (prj_name) => ({
|
|
2
2
|
board: {
|
|
3
3
|
active_layer: 0,
|
|
4
4
|
active_layer_preset: '',
|
|
@@ -41,10 +41,10 @@ export var kicad_prl = function (prj_name) { return ({
|
|
|
41
41
|
ssh_key: '',
|
|
42
42
|
},
|
|
43
43
|
meta: {
|
|
44
|
-
filename:
|
|
44
|
+
filename: `${prj_name}.kicad_prl`,
|
|
45
45
|
version: 3,
|
|
46
46
|
},
|
|
47
47
|
project: {
|
|
48
48
|
files: [],
|
|
49
49
|
},
|
|
50
|
-
});
|
|
50
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DrawingSheetFileExtension } from './wildcards_and_files_ext';
|
|
2
|
-
export
|
|
2
|
+
export const kicad_pro = (project_name) => ({
|
|
3
3
|
board: {
|
|
4
4
|
'3dviewports': [],
|
|
5
5
|
ipc2581: {
|
|
@@ -76,7 +76,7 @@ export var kicad_pro = function (project_name) { return ({
|
|
|
76
76
|
pinned_symbol_libs: [],
|
|
77
77
|
},
|
|
78
78
|
meta: {
|
|
79
|
-
filename:
|
|
79
|
+
filename: `${project_name}.kicad_pro`,
|
|
80
80
|
version: 1,
|
|
81
81
|
},
|
|
82
82
|
net_settings: {
|
|
@@ -208,7 +208,7 @@ export var kicad_pro = function (project_name) { return ({
|
|
|
208
208
|
version: 1,
|
|
209
209
|
},
|
|
210
210
|
net_format_name: '',
|
|
211
|
-
page_layout_descr_file:
|
|
211
|
+
page_layout_descr_file: `${project_name}.${DrawingSheetFileExtension}`,
|
|
212
212
|
plot_directory: '',
|
|
213
213
|
spice_current_sheet_as_root: false,
|
|
214
214
|
spice_external_command: 'spice "%I"',
|
|
@@ -221,4 +221,4 @@ export var kicad_pro = function (project_name) { return ({
|
|
|
221
221
|
},
|
|
222
222
|
sheets: [],
|
|
223
223
|
text_variables: {},
|
|
224
|
-
});
|
|
224
|
+
});
|