@modular-circuit/transpiler 0.0.91 → 0.0.94

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.
@@ -25,6 +25,10 @@ export declare class Layout {
25
25
  private width;
26
26
  private height;
27
27
  private max_height;
28
+ private current_row_index;
29
+ private current_row_items;
30
+ private flush_row;
28
31
  get_block_geometry(factor: BlockLabelPadding): BoxGeometry;
32
+ finalize(): void;
29
33
  }
30
34
  //# 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;AAI9D,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,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEf,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;CAoDlE"}
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;AAI9D,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,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,UAAU,CAAI;IAEtB,OAAO,CAAC,iBAAiB,CAAI;IAC7B,OAAO,CAAC,iBAAiB,CAA0C;IAEnE,OAAO,CAAC,SAAS;IAwBV,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IA4C1D,QAAQ;CAGhB"}
@@ -1,3 +1,39 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ var __values = (this && this.__values) || function(o) {
27
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
28
+ if (m) return m.call(o);
29
+ if (o && typeof o.length === "number") return {
30
+ next: function () {
31
+ if (o && i >= o.length) o = void 0;
32
+ return { value: o && o[i++], done: !o };
33
+ }
34
+ };
35
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
36
+ };
1
37
  import { PAPER_SIZE } from '../../utils/constraints';
2
38
  var MIL_TO_MM = 0.0254;
3
39
  export var GRID_SIZE = 50 * MIL_TO_MM;
@@ -8,7 +44,7 @@ var POWER_Y_STEP = 16 * GRID_SIZE;
8
44
  export function get_power_pos(pwr_number) {
9
45
  return { x: POWER_START_X, y: POWER_START_Y + POWER_Y_STEP * pwr_number };
10
46
  }
11
- var BLOCK_START_Y = 36 * GRID_SIZE;
47
+ var BLOCK_START_Y = GRID_SIZE;
12
48
  var BLOCK_START_X = BLOCK_START_Y;
13
49
  export var BLOCK_PIN_GAP = 4 * GRID_SIZE;
14
50
  export var BLOCK_PIN_TB_MARGIN = 2 * GRID_SIZE;
@@ -23,45 +59,70 @@ var Layout = /** @class */ (function () {
23
59
  this.width = BLOCK_START_X;
24
60
  this.height = BLOCK_START_Y;
25
61
  this.max_height = 0;
62
+ this.current_row_index = 0;
63
+ this.current_row_items = [];
26
64
  }
65
+ Layout.prototype.flush_row = function () {
66
+ var e_1, _a;
67
+ if (this.current_row_items.length === 0)
68
+ return;
69
+ // If this row is odd: apply right-to-left packing
70
+ var rtl = this.current_row_index % 2 === 1;
71
+ if (rtl) {
72
+ // right-most limit
73
+ var cursor = POWER_START_X - BLOCK_MARGIN_RIGHT;
74
+ try {
75
+ for (var _b = __values(__spreadArray([], __read(this.current_row_items), false).reverse()), _c = _b.next(); !_c.done; _c = _b.next()) {
76
+ var item = _c.value;
77
+ var w = item.bounding_box.size.x;
78
+ cursor -= w;
79
+ item.box.pos.x = cursor;
80
+ item.bounding_box.pos.x = cursor;
81
+ cursor -= BLOCK_MARGIN_LEFT;
82
+ }
83
+ }
84
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
85
+ finally {
86
+ try {
87
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
88
+ }
89
+ finally { if (e_1) throw e_1.error; }
90
+ }
91
+ }
92
+ // row finished → move to next
93
+ this.current_row_items = [];
94
+ this.current_row_index++;
95
+ };
27
96
  Layout.prototype.get_block_geometry = function (factor) {
28
97
  var block_height = Math.floor(factor.total_pin_num / 2) * BLOCK_PIN_GAP + 2 * BLOCK_PIN_TB_MARGIN;
29
98
  var block_width = Math.max(MIN_BLOCK_WIDTH, factor.internal.l_side + factor.internal.r_side + INTERNAL_LABEL_MARGIN);
30
- var block_bounding_width = Math.max(block_width, factor.internal.l_side +
31
- factor.internal.r_side +
32
- factor.outer.l_side +
33
- factor.outer.r_side +
34
- // | txt | | txt |
35
- WIRE_PADDING * 4);
99
+ var block_bounding_width = Math.max(block_width, factor.internal.l_side + factor.internal.r_side + factor.outer.l_side + factor.outer.r_side + WIRE_PADDING * 4);
36
100
  var box = {
37
- pos: {
38
- x: this.width,
39
- y: this.height,
40
- },
41
- size: {
42
- x: block_width,
43
- y: block_height,
44
- },
101
+ pos: { x: this.width, y: this.height },
102
+ size: { x: block_width, y: block_height },
45
103
  };
46
104
  var bounding_box = {
47
- pos: {
48
- x: this.width,
49
- y: this.height,
50
- },
51
- size: {
52
- x: block_bounding_width,
53
- y: block_height,
54
- },
105
+ pos: { x: this.width, y: this.height },
106
+ size: { x: block_bounding_width, y: block_height },
55
107
  };
108
+ this.current_row_items.push({ box: box, bounding_box: bounding_box });
56
109
  this.max_height = Math.max(this.max_height, block_height);
110
+ // compute next X
57
111
  this.width += block_bounding_width + BLOCK_MARGIN_LEFT;
112
+ // Row break?
58
113
  if (this.width + BLOCK_MARGIN_RIGHT + MIN_BLOCK_WIDTH + BLOCK_MARGIN_LEFT > POWER_START_X) {
114
+ this.flush_row();
115
+ // reset for next row
59
116
  this.width = BLOCK_START_X;
60
117
  this.height += this.max_height + BLOCK_MARGIN_TOP;
61
118
  this.max_height = 0;
62
119
  }
63
120
  return { box: box, bounding_box: bounding_box };
64
121
  };
122
+ // When all blocks processed, call this
123
+ Layout.prototype.finalize = function () {
124
+ this.flush_row();
125
+ };
65
126
  return Layout;
66
127
  }());
67
128
  export { Layout };
@@ -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;AAKtD,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;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
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;AAatD,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;IAgEnB,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,2BAA2B;IA+CnC,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,iBAAiB;CAQ1B"}
@@ -32,7 +32,7 @@ import { gen_hierarchical_label, gen_net_label, gen_sheet_pin } from '../../kica
32
32
  import { gen_sch_sheet } from '../../kicad/sheet';
33
33
  import { gen_lib_gnd, gen_lib_vcc, gen_sch_gnd, gen_sch_vcc } from '../../kicad/symbols';
34
34
  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';
35
+ import { BLOCK_PIN_GAP, BLOCK_PIN_TB_MARGIN, FONT_SIZE, Layout, WIRE_PADDING, get_power_pos, } from './layout';
36
36
  import { gen_wire } from '../../kicad/wire/gen_wire';
37
37
  var NetListConverter = /** @class */ (function () {
38
38
  function NetListConverter(ctx) {
@@ -186,6 +186,7 @@ var NetListConverter = /** @class */ (function () {
186
186
  }
187
187
  finally { if (e_6) throw e_6.error; }
188
188
  }
189
+ this.block_calc.finalize();
189
190
  sch.wires = this.wires;
190
191
  return sch;
191
192
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/transpiler",
3
- "version": "0.0.91",
3
+ "version": "0.0.94",
4
4
  "description": "Intermediate representation of the modular circuit",
5
5
  "main": "./build/index.js",
6
6
  "files": [