simple-circuit-engine 0.0.12 → 0.0.13
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/AGENTS.md +2 -1
- package/CLAUDE.md +2 -0
- package/dist/core/index.js +83 -73
- package/dist/core/setup.d.ts +8 -0
- package/dist/core/simulation/behaviors/arithmetic/AdderBehavior.d.ts +28 -0
- package/dist/core/simulation/behaviors/arithmetic/ArithmeticBehaviorMixin.d.ts +63 -0
- package/dist/core/simulation/behaviors/arithmetic/EightBitAdderBehavior.d.ts +51 -0
- package/dist/core/simulation/behaviors/arithmetic/EightBitOnesComplementBehavior.d.ts +29 -0
- package/dist/core/simulation/behaviors/arithmetic/HalfAdderBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/arithmetic/index.d.ts +7 -0
- package/dist/core/simulation/behaviors/index.d.ts +4 -0
- package/dist/core/simulation/states/arithmetic/AdderState.d.ts +16 -0
- package/dist/core/simulation/states/arithmetic/ArithmeticState.d.ts +53 -0
- package/dist/core/simulation/states/arithmetic/EightBitAdderState.d.ts +25 -0
- package/dist/core/simulation/states/arithmetic/EightBitOnesComplementState.d.ts +18 -0
- package/dist/core/simulation/states/arithmetic/HalfAdderState.d.ts +16 -0
- package/dist/core/simulation/states/arithmetic/index.d.ts +7 -0
- package/dist/core/simulation/states/index.d.ts +5 -0
- package/dist/core/simulation/types.d.ts +1 -1
- package/dist/core/topology/Component.d.ts +2 -1
- package/dist/core/topology/types.d.ts +19 -5
- package/dist/{core-Bjta9Y7_.js → core-b6Q8w2sn.js} +1505 -652
- package/dist/core-b6Q8w2sn.js.map +1 -0
- package/dist/i18n/index.d.ts +882 -0
- package/dist/i18n/locales/en.json.d.ts +268 -0
- package/dist/i18n/locales/fr.json.d.ts +268 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +137 -120
- package/dist/scene/CircuitEngine.d.ts +13 -0
- package/dist/scene/index.d.ts +1 -1
- package/dist/scene/index.js +50 -45
- package/dist/scene/setup.d.ts +8 -0
- package/dist/scene/shared/AbstractCircuitController.d.ts +6 -0
- package/dist/scene/shared/components/arithmetic/AdderVisualFactory.d.ts +54 -0
- package/dist/scene/shared/components/arithmetic/EightBitAdderVisualFactory.d.ts +45 -0
- package/dist/scene/shared/components/arithmetic/EightBitOnesComplementVisualFactory.d.ts +63 -0
- package/dist/scene/shared/components/arithmetic/HalfAdderVisualFactory.d.ts +55 -0
- package/dist/scene/shared/components/arithmetic/index.d.ts +4 -0
- package/dist/scene/shared/components/index.d.ts +4 -0
- package/dist/scene/shared/types.d.ts +0 -2
- package/dist/scene/shared/utils/GeometryUtils.d.ts +76 -0
- package/dist/scene/static/CircuitController.d.ts +1 -0
- package/dist/scene/static/PinTooltipWidget.d.ts +5 -0
- package/dist/scene/static/tools/BuildTool.d.ts +4 -0
- package/dist/scene/static/tools/ComponentPickerWidget.d.ts +7 -0
- package/dist/scene/static/tools/ConfigPanelWidget.d.ts +14 -0
- package/dist/{scene-CVsDdySt.js → scene-D4QcWeiq.js} +2487 -1099
- package/dist/scene-D4QcWeiq.js.map +1 -0
- package/package.json +14 -9
- package/dist/core-Bjta9Y7_.js.map +0 -1
- package/dist/scene-CVsDdySt.js.map +0 -1
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
function
|
|
1
|
+
function dt(e) {
|
|
2
2
|
let t, n, i;
|
|
3
|
-
return typeof e == "object" ? (t = e.hashFunction, n = e.expiring, i = e.tags) : t = e, (s,
|
|
4
|
-
if (
|
|
5
|
-
else if (
|
|
3
|
+
return typeof e == "object" ? (t = e.hashFunction, n = e.expiring, i = e.tags) : t = e, (s, r, a) => {
|
|
4
|
+
if (a.value != null) a.value = W(a.value, t, n, i);
|
|
5
|
+
else if (a.get != null) a.get = W(a.get, t, n, i);
|
|
6
6
|
else throw "Only put a Memoize() decorator on a method or get accessor.";
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function Se(e, t) {
|
|
10
|
+
return dt({
|
|
11
11
|
expiring: e,
|
|
12
12
|
hashFunction: t
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
var
|
|
16
|
-
function
|
|
15
|
+
var D = /* @__PURE__ */ new Map();
|
|
16
|
+
function W(e, t, n = 0, i) {
|
|
17
17
|
const s = /* @__PURE__ */ Symbol("__memoized_map__");
|
|
18
|
-
return function(...
|
|
19
|
-
let
|
|
18
|
+
return function(...r) {
|
|
19
|
+
let a;
|
|
20
20
|
this.hasOwnProperty(s) || Object.defineProperty(this, s, {
|
|
21
21
|
configurable: !1,
|
|
22
22
|
enumerable: !1,
|
|
23
23
|
writable: !1,
|
|
24
24
|
value: /* @__PURE__ */ new Map()
|
|
25
25
|
});
|
|
26
|
-
let
|
|
27
|
-
if (Array.isArray(i)) for (const c of i)
|
|
28
|
-
if (t ||
|
|
26
|
+
let o = this[s];
|
|
27
|
+
if (Array.isArray(i)) for (const c of i) D.has(c) ? D.get(c).push(o) : D.set(c, [o]);
|
|
28
|
+
if (t || r.length > 0 || n > 0) {
|
|
29
29
|
let c;
|
|
30
|
-
t === !0 ? c =
|
|
31
|
-
const
|
|
32
|
-
let
|
|
33
|
-
if (n > 0) if (!
|
|
30
|
+
t === !0 ? c = r.map((d) => d.toString()).join("!") : t ? c = t.apply(this, r) : c = r[0];
|
|
31
|
+
const p = `${c}__timestamp`;
|
|
32
|
+
let l = !1;
|
|
33
|
+
if (n > 0) if (!o.has(p)) l = !0;
|
|
34
34
|
else {
|
|
35
|
-
let
|
|
36
|
-
|
|
35
|
+
let d = o.get(p);
|
|
36
|
+
l = Date.now() - d > n;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
o.has(c) && !l ? a = o.get(c) : (a = e.apply(this, r), o.set(c, a), n > 0 && o.set(p, Date.now()));
|
|
39
39
|
} else {
|
|
40
40
|
const c = this;
|
|
41
|
-
|
|
41
|
+
o.has(c) ? a = o.get(c) : (a = e.apply(this, r), o.set(c, a));
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return a;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
var
|
|
46
|
+
var O = class X {
|
|
47
47
|
constructor(t, n, i) {
|
|
48
48
|
this.x = t, this.y = n, this.z = i;
|
|
49
49
|
}
|
|
@@ -58,14 +58,14 @@ var P = class W {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
static fromJSON(t) {
|
|
61
|
-
return new
|
|
61
|
+
return new X(t.x, t.y, t.z);
|
|
62
62
|
}
|
|
63
63
|
toString() {
|
|
64
64
|
return `Position(${this.x}, ${this.y}, ${this.z})`;
|
|
65
65
|
}
|
|
66
|
-
},
|
|
67
|
-
constructor(t = new
|
|
68
|
-
this.position = t, this.lookAtPosition = n, this.fov = i, this.near = s, this.far =
|
|
66
|
+
}, Q = class q {
|
|
67
|
+
constructor(t = new O(0, 15, 15), n = new O(0, 0, 0), i = 75, s = 0.1, r = 1e3) {
|
|
68
|
+
this.position = t, this.lookAtPosition = n, this.fov = i, this.near = s, this.far = r;
|
|
69
69
|
}
|
|
70
70
|
toJSON() {
|
|
71
71
|
return {
|
|
@@ -77,12 +77,12 @@ var P = class W {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
static fromJSON(t) {
|
|
80
|
-
return new
|
|
80
|
+
return new q(O.fromJSON(t.position), O.fromJSON(t.lookAtPosition), t.fov, t.near, t.far);
|
|
81
81
|
}
|
|
82
82
|
toString() {
|
|
83
83
|
return `CameraOptions(position: ${this.position.toString()}, lookAt: ${this.lookAtPosition.toString()}, fov: ${this.fov}, near: ${this.near}, far: ${this.far})`;
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, V = class K {
|
|
86
86
|
constructor(t, n) {
|
|
87
87
|
if (this.x = t, this.y = n, !Number.isInteger(t) || !Number.isInteger(n)) throw new TypeError(`Position coordinates must be integers (got x=${t}, y=${n})`);
|
|
88
88
|
}
|
|
@@ -96,42 +96,42 @@ var P = class W {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
static fromJSON(t) {
|
|
99
|
-
return new
|
|
99
|
+
return new K(t.x, t.y);
|
|
100
100
|
}
|
|
101
101
|
toString() {
|
|
102
102
|
return `Position(${this.x}, ${this.y})`;
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
function
|
|
105
|
+
function ht(e, t, n = 1 / 0) {
|
|
106
106
|
if (e.length === 0) return 0;
|
|
107
107
|
if (e.length === 1) return 1;
|
|
108
108
|
let i = 1;
|
|
109
109
|
for (let s = 0; s < e.length - 1; s++) {
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const r = e[s], a = e[s + 1], o = gt(t, r, a);
|
|
111
|
+
o < n && (n = o, i = s + 1);
|
|
112
112
|
}
|
|
113
113
|
return i;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
const i = n.x - t.x, s = n.y - t.y,
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
return Math.sqrt((e.x -
|
|
115
|
+
function gt(e, t, n) {
|
|
116
|
+
const i = n.x - t.x, s = n.y - t.y, r = i * i + s * s;
|
|
117
|
+
if (r === 0) return Math.sqrt((e.x - t.x) ** 2 + (e.y - t.y) ** 2);
|
|
118
|
+
const a = Math.max(0, Math.min(1, ((e.x - t.x) * i + (e.y - t.y) * s) / r)), o = t.x + a * i, c = t.y + a * s;
|
|
119
|
+
return Math.sqrt((e.x - o) ** 2 + (e.y - c) ** 2);
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function M(e, t = 5) {
|
|
122
122
|
if (e.length <= 2) return [...e];
|
|
123
123
|
const n = [e[0]];
|
|
124
124
|
for (let i = 1; i < e.length - 1; i++) {
|
|
125
|
-
const s = n[n.length - 1],
|
|
126
|
-
|
|
125
|
+
const s = n[n.length - 1], r = e[i], a = e[i + 1];
|
|
126
|
+
ft(s, r, a, t) || n.push(r);
|
|
127
127
|
}
|
|
128
128
|
return n.push(e[e.length - 1]), n;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function ft(e, t, n, i = 5) {
|
|
131
131
|
const s = (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x);
|
|
132
132
|
return Math.abs(s) <= i;
|
|
133
133
|
}
|
|
134
|
-
var
|
|
134
|
+
var yt = class Y {
|
|
135
135
|
constructor(t) {
|
|
136
136
|
if (this.angle = t, !Number.isInteger(t)) throw new TypeError(`Rotation angle must be an integer (got ${t})`);
|
|
137
137
|
}
|
|
@@ -139,7 +139,7 @@ var rt = class J {
|
|
|
139
139
|
return this.angle;
|
|
140
140
|
}
|
|
141
141
|
static fromJSON(t) {
|
|
142
|
-
return new
|
|
142
|
+
return new Y(t);
|
|
143
143
|
}
|
|
144
144
|
equals(t) {
|
|
145
145
|
return this.angle === t.angle;
|
|
@@ -148,7 +148,7 @@ var rt = class J {
|
|
|
148
148
|
return `Rotation(${this.angle}°)`;
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
|
-
function
|
|
151
|
+
function $() {
|
|
152
152
|
if (typeof crypto < "u" && crypto.randomUUID) return crypto.randomUUID();
|
|
153
153
|
const e = "0123456789abcdef", t = [
|
|
154
154
|
8,
|
|
@@ -158,37 +158,30 @@ function G() {
|
|
|
158
158
|
12
|
|
159
159
|
], n = [];
|
|
160
160
|
for (const s of t) {
|
|
161
|
-
let
|
|
162
|
-
for (let
|
|
163
|
-
const
|
|
164
|
-
|
|
161
|
+
let r = "";
|
|
162
|
+
for (let a = 0; a < s; a++) {
|
|
163
|
+
const o = Math.floor(Math.random() * 16);
|
|
164
|
+
r += e[o];
|
|
165
165
|
}
|
|
166
|
-
n.push(
|
|
166
|
+
n.push(r);
|
|
167
167
|
}
|
|
168
168
|
const i = n.join("-").split("");
|
|
169
169
|
return i[14] = "4", i[19] = e[parseInt(i[19] ?? "0", 16) & 3 | 8] ?? "0", i.join("");
|
|
170
170
|
}
|
|
171
|
-
var
|
|
171
|
+
var Z = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
172
172
|
return e.Voltage = "Voltage", e.Current = "Current", e;
|
|
173
|
-
})({}),
|
|
173
|
+
})({}), P = /* @__PURE__ */ (function(e) {
|
|
174
174
|
return e.Pin = "Pin", e.BranchingPoint = "BranchingPoint", e;
|
|
175
|
-
})({}),
|
|
175
|
+
})({}), we = [
|
|
176
176
|
"CMOS1",
|
|
177
177
|
"TTL1",
|
|
178
178
|
"Sandbox"
|
|
179
|
-
],
|
|
180
|
-
return e.Cube = "cube", e.Label = "label", e.Battery = "battery", e.Switch = "switch", e.DoubleThrowSwitch = "doubleThrowSwitch", e.Lightbulb = "lightbulb", e.Relay = "relay", e.SmallLED = "smallLED", e.RectangleLED = "rectangleLED", e.Clock = "clock", e.Inverter = "inverter", e.NandGate = "nandGate", e.Nand4Gate = "nand4Gate", e.Nand8Gate = "nand8Gate", e.NorGate = "norGate", e.Nor4Gate = "nor4Gate", e.Nor8Gate = "nor8Gate", e.XorGate = "xorGate", e.Xor4Gate = "xor4Gate", e.Xor8Gate = "xor8Gate", e;
|
|
181
|
-
})({}),
|
|
179
|
+
], j = "CMOS1", u = /* @__PURE__ */ (function(e) {
|
|
180
|
+
return e.Cube = "cube", e.Label = "label", e.Battery = "battery", e.Switch = "switch", e.DoubleThrowSwitch = "doubleThrowSwitch", e.Lightbulb = "lightbulb", e.Relay = "relay", e.SmallLED = "smallLED", e.RectangleLED = "rectangleLED", e.Clock = "clock", e.Inverter = "inverter", e.NandGate = "nandGate", e.Nand4Gate = "nand4Gate", e.Nand8Gate = "nand8Gate", e.NorGate = "norGate", e.Nor4Gate = "nor4Gate", e.Nor8Gate = "nor8Gate", e.XorGate = "xorGate", e.Xor4Gate = "xor4Gate", e.Xor8Gate = "xor8Gate", e.HalfAdder = "halfAdder", e.Adder = "adder", e.EightBitAdder = "eightBitAdder", e.EightBitOnesComplement = "eightBitOnesComplement", e;
|
|
181
|
+
})({}), I = {
|
|
182
182
|
[u.Switch]: {
|
|
183
183
|
id: u.Switch,
|
|
184
|
-
|
|
185
|
-
pins: /* @__PURE__ */ new Map([["input", {
|
|
186
|
-
subtype: "free",
|
|
187
|
-
sourceType: void 0
|
|
188
|
-
}], ["output", {
|
|
189
|
-
subtype: "free",
|
|
190
|
-
sourceType: void 0
|
|
191
|
-
}]]),
|
|
184
|
+
pins: /* @__PURE__ */ new Map([["input", { subtype: "free" }], ["output", { subtype: "free" }]]),
|
|
192
185
|
config: /* @__PURE__ */ new Map([
|
|
193
186
|
["initialState", "open"],
|
|
194
187
|
["transitionSpan", "1"],
|
|
@@ -197,20 +190,10 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
197
190
|
},
|
|
198
191
|
[u.DoubleThrowSwitch]: {
|
|
199
192
|
id: u.DoubleThrowSwitch,
|
|
200
|
-
name: "DoubleThrowSwitch",
|
|
201
193
|
pins: /* @__PURE__ */ new Map([
|
|
202
|
-
["input1", {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}],
|
|
206
|
-
["input2", {
|
|
207
|
-
subtype: "free",
|
|
208
|
-
sourceType: void 0
|
|
209
|
-
}],
|
|
210
|
-
["output", {
|
|
211
|
-
subtype: "free",
|
|
212
|
-
sourceType: void 0
|
|
213
|
-
}]
|
|
194
|
+
["input1", { subtype: "free" }],
|
|
195
|
+
["input2", { subtype: "free" }],
|
|
196
|
+
["output", { subtype: "free" }]
|
|
214
197
|
]),
|
|
215
198
|
config: /* @__PURE__ */ new Map([
|
|
216
199
|
["initialState", "input1"],
|
|
@@ -220,7 +203,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
220
203
|
},
|
|
221
204
|
[u.Battery]: {
|
|
222
205
|
id: u.Battery,
|
|
223
|
-
name: "Battery",
|
|
224
206
|
pins: /* @__PURE__ */ new Map([["cathode", {
|
|
225
207
|
subtype: "mainVcc",
|
|
226
208
|
sourceType: g.Voltage
|
|
@@ -232,36 +214,16 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
232
214
|
},
|
|
233
215
|
[u.Lightbulb]: {
|
|
234
216
|
id: u.Lightbulb,
|
|
235
|
-
|
|
236
|
-
pins: /* @__PURE__ */ new Map([["pin1", {
|
|
237
|
-
subtype: "free",
|
|
238
|
-
sourceType: void 0
|
|
239
|
-
}], ["pin2", {
|
|
240
|
-
subtype: "free",
|
|
241
|
-
sourceType: void 0
|
|
242
|
-
}]]),
|
|
217
|
+
pins: /* @__PURE__ */ new Map([["pin1", { subtype: "free" }], ["pin2", { subtype: "free" }]]),
|
|
243
218
|
config: /* @__PURE__ */ new Map([["transitionSpan", "1"], ["size", "1"]])
|
|
244
219
|
},
|
|
245
220
|
[u.Relay]: {
|
|
246
221
|
id: u.Relay,
|
|
247
|
-
name: "Relay",
|
|
248
222
|
pins: /* @__PURE__ */ new Map([
|
|
249
|
-
["cmd_in", {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}]
|
|
253
|
-
["cmd_out", {
|
|
254
|
-
subtype: "free",
|
|
255
|
-
sourceType: void 0
|
|
256
|
-
}],
|
|
257
|
-
["power_in", {
|
|
258
|
-
subtype: "free",
|
|
259
|
-
sourceType: void 0
|
|
260
|
-
}],
|
|
261
|
-
["power_out", {
|
|
262
|
-
subtype: "free",
|
|
263
|
-
sourceType: void 0
|
|
264
|
-
}]
|
|
223
|
+
["cmd_in", { subtype: "free" }],
|
|
224
|
+
["cmd_out", { subtype: "free" }],
|
|
225
|
+
["power_in", { subtype: "free" }],
|
|
226
|
+
["power_out", { subtype: "free" }]
|
|
265
227
|
]),
|
|
266
228
|
config: /* @__PURE__ */ new Map([
|
|
267
229
|
["activationLogic", "positive"],
|
|
@@ -271,14 +233,7 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
271
233
|
},
|
|
272
234
|
[u.SmallLED]: {
|
|
273
235
|
id: u.SmallLED,
|
|
274
|
-
|
|
275
|
-
pins: /* @__PURE__ */ new Map([["pin1", {
|
|
276
|
-
subtype: "free",
|
|
277
|
-
sourceType: void 0
|
|
278
|
-
}], ["pin2", {
|
|
279
|
-
subtype: "free",
|
|
280
|
-
sourceType: void 0
|
|
281
|
-
}]]),
|
|
236
|
+
pins: /* @__PURE__ */ new Map([["pin1", { subtype: "free" }], ["pin2", { subtype: "free" }]]),
|
|
282
237
|
config: /* @__PURE__ */ new Map([
|
|
283
238
|
["transitionSpan", "1"],
|
|
284
239
|
["idleColor", "white"],
|
|
@@ -289,14 +244,7 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
289
244
|
},
|
|
290
245
|
[u.RectangleLED]: {
|
|
291
246
|
id: u.RectangleLED,
|
|
292
|
-
|
|
293
|
-
pins: /* @__PURE__ */ new Map([["pin1", {
|
|
294
|
-
subtype: "free",
|
|
295
|
-
sourceType: void 0
|
|
296
|
-
}], ["pin2", {
|
|
297
|
-
subtype: "free",
|
|
298
|
-
sourceType: void 0
|
|
299
|
-
}]]),
|
|
247
|
+
pins: /* @__PURE__ */ new Map([["pin1", { subtype: "free" }], ["pin2", { subtype: "free" }]]),
|
|
300
248
|
config: /* @__PURE__ */ new Map([
|
|
301
249
|
["transitionSpan", "1"],
|
|
302
250
|
["idleColor", "white"],
|
|
@@ -308,19 +256,16 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
308
256
|
},
|
|
309
257
|
[u.Cube]: {
|
|
310
258
|
id: u.Cube,
|
|
311
|
-
name: "Cube",
|
|
312
259
|
pins: /* @__PURE__ */ new Map([]),
|
|
313
260
|
config: /* @__PURE__ */ new Map([["color", "red"]])
|
|
314
261
|
},
|
|
315
262
|
[u.Label]: {
|
|
316
263
|
id: u.Label,
|
|
317
|
-
name: "Label",
|
|
318
264
|
pins: /* @__PURE__ */ new Map([]),
|
|
319
265
|
config: /* @__PURE__ */ new Map([["text", "Label"], ["size", "1"]])
|
|
320
266
|
},
|
|
321
267
|
[u.Clock]: {
|
|
322
268
|
id: u.Clock,
|
|
323
|
-
name: "Clock",
|
|
324
269
|
pins: /* @__PURE__ */ new Map([
|
|
325
270
|
["vcc", {
|
|
326
271
|
subtype: "vcc",
|
|
@@ -328,7 +273,10 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
328
273
|
}],
|
|
329
274
|
["output", {
|
|
330
275
|
subtype: "logicOutput",
|
|
331
|
-
|
|
276
|
+
logicPinData: {
|
|
277
|
+
interface: "output",
|
|
278
|
+
index: 0
|
|
279
|
+
}
|
|
332
280
|
}],
|
|
333
281
|
["gnd", {
|
|
334
282
|
subtype: "gnd",
|
|
@@ -339,7 +287,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
339
287
|
},
|
|
340
288
|
[u.Inverter]: {
|
|
341
289
|
id: u.Inverter,
|
|
342
|
-
name: "Inverter",
|
|
343
290
|
pins: /* @__PURE__ */ new Map([
|
|
344
291
|
["vcc", {
|
|
345
292
|
subtype: "vcc",
|
|
@@ -347,11 +294,17 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
347
294
|
}],
|
|
348
295
|
["input", {
|
|
349
296
|
subtype: "logicInput",
|
|
350
|
-
|
|
297
|
+
logicPinData: {
|
|
298
|
+
interface: "input",
|
|
299
|
+
index: 0
|
|
300
|
+
}
|
|
351
301
|
}],
|
|
352
302
|
["output", {
|
|
353
303
|
subtype: "logicOutput",
|
|
354
|
-
|
|
304
|
+
logicPinData: {
|
|
305
|
+
interface: "output",
|
|
306
|
+
index: 0
|
|
307
|
+
}
|
|
355
308
|
}],
|
|
356
309
|
["gnd", {
|
|
357
310
|
subtype: "gnd",
|
|
@@ -367,7 +320,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
367
320
|
},
|
|
368
321
|
[u.NandGate]: {
|
|
369
322
|
id: u.NandGate,
|
|
370
|
-
name: "NAND Gate",
|
|
371
323
|
pins: /* @__PURE__ */ new Map([
|
|
372
324
|
["vcc", {
|
|
373
325
|
subtype: "vcc",
|
|
@@ -375,15 +327,24 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
375
327
|
}],
|
|
376
328
|
["input1", {
|
|
377
329
|
subtype: "logicInput",
|
|
378
|
-
|
|
330
|
+
logicPinData: {
|
|
331
|
+
interface: "input",
|
|
332
|
+
index: 0
|
|
333
|
+
}
|
|
379
334
|
}],
|
|
380
335
|
["input2", {
|
|
381
336
|
subtype: "logicInput",
|
|
382
|
-
|
|
337
|
+
logicPinData: {
|
|
338
|
+
interface: "input",
|
|
339
|
+
index: 1
|
|
340
|
+
}
|
|
383
341
|
}],
|
|
384
342
|
["output", {
|
|
385
343
|
subtype: "logicOutput",
|
|
386
|
-
|
|
344
|
+
logicPinData: {
|
|
345
|
+
interface: "output",
|
|
346
|
+
index: 0
|
|
347
|
+
}
|
|
387
348
|
}],
|
|
388
349
|
["gnd", {
|
|
389
350
|
subtype: "gnd",
|
|
@@ -399,7 +360,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
399
360
|
},
|
|
400
361
|
[u.Nand4Gate]: {
|
|
401
362
|
id: u.Nand4Gate,
|
|
402
|
-
name: "NAND4 Gate",
|
|
403
363
|
pins: /* @__PURE__ */ new Map([
|
|
404
364
|
["vcc", {
|
|
405
365
|
subtype: "vcc",
|
|
@@ -407,23 +367,38 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
407
367
|
}],
|
|
408
368
|
["input1", {
|
|
409
369
|
subtype: "logicInput",
|
|
410
|
-
|
|
370
|
+
logicPinData: {
|
|
371
|
+
interface: "input",
|
|
372
|
+
index: 0
|
|
373
|
+
}
|
|
411
374
|
}],
|
|
412
375
|
["input2", {
|
|
413
376
|
subtype: "logicInput",
|
|
414
|
-
|
|
377
|
+
logicPinData: {
|
|
378
|
+
interface: "input",
|
|
379
|
+
index: 1
|
|
380
|
+
}
|
|
415
381
|
}],
|
|
416
382
|
["input3", {
|
|
417
383
|
subtype: "logicInput",
|
|
418
|
-
|
|
384
|
+
logicPinData: {
|
|
385
|
+
interface: "input",
|
|
386
|
+
index: 2
|
|
387
|
+
}
|
|
419
388
|
}],
|
|
420
389
|
["input4", {
|
|
421
390
|
subtype: "logicInput",
|
|
422
|
-
|
|
391
|
+
logicPinData: {
|
|
392
|
+
interface: "input",
|
|
393
|
+
index: 3
|
|
394
|
+
}
|
|
423
395
|
}],
|
|
424
396
|
["output", {
|
|
425
397
|
subtype: "logicOutput",
|
|
426
|
-
|
|
398
|
+
logicPinData: {
|
|
399
|
+
interface: "output",
|
|
400
|
+
index: 0
|
|
401
|
+
}
|
|
427
402
|
}],
|
|
428
403
|
["gnd", {
|
|
429
404
|
subtype: "gnd",
|
|
@@ -439,7 +414,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
439
414
|
},
|
|
440
415
|
[u.Nand8Gate]: {
|
|
441
416
|
id: u.Nand8Gate,
|
|
442
|
-
name: "NAND8 Gate",
|
|
443
417
|
pins: /* @__PURE__ */ new Map([
|
|
444
418
|
["vcc", {
|
|
445
419
|
subtype: "vcc",
|
|
@@ -447,39 +421,66 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
447
421
|
}],
|
|
448
422
|
["input1", {
|
|
449
423
|
subtype: "logicInput",
|
|
450
|
-
|
|
424
|
+
logicPinData: {
|
|
425
|
+
interface: "input",
|
|
426
|
+
index: 0
|
|
427
|
+
}
|
|
451
428
|
}],
|
|
452
429
|
["input2", {
|
|
453
430
|
subtype: "logicInput",
|
|
454
|
-
|
|
431
|
+
logicPinData: {
|
|
432
|
+
interface: "input",
|
|
433
|
+
index: 1
|
|
434
|
+
}
|
|
455
435
|
}],
|
|
456
436
|
["input3", {
|
|
457
437
|
subtype: "logicInput",
|
|
458
|
-
|
|
438
|
+
logicPinData: {
|
|
439
|
+
interface: "input",
|
|
440
|
+
index: 2
|
|
441
|
+
}
|
|
459
442
|
}],
|
|
460
443
|
["input4", {
|
|
461
444
|
subtype: "logicInput",
|
|
462
|
-
|
|
445
|
+
logicPinData: {
|
|
446
|
+
interface: "input",
|
|
447
|
+
index: 3
|
|
448
|
+
}
|
|
463
449
|
}],
|
|
464
450
|
["input5", {
|
|
465
451
|
subtype: "logicInput",
|
|
466
|
-
|
|
452
|
+
logicPinData: {
|
|
453
|
+
interface: "input",
|
|
454
|
+
index: 4
|
|
455
|
+
}
|
|
467
456
|
}],
|
|
468
457
|
["input6", {
|
|
469
458
|
subtype: "logicInput",
|
|
470
|
-
|
|
459
|
+
logicPinData: {
|
|
460
|
+
interface: "input",
|
|
461
|
+
index: 5
|
|
462
|
+
}
|
|
471
463
|
}],
|
|
472
464
|
["input7", {
|
|
473
465
|
subtype: "logicInput",
|
|
474
|
-
|
|
466
|
+
logicPinData: {
|
|
467
|
+
interface: "input",
|
|
468
|
+
index: 6
|
|
469
|
+
}
|
|
475
470
|
}],
|
|
476
471
|
["input8", {
|
|
477
472
|
subtype: "logicInput",
|
|
478
|
-
|
|
473
|
+
logicPinData: {
|
|
474
|
+
interface: "input",
|
|
475
|
+
index: 7
|
|
476
|
+
}
|
|
479
477
|
}],
|
|
480
478
|
["output", {
|
|
481
479
|
subtype: "logicOutput",
|
|
482
|
-
|
|
480
|
+
logicPinData: {
|
|
481
|
+
interface: "output",
|
|
482
|
+
index: 0
|
|
483
|
+
}
|
|
483
484
|
}],
|
|
484
485
|
["gnd", {
|
|
485
486
|
subtype: "gnd",
|
|
@@ -495,7 +496,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
495
496
|
},
|
|
496
497
|
[u.NorGate]: {
|
|
497
498
|
id: u.NorGate,
|
|
498
|
-
name: "NOR Gate",
|
|
499
499
|
pins: /* @__PURE__ */ new Map([
|
|
500
500
|
["vcc", {
|
|
501
501
|
subtype: "vcc",
|
|
@@ -503,15 +503,24 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
503
503
|
}],
|
|
504
504
|
["input1", {
|
|
505
505
|
subtype: "logicInput",
|
|
506
|
-
|
|
506
|
+
logicPinData: {
|
|
507
|
+
interface: "input",
|
|
508
|
+
index: 0
|
|
509
|
+
}
|
|
507
510
|
}],
|
|
508
511
|
["input2", {
|
|
509
512
|
subtype: "logicInput",
|
|
510
|
-
|
|
513
|
+
logicPinData: {
|
|
514
|
+
interface: "input",
|
|
515
|
+
index: 1
|
|
516
|
+
}
|
|
511
517
|
}],
|
|
512
518
|
["output", {
|
|
513
519
|
subtype: "logicOutput",
|
|
514
|
-
|
|
520
|
+
logicPinData: {
|
|
521
|
+
interface: "output",
|
|
522
|
+
index: 0
|
|
523
|
+
}
|
|
515
524
|
}],
|
|
516
525
|
["gnd", {
|
|
517
526
|
subtype: "gnd",
|
|
@@ -527,7 +536,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
527
536
|
},
|
|
528
537
|
[u.Nor4Gate]: {
|
|
529
538
|
id: u.Nor4Gate,
|
|
530
|
-
name: "NOR4 Gate",
|
|
531
539
|
pins: /* @__PURE__ */ new Map([
|
|
532
540
|
["vcc", {
|
|
533
541
|
subtype: "vcc",
|
|
@@ -535,23 +543,38 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
535
543
|
}],
|
|
536
544
|
["input1", {
|
|
537
545
|
subtype: "logicInput",
|
|
538
|
-
|
|
546
|
+
logicPinData: {
|
|
547
|
+
interface: "input",
|
|
548
|
+
index: 0
|
|
549
|
+
}
|
|
539
550
|
}],
|
|
540
551
|
["input2", {
|
|
541
552
|
subtype: "logicInput",
|
|
542
|
-
|
|
553
|
+
logicPinData: {
|
|
554
|
+
interface: "input",
|
|
555
|
+
index: 1
|
|
556
|
+
}
|
|
543
557
|
}],
|
|
544
558
|
["input3", {
|
|
545
559
|
subtype: "logicInput",
|
|
546
|
-
|
|
560
|
+
logicPinData: {
|
|
561
|
+
interface: "input",
|
|
562
|
+
index: 2
|
|
563
|
+
}
|
|
547
564
|
}],
|
|
548
565
|
["input4", {
|
|
549
566
|
subtype: "logicInput",
|
|
550
|
-
|
|
567
|
+
logicPinData: {
|
|
568
|
+
interface: "input",
|
|
569
|
+
index: 3
|
|
570
|
+
}
|
|
551
571
|
}],
|
|
552
572
|
["output", {
|
|
553
573
|
subtype: "logicOutput",
|
|
554
|
-
|
|
574
|
+
logicPinData: {
|
|
575
|
+
interface: "output",
|
|
576
|
+
index: 0
|
|
577
|
+
}
|
|
555
578
|
}],
|
|
556
579
|
["gnd", {
|
|
557
580
|
subtype: "gnd",
|
|
@@ -567,7 +590,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
567
590
|
},
|
|
568
591
|
[u.Nor8Gate]: {
|
|
569
592
|
id: u.Nor8Gate,
|
|
570
|
-
name: "NOR8 Gate",
|
|
571
593
|
pins: /* @__PURE__ */ new Map([
|
|
572
594
|
["vcc", {
|
|
573
595
|
subtype: "vcc",
|
|
@@ -575,39 +597,66 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
575
597
|
}],
|
|
576
598
|
["input1", {
|
|
577
599
|
subtype: "logicInput",
|
|
578
|
-
|
|
600
|
+
logicPinData: {
|
|
601
|
+
interface: "input",
|
|
602
|
+
index: 0
|
|
603
|
+
}
|
|
579
604
|
}],
|
|
580
605
|
["input2", {
|
|
581
606
|
subtype: "logicInput",
|
|
582
|
-
|
|
607
|
+
logicPinData: {
|
|
608
|
+
interface: "input",
|
|
609
|
+
index: 1
|
|
610
|
+
}
|
|
583
611
|
}],
|
|
584
612
|
["input3", {
|
|
585
613
|
subtype: "logicInput",
|
|
586
|
-
|
|
614
|
+
logicPinData: {
|
|
615
|
+
interface: "input",
|
|
616
|
+
index: 2
|
|
617
|
+
}
|
|
587
618
|
}],
|
|
588
619
|
["input4", {
|
|
589
620
|
subtype: "logicInput",
|
|
590
|
-
|
|
621
|
+
logicPinData: {
|
|
622
|
+
interface: "input",
|
|
623
|
+
index: 3
|
|
624
|
+
}
|
|
591
625
|
}],
|
|
592
626
|
["input5", {
|
|
593
627
|
subtype: "logicInput",
|
|
594
|
-
|
|
628
|
+
logicPinData: {
|
|
629
|
+
interface: "input",
|
|
630
|
+
index: 4
|
|
631
|
+
}
|
|
595
632
|
}],
|
|
596
633
|
["input6", {
|
|
597
634
|
subtype: "logicInput",
|
|
598
|
-
|
|
635
|
+
logicPinData: {
|
|
636
|
+
interface: "input",
|
|
637
|
+
index: 5
|
|
638
|
+
}
|
|
599
639
|
}],
|
|
600
640
|
["input7", {
|
|
601
641
|
subtype: "logicInput",
|
|
602
|
-
|
|
642
|
+
logicPinData: {
|
|
643
|
+
interface: "input",
|
|
644
|
+
index: 6
|
|
645
|
+
}
|
|
603
646
|
}],
|
|
604
647
|
["input8", {
|
|
605
648
|
subtype: "logicInput",
|
|
606
|
-
|
|
649
|
+
logicPinData: {
|
|
650
|
+
interface: "input",
|
|
651
|
+
index: 7
|
|
652
|
+
}
|
|
607
653
|
}],
|
|
608
654
|
["output", {
|
|
609
655
|
subtype: "logicOutput",
|
|
610
|
-
|
|
656
|
+
logicPinData: {
|
|
657
|
+
interface: "output",
|
|
658
|
+
index: 0
|
|
659
|
+
}
|
|
611
660
|
}],
|
|
612
661
|
["gnd", {
|
|
613
662
|
subtype: "gnd",
|
|
@@ -623,7 +672,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
623
672
|
},
|
|
624
673
|
[u.XorGate]: {
|
|
625
674
|
id: u.XorGate,
|
|
626
|
-
name: "XOR Gate",
|
|
627
675
|
pins: /* @__PURE__ */ new Map([
|
|
628
676
|
["vcc", {
|
|
629
677
|
subtype: "vcc",
|
|
@@ -631,15 +679,24 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
631
679
|
}],
|
|
632
680
|
["input1", {
|
|
633
681
|
subtype: "logicInput",
|
|
634
|
-
|
|
682
|
+
logicPinData: {
|
|
683
|
+
interface: "input",
|
|
684
|
+
index: 0
|
|
685
|
+
}
|
|
635
686
|
}],
|
|
636
687
|
["input2", {
|
|
637
688
|
subtype: "logicInput",
|
|
638
|
-
|
|
689
|
+
logicPinData: {
|
|
690
|
+
interface: "input",
|
|
691
|
+
index: 1
|
|
692
|
+
}
|
|
639
693
|
}],
|
|
640
694
|
["output", {
|
|
641
695
|
subtype: "logicOutput",
|
|
642
|
-
|
|
696
|
+
logicPinData: {
|
|
697
|
+
interface: "output",
|
|
698
|
+
index: 0
|
|
699
|
+
}
|
|
643
700
|
}],
|
|
644
701
|
["gnd", {
|
|
645
702
|
subtype: "gnd",
|
|
@@ -655,7 +712,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
655
712
|
},
|
|
656
713
|
[u.Xor4Gate]: {
|
|
657
714
|
id: u.Xor4Gate,
|
|
658
|
-
name: "XOR4 Gate",
|
|
659
715
|
pins: /* @__PURE__ */ new Map([
|
|
660
716
|
["vcc", {
|
|
661
717
|
subtype: "vcc",
|
|
@@ -663,23 +719,38 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
663
719
|
}],
|
|
664
720
|
["input1", {
|
|
665
721
|
subtype: "logicInput",
|
|
666
|
-
|
|
722
|
+
logicPinData: {
|
|
723
|
+
interface: "input",
|
|
724
|
+
index: 0
|
|
725
|
+
}
|
|
667
726
|
}],
|
|
668
727
|
["input2", {
|
|
669
728
|
subtype: "logicInput",
|
|
670
|
-
|
|
729
|
+
logicPinData: {
|
|
730
|
+
interface: "input",
|
|
731
|
+
index: 1
|
|
732
|
+
}
|
|
671
733
|
}],
|
|
672
734
|
["input3", {
|
|
673
735
|
subtype: "logicInput",
|
|
674
|
-
|
|
736
|
+
logicPinData: {
|
|
737
|
+
interface: "input",
|
|
738
|
+
index: 2
|
|
739
|
+
}
|
|
675
740
|
}],
|
|
676
741
|
["input4", {
|
|
677
742
|
subtype: "logicInput",
|
|
678
|
-
|
|
743
|
+
logicPinData: {
|
|
744
|
+
interface: "input",
|
|
745
|
+
index: 3
|
|
746
|
+
}
|
|
679
747
|
}],
|
|
680
748
|
["output", {
|
|
681
749
|
subtype: "logicOutput",
|
|
682
|
-
|
|
750
|
+
logicPinData: {
|
|
751
|
+
interface: "output",
|
|
752
|
+
index: 0
|
|
753
|
+
}
|
|
683
754
|
}],
|
|
684
755
|
["gnd", {
|
|
685
756
|
subtype: "gnd",
|
|
@@ -695,7 +766,6 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
695
766
|
},
|
|
696
767
|
[u.Xor8Gate]: {
|
|
697
768
|
id: u.Xor8Gate,
|
|
698
|
-
name: "XOR8 Gate",
|
|
699
769
|
pins: /* @__PURE__ */ new Map([
|
|
700
770
|
["vcc", {
|
|
701
771
|
subtype: "vcc",
|
|
@@ -703,39 +773,66 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
703
773
|
}],
|
|
704
774
|
["input1", {
|
|
705
775
|
subtype: "logicInput",
|
|
706
|
-
|
|
776
|
+
logicPinData: {
|
|
777
|
+
interface: "input",
|
|
778
|
+
index: 0
|
|
779
|
+
}
|
|
707
780
|
}],
|
|
708
781
|
["input2", {
|
|
709
782
|
subtype: "logicInput",
|
|
710
|
-
|
|
783
|
+
logicPinData: {
|
|
784
|
+
interface: "input",
|
|
785
|
+
index: 1
|
|
786
|
+
}
|
|
711
787
|
}],
|
|
712
788
|
["input3", {
|
|
713
789
|
subtype: "logicInput",
|
|
714
|
-
|
|
790
|
+
logicPinData: {
|
|
791
|
+
interface: "input",
|
|
792
|
+
index: 2
|
|
793
|
+
}
|
|
715
794
|
}],
|
|
716
795
|
["input4", {
|
|
717
796
|
subtype: "logicInput",
|
|
718
|
-
|
|
797
|
+
logicPinData: {
|
|
798
|
+
interface: "input",
|
|
799
|
+
index: 3
|
|
800
|
+
}
|
|
719
801
|
}],
|
|
720
802
|
["input5", {
|
|
721
803
|
subtype: "logicInput",
|
|
722
|
-
|
|
804
|
+
logicPinData: {
|
|
805
|
+
interface: "input",
|
|
806
|
+
index: 4
|
|
807
|
+
}
|
|
723
808
|
}],
|
|
724
809
|
["input6", {
|
|
725
810
|
subtype: "logicInput",
|
|
726
|
-
|
|
811
|
+
logicPinData: {
|
|
812
|
+
interface: "input",
|
|
813
|
+
index: 5
|
|
814
|
+
}
|
|
727
815
|
}],
|
|
728
816
|
["input7", {
|
|
729
817
|
subtype: "logicInput",
|
|
730
|
-
|
|
818
|
+
logicPinData: {
|
|
819
|
+
interface: "input",
|
|
820
|
+
index: 6
|
|
821
|
+
}
|
|
731
822
|
}],
|
|
732
823
|
["input8", {
|
|
733
824
|
subtype: "logicInput",
|
|
734
|
-
|
|
825
|
+
logicPinData: {
|
|
826
|
+
interface: "input",
|
|
827
|
+
index: 7
|
|
828
|
+
}
|
|
735
829
|
}],
|
|
736
830
|
["output", {
|
|
737
831
|
subtype: "logicOutput",
|
|
738
|
-
|
|
832
|
+
logicPinData: {
|
|
833
|
+
interface: "output",
|
|
834
|
+
index: 0
|
|
835
|
+
}
|
|
739
836
|
}],
|
|
740
837
|
["gnd", {
|
|
741
838
|
subtype: "gnd",
|
|
@@ -748,8 +845,444 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
748
845
|
["transitionSpan", "6"],
|
|
749
846
|
["initializationOrder", ""]
|
|
750
847
|
])
|
|
848
|
+
},
|
|
849
|
+
[u.HalfAdder]: {
|
|
850
|
+
id: u.HalfAdder,
|
|
851
|
+
pins: /* @__PURE__ */ new Map([
|
|
852
|
+
["vcc", {
|
|
853
|
+
subtype: "vcc",
|
|
854
|
+
sourceType: g.Voltage
|
|
855
|
+
}],
|
|
856
|
+
["inputA", {
|
|
857
|
+
subtype: "logicInput",
|
|
858
|
+
logicPinData: {
|
|
859
|
+
interface: "input",
|
|
860
|
+
index: 0
|
|
861
|
+
}
|
|
862
|
+
}],
|
|
863
|
+
["inputB", {
|
|
864
|
+
subtype: "logicInput",
|
|
865
|
+
logicPinData: {
|
|
866
|
+
interface: "input",
|
|
867
|
+
index: 1
|
|
868
|
+
}
|
|
869
|
+
}],
|
|
870
|
+
["sum", {
|
|
871
|
+
subtype: "logicOutput",
|
|
872
|
+
logicPinData: {
|
|
873
|
+
interface: "sum",
|
|
874
|
+
index: 0
|
|
875
|
+
}
|
|
876
|
+
}],
|
|
877
|
+
["carry", {
|
|
878
|
+
subtype: "logicOutput",
|
|
879
|
+
logicPinData: {
|
|
880
|
+
interface: "carry",
|
|
881
|
+
index: 0
|
|
882
|
+
}
|
|
883
|
+
}],
|
|
884
|
+
["gnd", {
|
|
885
|
+
subtype: "gnd",
|
|
886
|
+
sourceType: g.Current
|
|
887
|
+
}]
|
|
888
|
+
]),
|
|
889
|
+
config: /* @__PURE__ */ new Map([
|
|
890
|
+
["defaultLogicFamily", "CMOS1"],
|
|
891
|
+
["transitionSpan", "2"],
|
|
892
|
+
["initializationOrder", ""]
|
|
893
|
+
])
|
|
894
|
+
},
|
|
895
|
+
[u.Adder]: {
|
|
896
|
+
id: u.Adder,
|
|
897
|
+
pins: /* @__PURE__ */ new Map([
|
|
898
|
+
["vcc", {
|
|
899
|
+
subtype: "vcc",
|
|
900
|
+
sourceType: g.Voltage
|
|
901
|
+
}],
|
|
902
|
+
["carryIn", {
|
|
903
|
+
subtype: "logicInput",
|
|
904
|
+
logicPinData: {
|
|
905
|
+
interface: "carryIn",
|
|
906
|
+
index: 0
|
|
907
|
+
}
|
|
908
|
+
}],
|
|
909
|
+
["inputA", {
|
|
910
|
+
subtype: "logicInput",
|
|
911
|
+
logicPinData: {
|
|
912
|
+
interface: "input",
|
|
913
|
+
index: 0
|
|
914
|
+
}
|
|
915
|
+
}],
|
|
916
|
+
["inputB", {
|
|
917
|
+
subtype: "logicInput",
|
|
918
|
+
logicPinData: {
|
|
919
|
+
interface: "input",
|
|
920
|
+
index: 1
|
|
921
|
+
}
|
|
922
|
+
}],
|
|
923
|
+
["sum", {
|
|
924
|
+
subtype: "logicOutput",
|
|
925
|
+
logicPinData: {
|
|
926
|
+
interface: "sum",
|
|
927
|
+
index: 0
|
|
928
|
+
}
|
|
929
|
+
}],
|
|
930
|
+
["carryOut", {
|
|
931
|
+
subtype: "logicOutput",
|
|
932
|
+
logicPinData: {
|
|
933
|
+
interface: "carryOut",
|
|
934
|
+
index: 0
|
|
935
|
+
}
|
|
936
|
+
}],
|
|
937
|
+
["gnd", {
|
|
938
|
+
subtype: "gnd",
|
|
939
|
+
sourceType: g.Current
|
|
940
|
+
}]
|
|
941
|
+
]),
|
|
942
|
+
config: /* @__PURE__ */ new Map([
|
|
943
|
+
["defaultLogicFamily", "CMOS1"],
|
|
944
|
+
["transitionSpan", "4"],
|
|
945
|
+
["initializationOrder", ""]
|
|
946
|
+
])
|
|
947
|
+
},
|
|
948
|
+
[u.EightBitAdder]: {
|
|
949
|
+
id: u.EightBitAdder,
|
|
950
|
+
pins: /* @__PURE__ */ new Map([
|
|
951
|
+
["vcc", {
|
|
952
|
+
subtype: "vcc",
|
|
953
|
+
sourceType: g.Voltage
|
|
954
|
+
}],
|
|
955
|
+
["carryIn", {
|
|
956
|
+
subtype: "logicInput",
|
|
957
|
+
logicPinData: {
|
|
958
|
+
interface: "carryIn",
|
|
959
|
+
index: 0
|
|
960
|
+
}
|
|
961
|
+
}],
|
|
962
|
+
["inputA-0", {
|
|
963
|
+
subtype: "logicInput",
|
|
964
|
+
logicPinData: {
|
|
965
|
+
interface: "inputA",
|
|
966
|
+
index: 0
|
|
967
|
+
}
|
|
968
|
+
}],
|
|
969
|
+
["inputA-1", {
|
|
970
|
+
subtype: "logicInput",
|
|
971
|
+
logicPinData: {
|
|
972
|
+
interface: "inputA",
|
|
973
|
+
index: 1
|
|
974
|
+
}
|
|
975
|
+
}],
|
|
976
|
+
["inputA-2", {
|
|
977
|
+
subtype: "logicInput",
|
|
978
|
+
logicPinData: {
|
|
979
|
+
interface: "inputA",
|
|
980
|
+
index: 2
|
|
981
|
+
}
|
|
982
|
+
}],
|
|
983
|
+
["inputA-3", {
|
|
984
|
+
subtype: "logicInput",
|
|
985
|
+
logicPinData: {
|
|
986
|
+
interface: "inputA",
|
|
987
|
+
index: 3
|
|
988
|
+
}
|
|
989
|
+
}],
|
|
990
|
+
["inputA-4", {
|
|
991
|
+
subtype: "logicInput",
|
|
992
|
+
logicPinData: {
|
|
993
|
+
interface: "inputA",
|
|
994
|
+
index: 4
|
|
995
|
+
}
|
|
996
|
+
}],
|
|
997
|
+
["inputA-5", {
|
|
998
|
+
subtype: "logicInput",
|
|
999
|
+
logicPinData: {
|
|
1000
|
+
interface: "inputA",
|
|
1001
|
+
index: 5
|
|
1002
|
+
}
|
|
1003
|
+
}],
|
|
1004
|
+
["inputA-6", {
|
|
1005
|
+
subtype: "logicInput",
|
|
1006
|
+
logicPinData: {
|
|
1007
|
+
interface: "inputA",
|
|
1008
|
+
index: 6
|
|
1009
|
+
}
|
|
1010
|
+
}],
|
|
1011
|
+
["inputA-7", {
|
|
1012
|
+
subtype: "logicInput",
|
|
1013
|
+
logicPinData: {
|
|
1014
|
+
interface: "inputA",
|
|
1015
|
+
index: 7
|
|
1016
|
+
}
|
|
1017
|
+
}],
|
|
1018
|
+
["inputB-0", {
|
|
1019
|
+
subtype: "logicInput",
|
|
1020
|
+
logicPinData: {
|
|
1021
|
+
interface: "inputB",
|
|
1022
|
+
index: 0
|
|
1023
|
+
}
|
|
1024
|
+
}],
|
|
1025
|
+
["inputB-1", {
|
|
1026
|
+
subtype: "logicInput",
|
|
1027
|
+
logicPinData: {
|
|
1028
|
+
interface: "inputB",
|
|
1029
|
+
index: 1
|
|
1030
|
+
}
|
|
1031
|
+
}],
|
|
1032
|
+
["inputB-2", {
|
|
1033
|
+
subtype: "logicInput",
|
|
1034
|
+
logicPinData: {
|
|
1035
|
+
interface: "inputB",
|
|
1036
|
+
index: 2
|
|
1037
|
+
}
|
|
1038
|
+
}],
|
|
1039
|
+
["inputB-3", {
|
|
1040
|
+
subtype: "logicInput",
|
|
1041
|
+
logicPinData: {
|
|
1042
|
+
interface: "inputB",
|
|
1043
|
+
index: 3
|
|
1044
|
+
}
|
|
1045
|
+
}],
|
|
1046
|
+
["inputB-4", {
|
|
1047
|
+
subtype: "logicInput",
|
|
1048
|
+
logicPinData: {
|
|
1049
|
+
interface: "inputB",
|
|
1050
|
+
index: 4
|
|
1051
|
+
}
|
|
1052
|
+
}],
|
|
1053
|
+
["inputB-5", {
|
|
1054
|
+
subtype: "logicInput",
|
|
1055
|
+
logicPinData: {
|
|
1056
|
+
interface: "inputB",
|
|
1057
|
+
index: 5
|
|
1058
|
+
}
|
|
1059
|
+
}],
|
|
1060
|
+
["inputB-6", {
|
|
1061
|
+
subtype: "logicInput",
|
|
1062
|
+
logicPinData: {
|
|
1063
|
+
interface: "inputB",
|
|
1064
|
+
index: 6
|
|
1065
|
+
}
|
|
1066
|
+
}],
|
|
1067
|
+
["inputB-7", {
|
|
1068
|
+
subtype: "logicInput",
|
|
1069
|
+
logicPinData: {
|
|
1070
|
+
interface: "inputB",
|
|
1071
|
+
index: 7
|
|
1072
|
+
}
|
|
1073
|
+
}],
|
|
1074
|
+
["sum-0", {
|
|
1075
|
+
subtype: "logicOutput",
|
|
1076
|
+
logicPinData: {
|
|
1077
|
+
interface: "sum",
|
|
1078
|
+
index: 0
|
|
1079
|
+
}
|
|
1080
|
+
}],
|
|
1081
|
+
["sum-1", {
|
|
1082
|
+
subtype: "logicOutput",
|
|
1083
|
+
logicPinData: {
|
|
1084
|
+
interface: "sum",
|
|
1085
|
+
index: 1
|
|
1086
|
+
}
|
|
1087
|
+
}],
|
|
1088
|
+
["sum-2", {
|
|
1089
|
+
subtype: "logicOutput",
|
|
1090
|
+
logicPinData: {
|
|
1091
|
+
interface: "sum",
|
|
1092
|
+
index: 2
|
|
1093
|
+
}
|
|
1094
|
+
}],
|
|
1095
|
+
["sum-3", {
|
|
1096
|
+
subtype: "logicOutput",
|
|
1097
|
+
logicPinData: {
|
|
1098
|
+
interface: "sum",
|
|
1099
|
+
index: 3
|
|
1100
|
+
}
|
|
1101
|
+
}],
|
|
1102
|
+
["sum-4", {
|
|
1103
|
+
subtype: "logicOutput",
|
|
1104
|
+
logicPinData: {
|
|
1105
|
+
interface: "sum",
|
|
1106
|
+
index: 4
|
|
1107
|
+
}
|
|
1108
|
+
}],
|
|
1109
|
+
["sum-5", {
|
|
1110
|
+
subtype: "logicOutput",
|
|
1111
|
+
logicPinData: {
|
|
1112
|
+
interface: "sum",
|
|
1113
|
+
index: 5
|
|
1114
|
+
}
|
|
1115
|
+
}],
|
|
1116
|
+
["sum-6", {
|
|
1117
|
+
subtype: "logicOutput",
|
|
1118
|
+
logicPinData: {
|
|
1119
|
+
interface: "sum",
|
|
1120
|
+
index: 6
|
|
1121
|
+
}
|
|
1122
|
+
}],
|
|
1123
|
+
["sum-7", {
|
|
1124
|
+
subtype: "logicOutput",
|
|
1125
|
+
logicPinData: {
|
|
1126
|
+
interface: "sum",
|
|
1127
|
+
index: 7
|
|
1128
|
+
}
|
|
1129
|
+
}],
|
|
1130
|
+
["carryOut", {
|
|
1131
|
+
subtype: "logicOutput",
|
|
1132
|
+
logicPinData: {
|
|
1133
|
+
interface: "carryOut",
|
|
1134
|
+
index: 0
|
|
1135
|
+
}
|
|
1136
|
+
}],
|
|
1137
|
+
["gnd", {
|
|
1138
|
+
subtype: "gnd",
|
|
1139
|
+
sourceType: g.Current
|
|
1140
|
+
}]
|
|
1141
|
+
]),
|
|
1142
|
+
config: /* @__PURE__ */ new Map([
|
|
1143
|
+
["defaultLogicFamily", "CMOS1"],
|
|
1144
|
+
["transitionSpan", "4"],
|
|
1145
|
+
["initializationOrder", ""]
|
|
1146
|
+
])
|
|
1147
|
+
},
|
|
1148
|
+
[u.EightBitOnesComplement]: {
|
|
1149
|
+
id: u.EightBitOnesComplement,
|
|
1150
|
+
pins: /* @__PURE__ */ new Map([
|
|
1151
|
+
["vcc", {
|
|
1152
|
+
subtype: "vcc",
|
|
1153
|
+
sourceType: g.Voltage
|
|
1154
|
+
}],
|
|
1155
|
+
["invert", {
|
|
1156
|
+
subtype: "logicInput",
|
|
1157
|
+
logicPinData: {
|
|
1158
|
+
interface: "invert",
|
|
1159
|
+
index: 0
|
|
1160
|
+
}
|
|
1161
|
+
}],
|
|
1162
|
+
["input-0", {
|
|
1163
|
+
subtype: "logicInput",
|
|
1164
|
+
logicPinData: {
|
|
1165
|
+
interface: "input",
|
|
1166
|
+
index: 0
|
|
1167
|
+
}
|
|
1168
|
+
}],
|
|
1169
|
+
["input-1", {
|
|
1170
|
+
subtype: "logicInput",
|
|
1171
|
+
logicPinData: {
|
|
1172
|
+
interface: "input",
|
|
1173
|
+
index: 1
|
|
1174
|
+
}
|
|
1175
|
+
}],
|
|
1176
|
+
["input-2", {
|
|
1177
|
+
subtype: "logicInput",
|
|
1178
|
+
logicPinData: {
|
|
1179
|
+
interface: "input",
|
|
1180
|
+
index: 2
|
|
1181
|
+
}
|
|
1182
|
+
}],
|
|
1183
|
+
["input-3", {
|
|
1184
|
+
subtype: "logicInput",
|
|
1185
|
+
logicPinData: {
|
|
1186
|
+
interface: "input",
|
|
1187
|
+
index: 3
|
|
1188
|
+
}
|
|
1189
|
+
}],
|
|
1190
|
+
["input-4", {
|
|
1191
|
+
subtype: "logicInput",
|
|
1192
|
+
logicPinData: {
|
|
1193
|
+
interface: "input",
|
|
1194
|
+
index: 4
|
|
1195
|
+
}
|
|
1196
|
+
}],
|
|
1197
|
+
["input-5", {
|
|
1198
|
+
subtype: "logicInput",
|
|
1199
|
+
logicPinData: {
|
|
1200
|
+
interface: "input",
|
|
1201
|
+
index: 5
|
|
1202
|
+
}
|
|
1203
|
+
}],
|
|
1204
|
+
["input-6", {
|
|
1205
|
+
subtype: "logicInput",
|
|
1206
|
+
logicPinData: {
|
|
1207
|
+
interface: "input",
|
|
1208
|
+
index: 6
|
|
1209
|
+
}
|
|
1210
|
+
}],
|
|
1211
|
+
["input-7", {
|
|
1212
|
+
subtype: "logicInput",
|
|
1213
|
+
logicPinData: {
|
|
1214
|
+
interface: "input",
|
|
1215
|
+
index: 7
|
|
1216
|
+
}
|
|
1217
|
+
}],
|
|
1218
|
+
["output-0", {
|
|
1219
|
+
subtype: "logicOutput",
|
|
1220
|
+
logicPinData: {
|
|
1221
|
+
interface: "output",
|
|
1222
|
+
index: 0
|
|
1223
|
+
}
|
|
1224
|
+
}],
|
|
1225
|
+
["output-1", {
|
|
1226
|
+
subtype: "logicOutput",
|
|
1227
|
+
logicPinData: {
|
|
1228
|
+
interface: "output",
|
|
1229
|
+
index: 1
|
|
1230
|
+
}
|
|
1231
|
+
}],
|
|
1232
|
+
["output-2", {
|
|
1233
|
+
subtype: "logicOutput",
|
|
1234
|
+
logicPinData: {
|
|
1235
|
+
interface: "output",
|
|
1236
|
+
index: 2
|
|
1237
|
+
}
|
|
1238
|
+
}],
|
|
1239
|
+
["output-3", {
|
|
1240
|
+
subtype: "logicOutput",
|
|
1241
|
+
logicPinData: {
|
|
1242
|
+
interface: "output",
|
|
1243
|
+
index: 3
|
|
1244
|
+
}
|
|
1245
|
+
}],
|
|
1246
|
+
["output-4", {
|
|
1247
|
+
subtype: "logicOutput",
|
|
1248
|
+
logicPinData: {
|
|
1249
|
+
interface: "output",
|
|
1250
|
+
index: 4
|
|
1251
|
+
}
|
|
1252
|
+
}],
|
|
1253
|
+
["output-5", {
|
|
1254
|
+
subtype: "logicOutput",
|
|
1255
|
+
logicPinData: {
|
|
1256
|
+
interface: "output",
|
|
1257
|
+
index: 5
|
|
1258
|
+
}
|
|
1259
|
+
}],
|
|
1260
|
+
["output-6", {
|
|
1261
|
+
subtype: "logicOutput",
|
|
1262
|
+
logicPinData: {
|
|
1263
|
+
interface: "output",
|
|
1264
|
+
index: 6
|
|
1265
|
+
}
|
|
1266
|
+
}],
|
|
1267
|
+
["output-7", {
|
|
1268
|
+
subtype: "logicOutput",
|
|
1269
|
+
logicPinData: {
|
|
1270
|
+
interface: "output",
|
|
1271
|
+
index: 7
|
|
1272
|
+
}
|
|
1273
|
+
}],
|
|
1274
|
+
["gnd", {
|
|
1275
|
+
subtype: "gnd",
|
|
1276
|
+
sourceType: g.Current
|
|
1277
|
+
}]
|
|
1278
|
+
]),
|
|
1279
|
+
config: /* @__PURE__ */ new Map([
|
|
1280
|
+
["defaultLogicFamily", "CMOS1"],
|
|
1281
|
+
["transitionSpan", "3"],
|
|
1282
|
+
["initializationOrder", ""]
|
|
1283
|
+
])
|
|
751
1284
|
}
|
|
752
|
-
},
|
|
1285
|
+
}, L = class tt {
|
|
753
1286
|
id;
|
|
754
1287
|
type;
|
|
755
1288
|
component;
|
|
@@ -758,11 +1291,11 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
758
1291
|
wires;
|
|
759
1292
|
source;
|
|
760
1293
|
subtype;
|
|
761
|
-
constructor(t, n, i, s,
|
|
762
|
-
this.id =
|
|
1294
|
+
constructor(t, n, i, s, r = void 0, a = "free") {
|
|
1295
|
+
this.id = $(), this.type = t, this.component = n, this.pinLabel = i, this.position = s, this.wires = /* @__PURE__ */ new Set(), this.source = r, this.subtype = a;
|
|
763
1296
|
}
|
|
764
1297
|
getPosition(t) {
|
|
765
|
-
if (this.type ===
|
|
1298
|
+
if (this.type === P.Pin) {
|
|
766
1299
|
if (!this.component) throw new Error("Pin node missing component reference");
|
|
767
1300
|
const n = t.getComponent(this.component);
|
|
768
1301
|
if (!n) throw new Error(`Component ${this.component} not found for pin node ${this.id}`);
|
|
@@ -794,10 +1327,10 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
794
1327
|
source: this.source || null,
|
|
795
1328
|
subtype: this.subtype
|
|
796
1329
|
};
|
|
797
|
-
return this.type ===
|
|
1330
|
+
return this.type === P.Pin ? (t.component = this.component || null, t.pinLabel = this.pinLabel || null) : t.position = this.position?.toJSON() || null, t;
|
|
798
1331
|
}
|
|
799
1332
|
static fromJSON(t) {
|
|
800
|
-
const n = t.position ?
|
|
1333
|
+
const n = t.position ? V.fromJSON(t.position) : void 0, i = new tt(t.type, t.component || void 0, t.pinLabel || void 0, n, t.source || void 0, t.subtype ?? "free");
|
|
801
1334
|
return Object.defineProperty(i, "id", {
|
|
802
1335
|
value: t.id,
|
|
803
1336
|
writable: !1,
|
|
@@ -805,13 +1338,13 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
805
1338
|
configurable: !1
|
|
806
1339
|
}), i;
|
|
807
1340
|
}
|
|
808
|
-
}, E = class
|
|
1341
|
+
}, E = class et {
|
|
809
1342
|
id;
|
|
810
1343
|
node1;
|
|
811
1344
|
node2;
|
|
812
1345
|
intermediatePositions;
|
|
813
1346
|
constructor(t, n, i = []) {
|
|
814
|
-
this.id =
|
|
1347
|
+
this.id = $(), this.node1 = t, this.node2 = n, this.intermediatePositions = i;
|
|
815
1348
|
}
|
|
816
1349
|
isStraightLine() {
|
|
817
1350
|
return this.intermediatePositions.length === 0;
|
|
@@ -825,7 +1358,7 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
825
1358
|
};
|
|
826
1359
|
}
|
|
827
1360
|
static fromJSON(t) {
|
|
828
|
-
const n = t.intermediatePositions.map((s) =>
|
|
1361
|
+
const n = t.intermediatePositions.map((s) => V.fromJSON(s)), i = new et(t.node1, t.node2, n);
|
|
829
1362
|
return Object.defineProperty(i, "id", {
|
|
830
1363
|
value: t.id,
|
|
831
1364
|
writable: !1,
|
|
@@ -833,7 +1366,7 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
833
1366
|
configurable: !1
|
|
834
1367
|
}), i;
|
|
835
1368
|
}
|
|
836
|
-
},
|
|
1369
|
+
}, z = class it {
|
|
837
1370
|
id;
|
|
838
1371
|
type;
|
|
839
1372
|
position;
|
|
@@ -841,19 +1374,24 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
841
1374
|
pins;
|
|
842
1375
|
config;
|
|
843
1376
|
editable;
|
|
844
|
-
constructor(t, n, i, s,
|
|
845
|
-
if (this.id =
|
|
846
|
-
const
|
|
847
|
-
throw new Error(`Duplicate pin names are not allowed: ${[...new Set(
|
|
1377
|
+
constructor(t, n, i, s, r = !0) {
|
|
1378
|
+
if (this.id = $(), this.type = t, this.position = n, this.rotation = i, new Set(s).size !== s.length) {
|
|
1379
|
+
const a = s.filter((o, c) => s.indexOf(o) !== c);
|
|
1380
|
+
throw new Error(`Duplicate pin names are not allowed: ${[...new Set(a)].join(", ")}`);
|
|
848
1381
|
}
|
|
849
|
-
this.pins = s, this.config = new Map(
|
|
1382
|
+
this.pins = s, this.config = new Map(I[t].config), this.editable = r;
|
|
850
1383
|
}
|
|
851
1384
|
getPinLabel(t) {
|
|
852
1385
|
const n = this.pins.indexOf(t);
|
|
853
1386
|
if (n === -1) return;
|
|
854
|
-
const i =
|
|
1387
|
+
const i = I[this.type].pins.keys();
|
|
855
1388
|
return Array.from(i)[n] || void 0;
|
|
856
1389
|
}
|
|
1390
|
+
getPinMetadata(t) {
|
|
1391
|
+
const n = this.getPinLabel(t);
|
|
1392
|
+
if (n)
|
|
1393
|
+
return I[this.type].pins.get(n);
|
|
1394
|
+
}
|
|
857
1395
|
setAllParameters(t) {
|
|
858
1396
|
this.config = new Map(t);
|
|
859
1397
|
}
|
|
@@ -888,7 +1426,7 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
888
1426
|
};
|
|
889
1427
|
}
|
|
890
1428
|
static fromJSON(t) {
|
|
891
|
-
const n = new
|
|
1429
|
+
const n = new it(t.type, V.fromJSON(t.position), yt.fromJSON(t.rotation), t.pins, t.editable);
|
|
892
1430
|
return n.config = new Map(Object.entries(t.config)), Object.defineProperty(n, "id", {
|
|
893
1431
|
value: t.id,
|
|
894
1432
|
writable: !1,
|
|
@@ -896,8 +1434,8 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
896
1434
|
configurable: !1
|
|
897
1435
|
}), n;
|
|
898
1436
|
}
|
|
899
|
-
},
|
|
900
|
-
constructor(t = "Untitled Circuit", n =
|
|
1437
|
+
}, H = class nt {
|
|
1438
|
+
constructor(t = "Untitled Circuit", n = j) {
|
|
901
1439
|
this.name = t, this.defaultLogicFamily = n;
|
|
902
1440
|
}
|
|
903
1441
|
toJSON() {
|
|
@@ -907,11 +1445,11 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
907
1445
|
};
|
|
908
1446
|
}
|
|
909
1447
|
static fromJSON(t) {
|
|
910
|
-
return new
|
|
1448
|
+
return new nt(t.name, t.defaultLogicFamily);
|
|
911
1449
|
}
|
|
912
|
-
},
|
|
913
|
-
constructor(t, n, i, s,
|
|
914
|
-
if (this.version = t, this.options = n, this.size = i, this.divisions = s, this.cameraOptions =
|
|
1450
|
+
}, F = class st {
|
|
1451
|
+
constructor(t, n, i, s, r) {
|
|
1452
|
+
if (this.version = t, this.options = n, this.size = i, this.divisions = s, this.cameraOptions = r, !Number.isInteger(i) || !Number.isInteger(s)) throw new TypeError(`Size and divisions must be integers (got size=${i}, divisions=${s})`);
|
|
915
1453
|
}
|
|
916
1454
|
toJSON() {
|
|
917
1455
|
return {
|
|
@@ -923,43 +1461,43 @@ var X = "0.0.11", g = /* @__PURE__ */ (function(e) {
|
|
|
923
1461
|
};
|
|
924
1462
|
}
|
|
925
1463
|
static fromJSON(t) {
|
|
926
|
-
t.version !== "0.0.11" && console.warn(`This version of the engine supports v${
|
|
1464
|
+
t.version !== "0.0.11" && console.warn(`This version of the engine supports v${Z} circuit version files.
|
|
927
1465
|
Unexpected behavior may occurs loading v${t.version}.`);
|
|
928
|
-
const n = t.options ?
|
|
929
|
-
return new
|
|
1466
|
+
const n = t.options ? H.fromJSON(t.options) : new H("Untitled Circuit", j);
|
|
1467
|
+
return new st(t.version, n, t.size, t.divisions, Q.fromJSON(t.cameraOptions));
|
|
930
1468
|
}
|
|
931
1469
|
toString() {
|
|
932
1470
|
return `CircuitMetadata(${this.version}, ${this.options.name}, ${this.options.defaultLogicFamily}, ${this.size}, ${this.divisions}, ${this.cameraOptions.toString()})`;
|
|
933
1471
|
}
|
|
934
|
-
},
|
|
1472
|
+
}, vt = {
|
|
935
1473
|
2: 1,
|
|
936
1474
|
4: 1,
|
|
937
1475
|
8: 2,
|
|
938
1476
|
16: 2
|
|
939
|
-
},
|
|
1477
|
+
}, St = {
|
|
940
1478
|
2: 2,
|
|
941
1479
|
4: 2,
|
|
942
1480
|
8: 3,
|
|
943
1481
|
16: 3
|
|
944
|
-
},
|
|
1482
|
+
}, wt = {
|
|
945
1483
|
2: 1,
|
|
946
1484
|
4: 2,
|
|
947
1485
|
8: 2,
|
|
948
1486
|
16: 3
|
|
949
|
-
},
|
|
1487
|
+
}, mt = {
|
|
950
1488
|
2: 2,
|
|
951
1489
|
4: 3,
|
|
952
1490
|
8: 3,
|
|
953
1491
|
16: 4
|
|
954
1492
|
};
|
|
955
|
-
function
|
|
1493
|
+
function bt(e) {
|
|
956
1494
|
const t = e.config.get("defaultLogicFamily");
|
|
957
|
-
if (!(!t || t === "Sandbox") &&
|
|
958
|
-
const n = e.config.get("activationLogic") ?? "negative", i =
|
|
959
|
-
return i &&
|
|
1495
|
+
if (!(!t || t === "Sandbox") && Ct(e.type)) {
|
|
1496
|
+
const n = e.config.get("activationLogic") ?? "negative", i = Pt(e.type, n);
|
|
1497
|
+
return i && xt(t, i.gateFamily, i.inputCount) || void 0;
|
|
960
1498
|
}
|
|
961
1499
|
}
|
|
962
|
-
function
|
|
1500
|
+
function Ct(e) {
|
|
963
1501
|
return [
|
|
964
1502
|
u.Inverter,
|
|
965
1503
|
u.NandGate,
|
|
@@ -973,7 +1511,7 @@ function pt(e) {
|
|
|
973
1511
|
u.Xor8Gate
|
|
974
1512
|
].includes(e);
|
|
975
1513
|
}
|
|
976
|
-
function
|
|
1514
|
+
function Pt(e, t) {
|
|
977
1515
|
switch (e) {
|
|
978
1516
|
case u.Inverter:
|
|
979
1517
|
return {
|
|
@@ -1029,7 +1567,7 @@ function lt(e, t) {
|
|
|
1029
1567
|
return null;
|
|
1030
1568
|
}
|
|
1031
1569
|
}
|
|
1032
|
-
function
|
|
1570
|
+
function xt(e, t, n) {
|
|
1033
1571
|
if (e === "Sandbox") throw new Error("computeGateDelay must not be called for Sandbox family");
|
|
1034
1572
|
if (t === "NOT") return 1;
|
|
1035
1573
|
if (t === "Buffer") return 2;
|
|
@@ -1052,16 +1590,16 @@ function gt(e, t, n) {
|
|
|
1052
1590
|
let i;
|
|
1053
1591
|
switch (t) {
|
|
1054
1592
|
case "NAND":
|
|
1055
|
-
i =
|
|
1593
|
+
i = vt;
|
|
1056
1594
|
break;
|
|
1057
1595
|
case "AND":
|
|
1058
|
-
i =
|
|
1596
|
+
i = St;
|
|
1059
1597
|
break;
|
|
1060
1598
|
case "NOR":
|
|
1061
|
-
i =
|
|
1599
|
+
i = wt;
|
|
1062
1600
|
break;
|
|
1063
1601
|
case "OR":
|
|
1064
|
-
i =
|
|
1602
|
+
i = mt;
|
|
1065
1603
|
break;
|
|
1066
1604
|
}
|
|
1067
1605
|
const s = i[n];
|
|
@@ -1070,13 +1608,13 @@ function gt(e, t, n) {
|
|
|
1070
1608
|
}
|
|
1071
1609
|
throw new Error(`Unsupported logic family: ${e}`);
|
|
1072
1610
|
}
|
|
1073
|
-
var
|
|
1611
|
+
var me = class rt {
|
|
1074
1612
|
metadata;
|
|
1075
1613
|
components;
|
|
1076
1614
|
enodes;
|
|
1077
1615
|
wires;
|
|
1078
1616
|
constructor(t) {
|
|
1079
|
-
this.metadata = new
|
|
1617
|
+
this.metadata = new F(Z, t, 10, 10, new Q()), this.components = /* @__PURE__ */ new Map(), this.enodes = /* @__PURE__ */ new Map(), this.wires = /* @__PURE__ */ new Map();
|
|
1080
1618
|
}
|
|
1081
1619
|
get name() {
|
|
1082
1620
|
return this.metadata.options.name;
|
|
@@ -1086,38 +1624,38 @@ var ie = class Z {
|
|
|
1086
1624
|
this.metadata.options.name = t;
|
|
1087
1625
|
}
|
|
1088
1626
|
addComponent(t, n, i, s) {
|
|
1089
|
-
const
|
|
1090
|
-
if (s) for (const [c,
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
for (const [c,
|
|
1094
|
-
const
|
|
1095
|
-
this.enodes.set(
|
|
1627
|
+
const r = I[t], a = new z(t, n, i, []);
|
|
1628
|
+
if (s) for (const [c, p] of s) a.config.set(c, p);
|
|
1629
|
+
a.config.has("defaultLogicFamily") && !a.config.get("defaultLogicFamily") && a.config.set("defaultLogicFamily", this.metadata.options.defaultLogicFamily), this.resolveTransitionSpan(a);
|
|
1630
|
+
const o = [];
|
|
1631
|
+
for (const [c, p] of r.pins) {
|
|
1632
|
+
const l = new L(P.Pin, a.id, c, void 0, p.sourceType, p.subtype);
|
|
1633
|
+
this.enodes.set(l.id, l), o.push(l.id);
|
|
1096
1634
|
}
|
|
1097
|
-
return Object.defineProperty(
|
|
1098
|
-
value:
|
|
1635
|
+
return Object.defineProperty(a, "pins", {
|
|
1636
|
+
value: o,
|
|
1099
1637
|
writable: !1,
|
|
1100
1638
|
enumerable: !0,
|
|
1101
1639
|
configurable: !1
|
|
1102
|
-
}), this.components.set(
|
|
1640
|
+
}), this.components.set(a.id, a), a;
|
|
1103
1641
|
}
|
|
1104
1642
|
resolveTransitionSpan(t) {
|
|
1105
1643
|
if (!t.config.has("transitionSpan")) return;
|
|
1106
|
-
const n =
|
|
1644
|
+
const n = bt(t);
|
|
1107
1645
|
n && t.config.set("transitionSpan", String(n));
|
|
1108
1646
|
}
|
|
1109
1647
|
removeComponent(t) {
|
|
1110
1648
|
const n = this.components.get(t);
|
|
1111
1649
|
if (!n) throw new Error(`Component ${t} does not exist`);
|
|
1112
1650
|
const i = [], s = [];
|
|
1113
|
-
for (const
|
|
1114
|
-
const
|
|
1115
|
-
if (
|
|
1116
|
-
const
|
|
1117
|
-
for (const c of
|
|
1651
|
+
for (const r of n.pins) {
|
|
1652
|
+
const a = this.enodes.get(r);
|
|
1653
|
+
if (a) {
|
|
1654
|
+
const o = Array.from(a.wires);
|
|
1655
|
+
for (const c of o)
|
|
1118
1656
|
this.removeWire(c), i.push(c);
|
|
1119
1657
|
}
|
|
1120
|
-
this.enodes.delete(
|
|
1658
|
+
this.enodes.delete(r), s.push(r);
|
|
1121
1659
|
}
|
|
1122
1660
|
return this.components.delete(t), {
|
|
1123
1661
|
deletedWires: i,
|
|
@@ -1148,35 +1686,35 @@ var ie = class Z {
|
|
|
1148
1686
|
return Array.from(this.enodes.values());
|
|
1149
1687
|
}
|
|
1150
1688
|
addBranchingPoint(t, n) {
|
|
1151
|
-
const i = new
|
|
1689
|
+
const i = new L(P.BranchingPoint, void 0, void 0, t, n);
|
|
1152
1690
|
return this.enodes.set(i.id, i), i;
|
|
1153
1691
|
}
|
|
1154
1692
|
removeBranchingPoint(t) {
|
|
1155
1693
|
const n = this.enodes.get(t);
|
|
1156
1694
|
if (!n) throw new Error(`Enode ${t} does not exist`);
|
|
1157
|
-
if (n.type !==
|
|
1695
|
+
if (n.type !== P.BranchingPoint) throw new Error(`Enode ${t} is not a branching point, it must be removed with its component.`);
|
|
1158
1696
|
const i = {}, s = this.getWiresByNode(t);
|
|
1159
1697
|
if (s.length === 1 || s.length > 2) {
|
|
1160
|
-
const
|
|
1161
|
-
for (const
|
|
1162
|
-
this.removeWire(
|
|
1163
|
-
Object.assign(i, { deletedWires:
|
|
1698
|
+
const r = [];
|
|
1699
|
+
for (const a of s)
|
|
1700
|
+
this.removeWire(a.id), r.push(a.id);
|
|
1701
|
+
Object.assign(i, { deletedWires: r });
|
|
1164
1702
|
} else if (s.length === 2) {
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
Object.assign(i, { mergedWires: [
|
|
1703
|
+
const r = s[0], a = s[1], o = r.node1 === t ? r.node2 : r.node1, c = a.node1 === t ? a.node2 : a.node1, p = [];
|
|
1704
|
+
o === r.node1 ? p.push(...r.intermediatePositions) : o === r.node2 && p.push(...[...r.intermediatePositions].reverse()), p.push(n.getPosition(this)), c === a.node1 ? p.push(...[...a.intermediatePositions].reverse()) : c === a.node2 && p.push(...a.intermediatePositions), this.removeWire(r.id), this.removeWire(a.id);
|
|
1705
|
+
const l = this.addWire(o, c, p);
|
|
1706
|
+
if (l instanceof Error) throw new Error(`Failed to merge wires at branching point ${t}: ${l.message}`);
|
|
1707
|
+
Object.assign(i, { mergedWires: [r.id, a.id] }), Object.assign(i, { newWire: l });
|
|
1170
1708
|
}
|
|
1171
1709
|
return this.enodes.delete(t), i;
|
|
1172
1710
|
}
|
|
1173
1711
|
addWire(t, n, i) {
|
|
1174
1712
|
if (t === n) return /* @__PURE__ */ new Error("Cannot create wire connecting node to itself");
|
|
1175
|
-
const s = this.enodes.get(t),
|
|
1176
|
-
if (!s || !
|
|
1713
|
+
const s = this.enodes.get(t), r = this.enodes.get(n);
|
|
1714
|
+
if (!s || !r) return /* @__PURE__ */ new Error("Wire requires at least one existing ENode");
|
|
1177
1715
|
if (this.hasWireBetween(t, n)) return /* @__PURE__ */ new Error("Duplicate wire between same nodes");
|
|
1178
|
-
const
|
|
1179
|
-
return this.wires.set(
|
|
1716
|
+
const a = new E(t, n, i || []);
|
|
1717
|
+
return this.wires.set(a.id, a), s.wires.add(a.id), r.wires.add(a.id), a;
|
|
1180
1718
|
}
|
|
1181
1719
|
removeWire(t) {
|
|
1182
1720
|
const n = this.wires.get(t);
|
|
@@ -1187,38 +1725,38 @@ var ie = class Z {
|
|
|
1187
1725
|
splitWire(t, n, i = null) {
|
|
1188
1726
|
const s = this.wires.get(t);
|
|
1189
1727
|
if (!s) throw new Error(`Wire ${t} does not exist`);
|
|
1190
|
-
const
|
|
1191
|
-
if (!
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1728
|
+
const r = this.enodes.get(s.node1), a = this.enodes.get(s.node2);
|
|
1729
|
+
if (!r || !a) throw new Error(`Wire ${t} is connected to non-existent ENodes`);
|
|
1730
|
+
const o = [
|
|
1731
|
+
r.getPosition(this),
|
|
1194
1732
|
...s.intermediatePositions,
|
|
1195
|
-
|
|
1196
|
-
], c =
|
|
1197
|
-
this.wires.delete(t),
|
|
1198
|
-
let
|
|
1199
|
-
if (i) if (this.enodes.get(i))
|
|
1733
|
+
a.getPosition(this)
|
|
1734
|
+
], c = ht(o, n), p = o.slice(1, c), l = o.slice(c, o.length - 1);
|
|
1735
|
+
this.wires.delete(t), r.wires.delete(t), a.wires.delete(t);
|
|
1736
|
+
let d;
|
|
1737
|
+
if (i) if (this.enodes.get(i)) d = this.enodes.get(i);
|
|
1200
1738
|
else throw new Error(`Target ENode ${i} does not exist`);
|
|
1201
|
-
else
|
|
1202
|
-
const
|
|
1203
|
-
if ((!
|
|
1204
|
-
const f = this.addWire(
|
|
1205
|
-
f instanceof E ? (this.simplifyWireIntermediatePositions(f.id),
|
|
1739
|
+
else d = this.addBranchingPoint(n);
|
|
1740
|
+
const y = [];
|
|
1741
|
+
if ((!d.component || r.component !== d.component) && !this.hasWireBetween(r.id, d.id)) {
|
|
1742
|
+
const f = this.addWire(r.id, d.id, p);
|
|
1743
|
+
f instanceof E ? (this.simplifyWireIntermediatePositions(f.id), y.push(f)) : console.warn(`Failure to create wire at split : ${f.message}`);
|
|
1206
1744
|
}
|
|
1207
|
-
if ((!
|
|
1208
|
-
const f = this.addWire(
|
|
1209
|
-
f instanceof E ? (this.simplifyWireIntermediatePositions(f.id),
|
|
1745
|
+
if ((!d.component || a.component !== d.component) && !this.hasWireBetween(a.id, d.id)) {
|
|
1746
|
+
const f = this.addWire(d.id, a.id, l);
|
|
1747
|
+
f instanceof E ? (this.simplifyWireIntermediatePositions(f.id), y.push(f)) : console.warn(`Failure to create wire at split : ${f.message}`);
|
|
1210
1748
|
}
|
|
1211
1749
|
return {
|
|
1212
|
-
branchingPoint:
|
|
1213
|
-
wires:
|
|
1750
|
+
branchingPoint: d,
|
|
1751
|
+
wires: y
|
|
1214
1752
|
};
|
|
1215
1753
|
}
|
|
1216
1754
|
getWireBetweenNodes(t, n) {
|
|
1217
1755
|
const i = this.enodes.get(t);
|
|
1218
1756
|
if (i)
|
|
1219
1757
|
for (const s of i.wires) {
|
|
1220
|
-
const
|
|
1221
|
-
if (
|
|
1758
|
+
const r = this.wires.get(s);
|
|
1759
|
+
if (r && (r.node2 === n || r.node1 === n)) return r;
|
|
1222
1760
|
}
|
|
1223
1761
|
}
|
|
1224
1762
|
getWire(t) {
|
|
@@ -1232,8 +1770,8 @@ var ie = class Z {
|
|
|
1232
1770
|
if (!n) return [];
|
|
1233
1771
|
const i = [];
|
|
1234
1772
|
for (const s of n.wires) {
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1773
|
+
const r = this.wires.get(s);
|
|
1774
|
+
r && i.push(r);
|
|
1237
1775
|
}
|
|
1238
1776
|
return i;
|
|
1239
1777
|
}
|
|
@@ -1255,8 +1793,8 @@ var ie = class Z {
|
|
|
1255
1793
|
const i = this.enodes.get(t);
|
|
1256
1794
|
if (!i) return !1;
|
|
1257
1795
|
for (const s of i.wires) {
|
|
1258
|
-
const
|
|
1259
|
-
if (
|
|
1796
|
+
const r = this.wires.get(s);
|
|
1797
|
+
if (r && (r.node2 === n || r.node1 === n)) return !0;
|
|
1260
1798
|
}
|
|
1261
1799
|
return !1;
|
|
1262
1800
|
}
|
|
@@ -1270,11 +1808,11 @@ var ie = class Z {
|
|
|
1270
1808
|
}
|
|
1271
1809
|
getComponentPinByLabel(t, n) {
|
|
1272
1810
|
let i = 0;
|
|
1273
|
-
const s =
|
|
1274
|
-
for (const
|
|
1275
|
-
const
|
|
1811
|
+
const s = I[t.type], r = Array.from(s.pins.keys());
|
|
1812
|
+
for (const a of t.pins) {
|
|
1813
|
+
const o = this.enodes.get(a), c = r[i];
|
|
1276
1814
|
if (c) {
|
|
1277
|
-
if (
|
|
1815
|
+
if (o && c === n) return o;
|
|
1278
1816
|
i++;
|
|
1279
1817
|
}
|
|
1280
1818
|
}
|
|
@@ -1283,24 +1821,24 @@ var ie = class Z {
|
|
|
1283
1821
|
const s = this.wires.get(t);
|
|
1284
1822
|
if (!s) throw new Error(`Wire ${t} does not exist`);
|
|
1285
1823
|
if (i) {
|
|
1286
|
-
const
|
|
1824
|
+
const r = M([
|
|
1287
1825
|
this.enodes.get(s.node1).getPosition(this),
|
|
1288
1826
|
...n,
|
|
1289
1827
|
this.enodes.get(s.node2).getPosition(this)
|
|
1290
1828
|
], 10);
|
|
1291
|
-
s.intermediatePositions =
|
|
1829
|
+
s.intermediatePositions = r.slice(1, r.length - 1);
|
|
1292
1830
|
} else s.intermediatePositions = n;
|
|
1293
1831
|
return s;
|
|
1294
1832
|
}
|
|
1295
1833
|
simplifyWireIntermediatePositions(t) {
|
|
1296
1834
|
const n = this.wires.get(t);
|
|
1297
1835
|
if (!n) throw new Error(`Wire ${t} does not exist`);
|
|
1298
|
-
const i =
|
|
1836
|
+
const i = M([
|
|
1299
1837
|
this.enodes.get(n.node1).getPosition(this),
|
|
1300
1838
|
...n.intermediatePositions,
|
|
1301
1839
|
this.enodes.get(n.node2).getPosition(this)
|
|
1302
1840
|
], 5);
|
|
1303
|
-
return n.intermediatePositions = i.slice(1, i.length - 1), n.intermediatePositions =
|
|
1841
|
+
return n.intermediatePositions = i.slice(1, i.length - 1), n.intermediatePositions = M(n.intermediatePositions), n;
|
|
1304
1842
|
}
|
|
1305
1843
|
updateENodeSourceType(t, n) {
|
|
1306
1844
|
const i = this.enodes.get(t);
|
|
@@ -1311,7 +1849,7 @@ var ie = class Z {
|
|
|
1311
1849
|
let n = 0;
|
|
1312
1850
|
for (const i of this.components.values()) n = Math.max(n, Math.abs(i.position.x), Math.abs(i.position.y));
|
|
1313
1851
|
for (const i of this.enodes.values()) {
|
|
1314
|
-
if (i.type ===
|
|
1852
|
+
if (i.type === P.Pin) continue;
|
|
1315
1853
|
const s = i.position;
|
|
1316
1854
|
s && (n = Math.max(n, Math.abs(s.x), Math.abs(s.y)));
|
|
1317
1855
|
}
|
|
@@ -1327,41 +1865,41 @@ var ie = class Z {
|
|
|
1327
1865
|
};
|
|
1328
1866
|
}
|
|
1329
1867
|
static fromJSON(t) {
|
|
1330
|
-
const n =
|
|
1868
|
+
const n = F.fromJSON(t.metadata), i = new rt(n.options);
|
|
1331
1869
|
i.metadata = n;
|
|
1332
1870
|
for (const s of t.components) {
|
|
1333
|
-
const
|
|
1334
|
-
i.components.set(
|
|
1871
|
+
const r = z.fromJSON(s);
|
|
1872
|
+
i.components.set(r.id, r);
|
|
1335
1873
|
}
|
|
1336
1874
|
for (const s of t.enodes) {
|
|
1337
|
-
const
|
|
1338
|
-
i.enodes.set(
|
|
1875
|
+
const r = L.fromJSON(s);
|
|
1876
|
+
i.enodes.set(r.id, r);
|
|
1339
1877
|
}
|
|
1340
1878
|
if (t.wires) for (const s of t.wires) {
|
|
1341
|
-
const
|
|
1342
|
-
i.wires.set(
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1879
|
+
const r = E.fromJSON(s);
|
|
1880
|
+
i.wires.set(r.id, r);
|
|
1881
|
+
const a = i.enodes.get(r.node1), o = i.enodes.get(r.node2);
|
|
1882
|
+
a && a.wires.add(r.id), o && o.wires.add(r.id);
|
|
1345
1883
|
}
|
|
1346
1884
|
return i;
|
|
1347
1885
|
}
|
|
1348
|
-
},
|
|
1886
|
+
}, be = {
|
|
1349
1887
|
MIN_TPS: 1,
|
|
1350
|
-
MAX_TPS:
|
|
1888
|
+
MAX_TPS: 100,
|
|
1351
1889
|
DEFAULT_TPS: 3,
|
|
1352
1890
|
DEFAULT_INTERVAL_MS: 500
|
|
1353
|
-
},
|
|
1891
|
+
}, at = {
|
|
1354
1892
|
TRANSITION_SPAN_TICKS: 1,
|
|
1355
1893
|
TRANSITION_USER_SPAN_MS: 200
|
|
1356
1894
|
};
|
|
1357
|
-
function
|
|
1895
|
+
function T(...e) {
|
|
1358
1896
|
return {
|
|
1359
1897
|
hasVoltage: e.some((t) => t.hasVoltage),
|
|
1360
1898
|
hasCurrent: e.some((t) => t.hasCurrent),
|
|
1361
1899
|
locked: !1
|
|
1362
1900
|
};
|
|
1363
1901
|
}
|
|
1364
|
-
var
|
|
1902
|
+
var J = class ot {
|
|
1365
1903
|
tick;
|
|
1366
1904
|
nodeStates;
|
|
1367
1905
|
wireStates;
|
|
@@ -1374,12 +1912,12 @@ var V = class tt {
|
|
|
1374
1912
|
this.tick = t;
|
|
1375
1913
|
}
|
|
1376
1914
|
clone() {
|
|
1377
|
-
const t = new
|
|
1378
|
-
for (const [
|
|
1915
|
+
const t = new ot(this.tick), n = /* @__PURE__ */ new Map();
|
|
1916
|
+
for (const [r, a] of this.nodeStates.entries()) n.set(r, { ...a });
|
|
1379
1917
|
const i = /* @__PURE__ */ new Map();
|
|
1380
|
-
for (const [
|
|
1918
|
+
for (const [r, a] of this.wireStates.entries()) i.set(r, { ...a });
|
|
1381
1919
|
const s = /* @__PURE__ */ new Map();
|
|
1382
|
-
for (const [
|
|
1920
|
+
for (const [r, a] of this.componentStates.entries()) s.set(r, Object.assign(Object.create(Object.getPrototypeOf(a)), a));
|
|
1383
1921
|
return Object.defineProperty(t, "nodeStates", {
|
|
1384
1922
|
value: n,
|
|
1385
1923
|
writable: !1,
|
|
@@ -1429,26 +1967,26 @@ var V = class tt {
|
|
|
1429
1967
|
setNextState(e, t) {
|
|
1430
1968
|
this._nextState = e, this._expirationTick = t;
|
|
1431
1969
|
}
|
|
1432
|
-
},
|
|
1970
|
+
}, It = class extends b {
|
|
1433
1971
|
constructor(e) {
|
|
1434
1972
|
super(e, "on");
|
|
1435
1973
|
}
|
|
1436
|
-
},
|
|
1974
|
+
}, Tt = class extends b {
|
|
1437
1975
|
constructor(e, t = "off") {
|
|
1438
1976
|
super(e, t);
|
|
1439
1977
|
}
|
|
1440
1978
|
get isLit() {
|
|
1441
1979
|
return this.state === "on" || this.state === "goingOn";
|
|
1442
1980
|
}
|
|
1443
|
-
},
|
|
1981
|
+
}, ct = class extends b {
|
|
1444
1982
|
constructor(e, t = "off") {
|
|
1445
1983
|
super(e, t);
|
|
1446
1984
|
}
|
|
1447
1985
|
get isLit() {
|
|
1448
1986
|
return this.state === "on" || this.state === "goingOn";
|
|
1449
1987
|
}
|
|
1450
|
-
},
|
|
1451
|
-
},
|
|
1988
|
+
}, Ot = class extends ct {
|
|
1989
|
+
}, Et = class extends b {
|
|
1452
1990
|
constructor(e, t = "open") {
|
|
1453
1991
|
super(e, t);
|
|
1454
1992
|
}
|
|
@@ -1458,7 +1996,7 @@ var V = class tt {
|
|
|
1458
1996
|
get isClosed() {
|
|
1459
1997
|
return this.state === "closed" || this.state === "closing";
|
|
1460
1998
|
}
|
|
1461
|
-
},
|
|
1999
|
+
}, Nt = class extends b {
|
|
1462
2000
|
constructor(e, t = "open") {
|
|
1463
2001
|
super(e, t);
|
|
1464
2002
|
}
|
|
@@ -1468,18 +2006,18 @@ var V = class tt {
|
|
|
1468
2006
|
get isClosed() {
|
|
1469
2007
|
return this.state === "closed" || this.state === "closing";
|
|
1470
2008
|
}
|
|
1471
|
-
},
|
|
2009
|
+
}, At = class extends b {
|
|
1472
2010
|
constructor(e, t = "input1") {
|
|
1473
2011
|
super(e, t);
|
|
1474
2012
|
}
|
|
1475
2013
|
get isInTransition() {
|
|
1476
2014
|
return this.state === "1to2" || this.state === "2to1";
|
|
1477
2015
|
}
|
|
1478
|
-
},
|
|
2016
|
+
}, Bt = class extends b {
|
|
1479
2017
|
constructor(e) {
|
|
1480
2018
|
super(e, "high");
|
|
1481
2019
|
}
|
|
1482
|
-
},
|
|
2020
|
+
}, w = class extends b {
|
|
1483
2021
|
constructor(e, t = "low") {
|
|
1484
2022
|
super(e, t);
|
|
1485
2023
|
}
|
|
@@ -1489,47 +2027,107 @@ var V = class tt {
|
|
|
1489
2027
|
get isHigh() {
|
|
1490
2028
|
return this.state === "high";
|
|
1491
2029
|
}
|
|
1492
|
-
},
|
|
2030
|
+
}, Dt = class extends w {
|
|
1493
2031
|
constructor(e, t = "low") {
|
|
1494
2032
|
super(e, t);
|
|
1495
2033
|
}
|
|
1496
|
-
},
|
|
2034
|
+
}, Mt = class extends w {
|
|
1497
2035
|
constructor(e, t = "low") {
|
|
1498
2036
|
super(e, t);
|
|
1499
2037
|
}
|
|
1500
|
-
},
|
|
2038
|
+
}, Lt = class extends w {
|
|
1501
2039
|
constructor(e, t = "low") {
|
|
1502
2040
|
super(e, t);
|
|
1503
2041
|
}
|
|
1504
|
-
},
|
|
2042
|
+
}, kt = class extends w {
|
|
1505
2043
|
constructor(e, t = "low") {
|
|
1506
2044
|
super(e, t);
|
|
1507
2045
|
}
|
|
1508
|
-
},
|
|
2046
|
+
}, Gt = class extends w {
|
|
1509
2047
|
constructor(e, t = "low") {
|
|
1510
2048
|
super(e, t);
|
|
1511
2049
|
}
|
|
1512
|
-
},
|
|
2050
|
+
}, _t = class extends w {
|
|
1513
2051
|
constructor(e, t = "low") {
|
|
1514
2052
|
super(e, t);
|
|
1515
2053
|
}
|
|
1516
|
-
},
|
|
2054
|
+
}, Vt = class extends w {
|
|
1517
2055
|
constructor(e, t = "low") {
|
|
1518
2056
|
super(e, t);
|
|
1519
2057
|
}
|
|
1520
|
-
},
|
|
2058
|
+
}, $t = class extends w {
|
|
1521
2059
|
constructor(e, t = "low") {
|
|
1522
2060
|
super(e, t);
|
|
1523
2061
|
}
|
|
1524
|
-
},
|
|
2062
|
+
}, Rt = class extends w {
|
|
1525
2063
|
constructor(e, t = "low") {
|
|
1526
2064
|
super(e, t);
|
|
1527
2065
|
}
|
|
1528
|
-
},
|
|
2066
|
+
}, Wt = class extends w {
|
|
1529
2067
|
constructor(e, t = "low") {
|
|
1530
2068
|
super(e, t);
|
|
1531
2069
|
}
|
|
1532
|
-
},
|
|
2070
|
+
}, A = class extends b {
|
|
2071
|
+
outputCount;
|
|
2072
|
+
hexDigitCount;
|
|
2073
|
+
allLowState;
|
|
2074
|
+
constructor(e, t, n) {
|
|
2075
|
+
super(e, n), this.outputCount = t, this.hexDigitCount = Math.ceil(t / 4), this.allLowState = "0".repeat(this.hexDigitCount);
|
|
2076
|
+
}
|
|
2077
|
+
get isInTransition() {
|
|
2078
|
+
return this.state.startsWith("to");
|
|
2079
|
+
}
|
|
2080
|
+
get effectiveState() {
|
|
2081
|
+
return this.isInTransition ? this.parameters.get("prevState") ?? this.allLowState : this.state;
|
|
2082
|
+
}
|
|
2083
|
+
isOutputHigh(e) {
|
|
2084
|
+
const t = this.effectiveState;
|
|
2085
|
+
return t === "indeterminate" ? !1 : (parseInt(t, 16) >> e & 1) === 1;
|
|
2086
|
+
}
|
|
2087
|
+
}, zt = class extends A {
|
|
2088
|
+
constructor(e, t = "0") {
|
|
2089
|
+
super(e, 2, t);
|
|
2090
|
+
}
|
|
2091
|
+
get sumHigh() {
|
|
2092
|
+
return this.isOutputHigh(0);
|
|
2093
|
+
}
|
|
2094
|
+
get carryHigh() {
|
|
2095
|
+
return this.isOutputHigh(1);
|
|
2096
|
+
}
|
|
2097
|
+
}, Ht = class extends A {
|
|
2098
|
+
constructor(e, t = "0") {
|
|
2099
|
+
super(e, 2, t);
|
|
2100
|
+
}
|
|
2101
|
+
get sumHigh() {
|
|
2102
|
+
return this.isOutputHigh(0);
|
|
2103
|
+
}
|
|
2104
|
+
get carryOutHigh() {
|
|
2105
|
+
return this.isOutputHigh(1);
|
|
2106
|
+
}
|
|
2107
|
+
}, Ft = class extends A {
|
|
2108
|
+
constructor(e, t = "0000") {
|
|
2109
|
+
super(e, 16, t);
|
|
2110
|
+
}
|
|
2111
|
+
isSumHigh(e) {
|
|
2112
|
+
return this.isOutputHigh(2 * e);
|
|
2113
|
+
}
|
|
2114
|
+
isStageCarryHigh(e) {
|
|
2115
|
+
return this.isOutputHigh(2 * e + 1);
|
|
2116
|
+
}
|
|
2117
|
+
isCarryOutHigh() {
|
|
2118
|
+
return this.isStageCarryHigh(7);
|
|
2119
|
+
}
|
|
2120
|
+
}, Jt = class extends A {
|
|
2121
|
+
constructor(e, t = "000") {
|
|
2122
|
+
super(e, 9, t);
|
|
2123
|
+
}
|
|
2124
|
+
isOutputBitHigh(e) {
|
|
2125
|
+
return this.isOutputHigh(e);
|
|
2126
|
+
}
|
|
2127
|
+
isInvertHigh() {
|
|
2128
|
+
return this.isOutputHigh(8);
|
|
2129
|
+
}
|
|
2130
|
+
}, Ce = class {
|
|
1533
2131
|
behaviors;
|
|
1534
2132
|
constructor() {
|
|
1535
2133
|
this.behaviors = /* @__PURE__ */ new Map();
|
|
@@ -1560,7 +2158,7 @@ var V = class tt {
|
|
|
1560
2158
|
size() {
|
|
1561
2159
|
return this.behaviors.size;
|
|
1562
2160
|
}
|
|
1563
|
-
},
|
|
2161
|
+
}, C = class {
|
|
1564
2162
|
_componentType;
|
|
1565
2163
|
constructor(e) {
|
|
1566
2164
|
this._componentType = e;
|
|
@@ -1569,7 +2167,7 @@ var V = class tt {
|
|
|
1569
2167
|
return this._componentType;
|
|
1570
2168
|
}
|
|
1571
2169
|
get typeMetadata() {
|
|
1572
|
-
const e =
|
|
2170
|
+
const e = I[this._componentType];
|
|
1573
2171
|
if (!e) throw new Error(`Unknown metadata for Component type ${this._componentType}`);
|
|
1574
2172
|
return e;
|
|
1575
2173
|
}
|
|
@@ -1582,8 +2180,8 @@ var V = class tt {
|
|
|
1582
2180
|
const n = /* @__PURE__ */ new Set();
|
|
1583
2181
|
for (const [i, s] of e) {
|
|
1584
2182
|
if (!t.has(i)) continue;
|
|
1585
|
-
const
|
|
1586
|
-
(s.hasVoltage !==
|
|
2183
|
+
const r = t.get(i);
|
|
2184
|
+
(s.hasVoltage !== r?.hasVoltage || s.hasCurrent !== r?.hasCurrent) && n.add(i);
|
|
1587
2185
|
}
|
|
1588
2186
|
return n;
|
|
1589
2187
|
}
|
|
@@ -1618,29 +2216,29 @@ var V = class tt {
|
|
|
1618
2216
|
};
|
|
1619
2217
|
}
|
|
1620
2218
|
};
|
|
1621
|
-
function
|
|
2219
|
+
function x(e) {
|
|
1622
2220
|
const t = parseInt(e.get("transitionSpan") || "", 10);
|
|
1623
|
-
return isNaN(t) || t < 1 ?
|
|
2221
|
+
return isNaN(t) || t < 1 ? at.TRANSITION_SPAN_TICKS : t;
|
|
1624
2222
|
}
|
|
1625
|
-
var
|
|
2223
|
+
var Ut = class extends C {
|
|
1626
2224
|
constructor() {
|
|
1627
2225
|
super(u.Battery);
|
|
1628
2226
|
}
|
|
1629
2227
|
createInitialState(e) {
|
|
1630
2228
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for BatteryBehavior: ${e.type}`);
|
|
1631
|
-
return new
|
|
2229
|
+
return new It(e.id);
|
|
1632
2230
|
}
|
|
1633
|
-
},
|
|
2231
|
+
}, R = class extends C {
|
|
1634
2232
|
getBehavior(e, t, n, i) {
|
|
1635
2233
|
let s = !1;
|
|
1636
|
-
const
|
|
1637
|
-
return n ? (t.state === "off" || t.state === "goingOff") && (s = !0, t.setState("goingOn", i), t.setNextState("on", i +
|
|
2234
|
+
const r = [], a = x(e.config), o = t.expirationTick < 1 ? a : Math.max(i - t.startTick, 1);
|
|
2235
|
+
return n ? (t.state === "off" || t.state === "goingOff") && (s = !0, t.setState("goingOn", i), t.setNextState("on", i + o), r.push({
|
|
1638
2236
|
targetId: e.id,
|
|
1639
2237
|
scheduledAtTick: t.startTick,
|
|
1640
2238
|
readyAtTick: t.expirationTick,
|
|
1641
2239
|
type: "GoingOnEnd",
|
|
1642
2240
|
parameters: void 0
|
|
1643
|
-
})) : (t.state === "on" || t.state === "goingOn") && (s = !0, t.setState("goingOff", i), t.setNextState("off", i +
|
|
2241
|
+
})) : (t.state === "on" || t.state === "goingOn") && (s = !0, t.setState("goingOff", i), t.setNextState("off", i + o), r.push({
|
|
1644
2242
|
targetId: e.id,
|
|
1645
2243
|
scheduledAtTick: t.startTick,
|
|
1646
2244
|
readyAtTick: t.expirationTick,
|
|
@@ -1650,7 +2248,7 @@ var Mt = class extends T {
|
|
|
1650
2248
|
componentState: t,
|
|
1651
2249
|
hasChanged: s,
|
|
1652
2250
|
shouldCancelPending: !0,
|
|
1653
|
-
scheduledEvents:
|
|
2251
|
+
scheduledEvents: r
|
|
1654
2252
|
};
|
|
1655
2253
|
}
|
|
1656
2254
|
allowConductivity(e, t, n, i, s) {
|
|
@@ -1665,67 +2263,67 @@ var Mt = class extends T {
|
|
|
1665
2263
|
scheduledEvents: []
|
|
1666
2264
|
};
|
|
1667
2265
|
}
|
|
1668
|
-
},
|
|
2266
|
+
}, Xt = class extends R {
|
|
1669
2267
|
constructor() {
|
|
1670
2268
|
super(u.Lightbulb);
|
|
1671
2269
|
}
|
|
1672
2270
|
createInitialState(e) {
|
|
1673
2271
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for lightbulbBehavior: ${e.type}`);
|
|
1674
|
-
return new
|
|
2272
|
+
return new Tt(e.id);
|
|
1675
2273
|
}
|
|
1676
2274
|
onPinsChange(e, t, n, i) {
|
|
1677
2275
|
const s = this.getPinStates(e, n);
|
|
1678
2276
|
t.pinStates = s;
|
|
1679
|
-
const
|
|
1680
|
-
return this.getBehavior(e, t,
|
|
2277
|
+
const r = T(s.get("pin1"), s.get("pin2")), a = r.hasVoltage && r.hasCurrent;
|
|
2278
|
+
return this.getBehavior(e, t, a, i);
|
|
1681
2279
|
}
|
|
1682
|
-
},
|
|
2280
|
+
}, Qt = class extends R {
|
|
1683
2281
|
constructor() {
|
|
1684
2282
|
super(u.RectangleLED);
|
|
1685
2283
|
}
|
|
1686
2284
|
createInitialState(e) {
|
|
1687
2285
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for RectangleLEDBehavior: ${e.type}`);
|
|
1688
|
-
return new
|
|
2286
|
+
return new Ot(e.id);
|
|
1689
2287
|
}
|
|
1690
2288
|
onPinsChange(e, t, n, i) {
|
|
1691
2289
|
const s = this.getPinStates(e, n);
|
|
1692
2290
|
t.pinStates = s;
|
|
1693
|
-
const
|
|
1694
|
-
return this.getBehavior(e, t,
|
|
2291
|
+
const r = T(s.get("pin1"), s.get("pin2")), a = r.hasVoltage && r.hasCurrent;
|
|
2292
|
+
return this.getBehavior(e, t, a, i);
|
|
1695
2293
|
}
|
|
1696
2294
|
};
|
|
1697
|
-
function
|
|
2295
|
+
function qt(e) {
|
|
1698
2296
|
const t = parseInt(e.get("transitionSpan") || "", 10);
|
|
1699
|
-
return isNaN(t) || t < 1 ?
|
|
2297
|
+
return isNaN(t) || t < 1 ? at.TRANSITION_SPAN_TICKS : t;
|
|
1700
2298
|
}
|
|
1701
|
-
var
|
|
2299
|
+
var Kt = class extends C {
|
|
1702
2300
|
constructor() {
|
|
1703
2301
|
super(u.Relay);
|
|
1704
2302
|
}
|
|
1705
2303
|
createInitialState(e) {
|
|
1706
2304
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for RelayBehavior: ${e.type}`);
|
|
1707
2305
|
const t = e.config.get("activationLogic") === "negative" ? "closed" : "open";
|
|
1708
|
-
return new
|
|
2306
|
+
return new Et(e.id, t);
|
|
1709
2307
|
}
|
|
1710
2308
|
allowConductivity(e, t, n, i, s) {
|
|
1711
2309
|
if (i === s) return !0;
|
|
1712
|
-
const
|
|
1713
|
-
if (!
|
|
1714
|
-
const
|
|
1715
|
-
return
|
|
2310
|
+
const r = e.getPinLabel(i), a = e.getPinLabel(s);
|
|
2311
|
+
if (!r || !a) return !1;
|
|
2312
|
+
const o = [r, a];
|
|
2313
|
+
return o.includes("cmd_in") && o.includes("cmd_out") ? !0 : o.includes("power_in") && o.includes("power_out") ? t.state === "closed" || t.state === "opening" : !1;
|
|
1716
2314
|
}
|
|
1717
2315
|
onPinsChange(e, t, n, i) {
|
|
1718
2316
|
const s = this.getPinStates(e, n);
|
|
1719
|
-
s.set("cmd_in*cmd_out",
|
|
1720
|
-
const
|
|
2317
|
+
s.set("cmd_in*cmd_out", T(s.get("cmd_in"), s.get("cmd_out"))), s.set("power_in*power_out", T(s.get("power_in"), s.get("power_out")));
|
|
2318
|
+
const r = t.pinStates;
|
|
1721
2319
|
t.pinStates = s;
|
|
1722
|
-
const
|
|
1723
|
-
let
|
|
1724
|
-
const
|
|
1725
|
-
if (
|
|
2320
|
+
const a = this.getChangedPins(s, r), o = s.get("cmd_in*cmd_out"), c = o.hasVoltage && o.hasCurrent, p = e.config.get("activationLogic") === "negative" ? !c : c;
|
|
2321
|
+
let l = a.size > 0;
|
|
2322
|
+
const d = [], y = qt(e.config);
|
|
2323
|
+
if (p) {
|
|
1726
2324
|
if (t.state === "open" || t.state === "opening") {
|
|
1727
|
-
let f = t.state === "open" ?
|
|
1728
|
-
|
|
2325
|
+
let f = t.state === "open" ? y : Math.max(i - t.startTick, 1);
|
|
2326
|
+
l = !0, t.setState("closing", i), t.setNextState("closed", i + f), d.push({
|
|
1729
2327
|
targetId: e.id,
|
|
1730
2328
|
scheduledAtTick: t.startTick,
|
|
1731
2329
|
readyAtTick: t.expirationTick,
|
|
@@ -1734,8 +2332,8 @@ var _t = class extends T {
|
|
|
1734
2332
|
});
|
|
1735
2333
|
}
|
|
1736
2334
|
} else if (t.state === "closed" || t.state === "closing") {
|
|
1737
|
-
let f = t.state === "closed" ?
|
|
1738
|
-
|
|
2335
|
+
let f = t.state === "closed" ? y : Math.max(i - t.startTick, 1);
|
|
2336
|
+
l = !0, t.setState("opening", i), t.setNextState("open", i + f), d.push({
|
|
1739
2337
|
targetId: e.id,
|
|
1740
2338
|
scheduledAtTick: t.startTick,
|
|
1741
2339
|
readyAtTick: t.expirationTick,
|
|
@@ -1745,9 +2343,9 @@ var _t = class extends T {
|
|
|
1745
2343
|
}
|
|
1746
2344
|
return {
|
|
1747
2345
|
componentState: t,
|
|
1748
|
-
hasChanged:
|
|
1749
|
-
shouldCancelPending:
|
|
1750
|
-
scheduledEvents:
|
|
2346
|
+
hasChanged: l,
|
|
2347
|
+
shouldCancelPending: l,
|
|
2348
|
+
scheduledEvents: d
|
|
1751
2349
|
};
|
|
1752
2350
|
}
|
|
1753
2351
|
onEventFiring(e, t, n) {
|
|
@@ -1759,37 +2357,37 @@ var _t = class extends T {
|
|
|
1759
2357
|
scheduledEvents: []
|
|
1760
2358
|
};
|
|
1761
2359
|
}
|
|
1762
|
-
},
|
|
2360
|
+
}, Yt = class extends R {
|
|
1763
2361
|
constructor() {
|
|
1764
2362
|
super(u.SmallLED);
|
|
1765
2363
|
}
|
|
1766
2364
|
createInitialState(e) {
|
|
1767
2365
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for SmallLEDBehavior: ${e.type}`);
|
|
1768
|
-
return new
|
|
2366
|
+
return new ct(e.id);
|
|
1769
2367
|
}
|
|
1770
2368
|
onPinsChange(e, t, n, i) {
|
|
1771
2369
|
const s = this.getPinStates(e, n);
|
|
1772
2370
|
t.pinStates = s;
|
|
1773
|
-
const
|
|
1774
|
-
return this.getBehavior(e, t,
|
|
2371
|
+
const r = T(s.get("pin1"), s.get("pin2")), a = r.hasVoltage && r.hasCurrent;
|
|
2372
|
+
return this.getBehavior(e, t, a, i);
|
|
1775
2373
|
}
|
|
1776
|
-
},
|
|
2374
|
+
}, Zt = class extends C {
|
|
1777
2375
|
constructor() {
|
|
1778
2376
|
super(u.Switch);
|
|
1779
2377
|
}
|
|
1780
2378
|
createInitialState(e) {
|
|
1781
2379
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for SwitchBehavior: ${e.type}`);
|
|
1782
2380
|
const t = e.config.get("initialState") || "open";
|
|
1783
|
-
return new
|
|
2381
|
+
return new Nt(e.id, t);
|
|
1784
2382
|
}
|
|
1785
2383
|
allowConductivity(e, t, n, i, s) {
|
|
1786
2384
|
return t.state === "closed" || t.state === "opening";
|
|
1787
2385
|
}
|
|
1788
2386
|
onPinsChange(e, t, n, i) {
|
|
1789
|
-
const s = this.getPinStates(e, n),
|
|
2387
|
+
const s = this.getPinStates(e, n), r = t.pinStates;
|
|
1790
2388
|
t.pinStates = s;
|
|
1791
|
-
const
|
|
1792
|
-
return
|
|
2389
|
+
const a = this.getChangedPins(s, r);
|
|
2390
|
+
return a.size < 1 || !a.has("output") ? {
|
|
1793
2391
|
componentState: t,
|
|
1794
2392
|
hasChanged: !1,
|
|
1795
2393
|
shouldCancelPending: !1,
|
|
@@ -1803,8 +2401,8 @@ var _t = class extends T {
|
|
|
1803
2401
|
}
|
|
1804
2402
|
onUserCommand(e, t, n) {
|
|
1805
2403
|
let i = !1;
|
|
1806
|
-
const s = [],
|
|
1807
|
-
return n.type === "toggle_switch" && ["open", "closed"].includes(t.state) && (t.setState(t.state === "open" ? "closing" : "opening", n.scheduledAtTick), t.setNextState(t.state === "closing" ? "closed" : "open", n.scheduledAtTick +
|
|
2404
|
+
const s = [], r = x(e.config);
|
|
2405
|
+
return n.type === "toggle_switch" && ["open", "closed"].includes(t.state) && (t.setState(t.state === "open" ? "closing" : "opening", n.scheduledAtTick), t.setNextState(t.state === "closing" ? "closed" : "open", n.scheduledAtTick + r), i = !0, s.push({
|
|
1808
2406
|
targetId: e.id,
|
|
1809
2407
|
scheduledAtTick: t.startTick,
|
|
1810
2408
|
readyAtTick: t.expirationTick,
|
|
@@ -1826,27 +2424,27 @@ var _t = class extends T {
|
|
|
1826
2424
|
scheduledEvents: []
|
|
1827
2425
|
};
|
|
1828
2426
|
}
|
|
1829
|
-
},
|
|
2427
|
+
}, jt = class extends C {
|
|
1830
2428
|
constructor() {
|
|
1831
2429
|
super(u.DoubleThrowSwitch);
|
|
1832
2430
|
}
|
|
1833
2431
|
createInitialState(e) {
|
|
1834
2432
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for DoubleThrowSwitchBehavior: ${e.type}`);
|
|
1835
2433
|
const t = e.config.get("initialState") || "input1";
|
|
1836
|
-
return new
|
|
2434
|
+
return new At(e.id, t);
|
|
1837
2435
|
}
|
|
1838
2436
|
allowConductivity(e, t, n, i, s) {
|
|
1839
2437
|
if (i === s) return !0;
|
|
1840
|
-
const
|
|
1841
|
-
if (!
|
|
1842
|
-
const
|
|
1843
|
-
return
|
|
2438
|
+
const r = e.getPinLabel(i), a = e.getPinLabel(s);
|
|
2439
|
+
if (!r || !a) return !1;
|
|
2440
|
+
const o = [r, a];
|
|
2441
|
+
return o.includes("output") && o.includes("input1") ? t.state === "input1" || t.state === "1to2" : o.includes("output") && o.includes("input2") ? t.state === "input2" || t.state === "2to1" : !1;
|
|
1844
2442
|
}
|
|
1845
2443
|
onPinsChange(e, t, n, i) {
|
|
1846
|
-
const s = this.getPinStates(e, n),
|
|
2444
|
+
const s = this.getPinStates(e, n), r = t.pinStates;
|
|
1847
2445
|
t.pinStates = s;
|
|
1848
|
-
const
|
|
1849
|
-
return
|
|
2446
|
+
const a = this.getChangedPins(s, r);
|
|
2447
|
+
return a.size < 1 || !a.has("output") ? {
|
|
1850
2448
|
componentState: t,
|
|
1851
2449
|
hasChanged: !1,
|
|
1852
2450
|
shouldCancelPending: !1,
|
|
@@ -1860,8 +2458,8 @@ var _t = class extends T {
|
|
|
1860
2458
|
}
|
|
1861
2459
|
onUserCommand(e, t, n) {
|
|
1862
2460
|
let i = !1;
|
|
1863
|
-
const s = [],
|
|
1864
|
-
return n.type === "toggle_switch" && ["input1", "input2"].includes(t.state) && (t.setState(t.state === "input1" ? "1to2" : "2to1", n.scheduledAtTick), t.setNextState(t.state === "1to2" ? "input2" : "input1", n.scheduledAtTick +
|
|
2461
|
+
const s = [], r = x(e.config);
|
|
2462
|
+
return n.type === "toggle_switch" && ["input1", "input2"].includes(t.state) && (t.setState(t.state === "input1" ? "1to2" : "2to1", n.scheduledAtTick), t.setNextState(t.state === "1to2" ? "input2" : "input1", n.scheduledAtTick + r), i = !0, s.push({
|
|
1865
2463
|
targetId: e.id,
|
|
1866
2464
|
scheduledAtTick: t.startTick,
|
|
1867
2465
|
readyAtTick: t.expirationTick,
|
|
@@ -1883,23 +2481,23 @@ var _t = class extends T {
|
|
|
1883
2481
|
scheduledEvents: []
|
|
1884
2482
|
};
|
|
1885
2483
|
}
|
|
1886
|
-
},
|
|
2484
|
+
}, te = class extends C {
|
|
1887
2485
|
constructor() {
|
|
1888
2486
|
super(u.Clock);
|
|
1889
2487
|
}
|
|
1890
2488
|
createInitialState(e) {
|
|
1891
2489
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for ClockBehavior: ${e.type}`);
|
|
1892
|
-
const t = new
|
|
2490
|
+
const t = new Bt(e.id), n = e.config.get("startHigh") == "true";
|
|
1893
2491
|
t.setState(n ? "high" : "low", 0);
|
|
1894
2492
|
const i = Number(e.config.get("halfPeriod"));
|
|
1895
2493
|
return t.setNextState(n ? "low" : "high", i), t;
|
|
1896
2494
|
}
|
|
1897
2495
|
allowConductivity(e, t, n, i, s) {
|
|
1898
2496
|
if (i === s) return !0;
|
|
1899
|
-
const
|
|
1900
|
-
if (!
|
|
1901
|
-
const
|
|
1902
|
-
return
|
|
2497
|
+
const r = e.getPinLabel(i), a = e.getPinLabel(s);
|
|
2498
|
+
if (!r || !a) return !1;
|
|
2499
|
+
const o = [r, a];
|
|
2500
|
+
return o.includes("gnd") && o.includes("vcc") ? !1 : o.includes("gnd") && o.includes("output") ? t.state === "low" : o.includes("vcc") && o.includes("output") ? t.state === "high" : !1;
|
|
1903
2501
|
}
|
|
1904
2502
|
onStart(e, t) {
|
|
1905
2503
|
const i = Number(e.config.get("halfPeriod"));
|
|
@@ -1937,7 +2535,7 @@ var _t = class extends T {
|
|
|
1937
2535
|
}]
|
|
1938
2536
|
};
|
|
1939
2537
|
}
|
|
1940
|
-
}, m = class extends
|
|
2538
|
+
}, m = class extends C {
|
|
1941
2539
|
vccGuardBehavior(e, t, n) {
|
|
1942
2540
|
if (t.get("vcc").hasVoltage) return null;
|
|
1943
2541
|
let i = !1, s = !1;
|
|
@@ -1951,10 +2549,10 @@ var _t = class extends T {
|
|
|
1951
2549
|
nonLogicInputGuardBehavior(e, t, n) {
|
|
1952
2550
|
let i = !1;
|
|
1953
2551
|
const s = this.typeMetadata.pins;
|
|
1954
|
-
for (const [
|
|
1955
|
-
if (!s.has(
|
|
1956
|
-
const
|
|
1957
|
-
if (
|
|
2552
|
+
for (const [o, c] of t) {
|
|
2553
|
+
if (!s.has(o)) continue;
|
|
2554
|
+
const p = s.get(o);
|
|
2555
|
+
if (p && p?.subtype === "logicInput") {
|
|
1958
2556
|
if (c.hasVoltage && c.hasCurrent) {
|
|
1959
2557
|
i = !0;
|
|
1960
2558
|
break;
|
|
@@ -1966,11 +2564,11 @@ var _t = class extends T {
|
|
|
1966
2564
|
}
|
|
1967
2565
|
}
|
|
1968
2566
|
if (!i) return null;
|
|
1969
|
-
let
|
|
1970
|
-
return e.state !== "indeterminate" && (e.setState("indeterminate", n),
|
|
2567
|
+
let r = !1, a = !1;
|
|
2568
|
+
return e.state !== "indeterminate" && (e.setState("indeterminate", n), r = !0, a = !0), {
|
|
1971
2569
|
componentState: e,
|
|
1972
|
-
hasChanged:
|
|
1973
|
-
shouldCancelPending:
|
|
2570
|
+
hasChanged: r,
|
|
2571
|
+
shouldCancelPending: a,
|
|
1974
2572
|
scheduledEvents: []
|
|
1975
2573
|
};
|
|
1976
2574
|
}
|
|
@@ -1988,10 +2586,10 @@ var _t = class extends T {
|
|
|
1988
2586
|
shouldCancelPending: !0,
|
|
1989
2587
|
scheduledEvents: []
|
|
1990
2588
|
};
|
|
1991
|
-
const s =
|
|
2589
|
+
const s = x(e.config), r = t.expirationTick < 1 ? s : Math.max(i - t.startTick, 1);
|
|
1992
2590
|
if (n) {
|
|
1993
2591
|
if (t.state === "low" || t.state === "falling" || t.state === "indeterminate")
|
|
1994
|
-
return t.setState("rising", i), t.setNextState("high", i +
|
|
2592
|
+
return t.setState("rising", i), t.setNextState("high", i + r), {
|
|
1995
2593
|
componentState: t,
|
|
1996
2594
|
hasChanged: !0,
|
|
1997
2595
|
shouldCancelPending: !0,
|
|
@@ -2015,7 +2613,7 @@ var _t = class extends T {
|
|
|
2015
2613
|
hasChanged: !1,
|
|
2016
2614
|
shouldCancelPending: !1,
|
|
2017
2615
|
scheduledEvents: []
|
|
2018
|
-
} : t.state === "high" || t.state === "rising" || t.state === "indeterminate" ? (t.setState("falling", i), t.setNextState("low", i +
|
|
2616
|
+
} : t.state === "high" || t.state === "rising" || t.state === "indeterminate" ? (t.setState("falling", i), t.setNextState("low", i + r), {
|
|
2019
2617
|
componentState: t,
|
|
2020
2618
|
hasChanged: !0,
|
|
2021
2619
|
shouldCancelPending: !0,
|
|
@@ -2035,10 +2633,10 @@ var _t = class extends T {
|
|
|
2035
2633
|
}
|
|
2036
2634
|
allowConductivity(e, t, n, i, s) {
|
|
2037
2635
|
if (i === s) return !0;
|
|
2038
|
-
const
|
|
2039
|
-
if (!
|
|
2040
|
-
const
|
|
2041
|
-
return
|
|
2636
|
+
const r = e.getPinLabel(i), a = e.getPinLabel(s);
|
|
2637
|
+
if (!r || !a) return !1;
|
|
2638
|
+
const o = [r, a];
|
|
2639
|
+
return o.includes("vcc") && o.includes("output") ? t.state === "high" || t.state === "falling" : o.includes("gnd") && o.includes("output") ? t.state === "low" || t.state === "rising" : !1;
|
|
2042
2640
|
}
|
|
2043
2641
|
onEventFiring(e, t, n) {
|
|
2044
2642
|
let i = !1;
|
|
@@ -2049,197 +2647,437 @@ var _t = class extends T {
|
|
|
2049
2647
|
scheduledEvents: []
|
|
2050
2648
|
};
|
|
2051
2649
|
}
|
|
2052
|
-
},
|
|
2650
|
+
}, ee = class extends m {
|
|
2053
2651
|
constructor() {
|
|
2054
2652
|
super(u.Inverter);
|
|
2055
2653
|
}
|
|
2056
2654
|
createInitialState(e) {
|
|
2057
2655
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for InverterBehavior: ${e.type}`);
|
|
2058
2656
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2059
|
-
return new
|
|
2657
|
+
return new Dt(e.id, t);
|
|
2060
2658
|
}
|
|
2061
2659
|
onPinsChange(e, t, n, i) {
|
|
2062
2660
|
const s = this.getPinStates(e, n);
|
|
2063
2661
|
t.pinStates = s;
|
|
2064
|
-
const
|
|
2065
|
-
if (o) return o;
|
|
2066
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2662
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2067
2663
|
if (r) return r;
|
|
2068
|
-
const a =
|
|
2664
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2665
|
+
if (a) return a;
|
|
2666
|
+
const o = s.get("input").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2069
2667
|
return this.getBehavior(e, t, c, i);
|
|
2070
2668
|
}
|
|
2071
|
-
},
|
|
2669
|
+
}, ie = class extends m {
|
|
2072
2670
|
constructor() {
|
|
2073
2671
|
super(u.NandGate);
|
|
2074
2672
|
}
|
|
2075
2673
|
createInitialState(e) {
|
|
2076
2674
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for NandGateBehavior: ${e.type}`);
|
|
2077
2675
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2078
|
-
return new
|
|
2676
|
+
return new Mt(e.id, t);
|
|
2079
2677
|
}
|
|
2080
2678
|
onPinsChange(e, t, n, i) {
|
|
2081
2679
|
const s = this.getPinStates(e, n);
|
|
2082
2680
|
t.pinStates = s;
|
|
2083
|
-
const
|
|
2084
|
-
if (o) return o;
|
|
2085
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2681
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2086
2682
|
if (r) return r;
|
|
2087
|
-
const a =
|
|
2683
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2684
|
+
if (a) return a;
|
|
2685
|
+
const o = s.get("input1").hasVoltage && s.get("input2").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2088
2686
|
return this.getBehavior(e, t, c, i);
|
|
2089
2687
|
}
|
|
2090
|
-
},
|
|
2688
|
+
}, ne = class extends m {
|
|
2091
2689
|
constructor() {
|
|
2092
2690
|
super(u.Nand4Gate);
|
|
2093
2691
|
}
|
|
2094
2692
|
createInitialState(e) {
|
|
2095
2693
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for Nand4GateBehavior: ${e.type}`);
|
|
2096
2694
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2097
|
-
return new
|
|
2695
|
+
return new Lt(e.id, t);
|
|
2098
2696
|
}
|
|
2099
2697
|
onPinsChange(e, t, n, i) {
|
|
2100
2698
|
const s = this.getPinStates(e, n);
|
|
2101
2699
|
t.pinStates = s;
|
|
2102
|
-
const
|
|
2103
|
-
if (o) return o;
|
|
2104
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2700
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2105
2701
|
if (r) return r;
|
|
2106
|
-
const a =
|
|
2702
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2703
|
+
if (a) return a;
|
|
2704
|
+
const o = s.get("input1").hasVoltage && s.get("input2").hasVoltage && s.get("input3").hasVoltage && s.get("input4").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2107
2705
|
return this.getBehavior(e, t, c, i);
|
|
2108
2706
|
}
|
|
2109
|
-
},
|
|
2707
|
+
}, se = class extends m {
|
|
2110
2708
|
constructor() {
|
|
2111
2709
|
super(u.Nand8Gate);
|
|
2112
2710
|
}
|
|
2113
2711
|
createInitialState(e) {
|
|
2114
2712
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for Nand8GateBehavior: ${e.type}`);
|
|
2115
2713
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2116
|
-
return new
|
|
2714
|
+
return new kt(e.id, t);
|
|
2117
2715
|
}
|
|
2118
2716
|
onPinsChange(e, t, n, i) {
|
|
2119
2717
|
const s = this.getPinStates(e, n);
|
|
2120
2718
|
t.pinStates = s;
|
|
2121
|
-
const
|
|
2122
|
-
if (o) return o;
|
|
2123
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2719
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2124
2720
|
if (r) return r;
|
|
2125
|
-
const a =
|
|
2721
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2722
|
+
if (a) return a;
|
|
2723
|
+
const o = s.get("input1").hasVoltage && s.get("input2").hasVoltage && s.get("input3").hasVoltage && s.get("input4").hasVoltage && s.get("input5").hasVoltage && s.get("input6").hasVoltage && s.get("input7").hasVoltage && s.get("input8").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2126
2724
|
return this.getBehavior(e, t, c, i);
|
|
2127
2725
|
}
|
|
2128
|
-
},
|
|
2726
|
+
}, re = class extends m {
|
|
2129
2727
|
constructor() {
|
|
2130
2728
|
super(u.NorGate);
|
|
2131
2729
|
}
|
|
2132
2730
|
createInitialState(e) {
|
|
2133
2731
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for NorGateBehavior: ${e.type}`);
|
|
2134
2732
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2135
|
-
return new
|
|
2733
|
+
return new Gt(e.id, t);
|
|
2136
2734
|
}
|
|
2137
2735
|
onPinsChange(e, t, n, i) {
|
|
2138
2736
|
const s = this.getPinStates(e, n);
|
|
2139
2737
|
t.pinStates = s;
|
|
2140
|
-
const
|
|
2141
|
-
if (o) return o;
|
|
2142
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2738
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2143
2739
|
if (r) return r;
|
|
2144
|
-
const a =
|
|
2740
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2741
|
+
if (a) return a;
|
|
2742
|
+
const o = s.get("input1").hasVoltage || s.get("input2").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2145
2743
|
return this.getBehavior(e, t, c, i);
|
|
2146
2744
|
}
|
|
2147
|
-
},
|
|
2745
|
+
}, ae = class extends m {
|
|
2148
2746
|
constructor() {
|
|
2149
2747
|
super(u.Nor4Gate);
|
|
2150
2748
|
}
|
|
2151
2749
|
createInitialState(e) {
|
|
2152
2750
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for Nor4GateBehavior: ${e.type}`);
|
|
2153
2751
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2154
|
-
return new
|
|
2752
|
+
return new _t(e.id, t);
|
|
2155
2753
|
}
|
|
2156
2754
|
onPinsChange(e, t, n, i) {
|
|
2157
2755
|
const s = this.getPinStates(e, n);
|
|
2158
2756
|
t.pinStates = s;
|
|
2159
|
-
const
|
|
2160
|
-
if (o) return o;
|
|
2161
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2757
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2162
2758
|
if (r) return r;
|
|
2163
|
-
const a =
|
|
2759
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2760
|
+
if (a) return a;
|
|
2761
|
+
const o = s.get("input1").hasVoltage || s.get("input2").hasVoltage || s.get("input3").hasVoltage || s.get("input4").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2164
2762
|
return this.getBehavior(e, t, c, i);
|
|
2165
2763
|
}
|
|
2166
|
-
},
|
|
2764
|
+
}, oe = class extends m {
|
|
2167
2765
|
constructor() {
|
|
2168
2766
|
super(u.Nor8Gate);
|
|
2169
2767
|
}
|
|
2170
2768
|
createInitialState(e) {
|
|
2171
2769
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for Nor8GateBehavior: ${e.type}`);
|
|
2172
2770
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2173
|
-
return new
|
|
2771
|
+
return new Vt(e.id, t);
|
|
2174
2772
|
}
|
|
2175
2773
|
onPinsChange(e, t, n, i) {
|
|
2176
2774
|
const s = this.getPinStates(e, n);
|
|
2177
2775
|
t.pinStates = s;
|
|
2178
|
-
const
|
|
2179
|
-
if (o) return o;
|
|
2180
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2776
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2181
2777
|
if (r) return r;
|
|
2182
|
-
const a =
|
|
2778
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2779
|
+
if (a) return a;
|
|
2780
|
+
const o = s.get("input1").hasVoltage || s.get("input2").hasVoltage || s.get("input3").hasVoltage || s.get("input4").hasVoltage || s.get("input5").hasVoltage || s.get("input6").hasVoltage || s.get("input7").hasVoltage || s.get("input8").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2183
2781
|
return this.getBehavior(e, t, c, i);
|
|
2184
2782
|
}
|
|
2185
|
-
},
|
|
2783
|
+
}, ce = class extends m {
|
|
2186
2784
|
constructor() {
|
|
2187
2785
|
super(u.XorGate);
|
|
2188
2786
|
}
|
|
2189
2787
|
createInitialState(e) {
|
|
2190
2788
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for XorGateBehavior: ${e.type}`);
|
|
2191
2789
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2192
|
-
return new
|
|
2790
|
+
return new $t(e.id, t);
|
|
2193
2791
|
}
|
|
2194
2792
|
onPinsChange(e, t, n, i) {
|
|
2195
2793
|
const s = this.getPinStates(e, n);
|
|
2196
2794
|
t.pinStates = s;
|
|
2197
|
-
const
|
|
2198
|
-
if (o) return o;
|
|
2199
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2795
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2200
2796
|
if (r) return r;
|
|
2201
|
-
const a =
|
|
2797
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2798
|
+
if (a) return a;
|
|
2799
|
+
const o = s.get("input1").hasVoltage !== s.get("input2").hasVoltage, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2202
2800
|
return this.getBehavior(e, t, c, i);
|
|
2203
2801
|
}
|
|
2204
|
-
},
|
|
2802
|
+
}, ue = class extends m {
|
|
2205
2803
|
constructor() {
|
|
2206
2804
|
super(u.Xor4Gate);
|
|
2207
2805
|
}
|
|
2208
2806
|
createInitialState(e) {
|
|
2209
2807
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for Xor4GateBehavior: ${e.type}`);
|
|
2210
2808
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2211
|
-
return new
|
|
2809
|
+
return new Rt(e.id, t);
|
|
2212
2810
|
}
|
|
2213
2811
|
onPinsChange(e, t, n, i) {
|
|
2214
2812
|
const s = this.getPinStates(e, n);
|
|
2215
2813
|
t.pinStates = s;
|
|
2216
|
-
const
|
|
2217
|
-
if (o) return o;
|
|
2218
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2814
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2219
2815
|
if (r) return r;
|
|
2220
|
-
const a =
|
|
2816
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2817
|
+
if (a) return a;
|
|
2818
|
+
const o = ((s.get("input1").hasVoltage ? 1 : 0) + (s.get("input2").hasVoltage ? 1 : 0) + (s.get("input3").hasVoltage ? 1 : 0) + (s.get("input4").hasVoltage ? 1 : 0)) % 2 === 1, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2221
2819
|
return this.getBehavior(e, t, c, i);
|
|
2222
2820
|
}
|
|
2223
|
-
},
|
|
2821
|
+
}, le = class extends m {
|
|
2224
2822
|
constructor() {
|
|
2225
2823
|
super(u.Xor8Gate);
|
|
2226
2824
|
}
|
|
2227
2825
|
createInitialState(e) {
|
|
2228
2826
|
if (e.type !== this._componentType) throw new Error(`Invalid component type for Xor8GateBehavior: ${e.type}`);
|
|
2229
2827
|
const t = e.config.get("activationLogic") === "negative" ? "high" : "low";
|
|
2230
|
-
return new
|
|
2828
|
+
return new Wt(e.id, t);
|
|
2231
2829
|
}
|
|
2232
2830
|
onPinsChange(e, t, n, i) {
|
|
2233
2831
|
const s = this.getPinStates(e, n);
|
|
2234
2832
|
t.pinStates = s;
|
|
2235
|
-
const
|
|
2236
|
-
if (o) return o;
|
|
2237
|
-
const r = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2833
|
+
const r = this.vccGuardBehavior(t, s, i);
|
|
2238
2834
|
if (r) return r;
|
|
2239
|
-
const a =
|
|
2835
|
+
const a = this.nonLogicInputGuardBehavior(t, s, i);
|
|
2836
|
+
if (a) return a;
|
|
2837
|
+
const o = ((s.get("input1").hasVoltage ? 1 : 0) + (s.get("input2").hasVoltage ? 1 : 0) + (s.get("input3").hasVoltage ? 1 : 0) + (s.get("input4").hasVoltage ? 1 : 0) + (s.get("input5").hasVoltage ? 1 : 0) + (s.get("input6").hasVoltage ? 1 : 0) + (s.get("input7").hasVoltage ? 1 : 0) + (s.get("input8").hasVoltage ? 1 : 0)) % 2 === 1, c = e.config.get("activationLogic") === "negative" ? !o : o;
|
|
2240
2838
|
return this.getBehavior(e, t, c, i);
|
|
2241
2839
|
}
|
|
2242
|
-
},
|
|
2840
|
+
}, B = class extends C {
|
|
2841
|
+
onPinsChange(e, t, n, i) {
|
|
2842
|
+
const s = this.getPinStates(e, n);
|
|
2843
|
+
t.pinStates = s;
|
|
2844
|
+
const r = t, a = this.vccGuardBehavior(r, s, i);
|
|
2845
|
+
if (a) return a;
|
|
2846
|
+
const o = this.nonLogicInputGuardBehavior(r, s, i);
|
|
2847
|
+
if (o) return o;
|
|
2848
|
+
const c = this.computeTargetStableState(s);
|
|
2849
|
+
return this.scheduleTransition(e, r, c, i);
|
|
2850
|
+
}
|
|
2851
|
+
onEventFiring(e, t, n) {
|
|
2852
|
+
if (!n.type.startsWith("to")) return this.noChange(t);
|
|
2853
|
+
const i = n.type.slice(2);
|
|
2854
|
+
return t.state === i ? this.noChange(t) : (t.setState(i, n.readyAtTick), t.parameters.delete("prevState"), {
|
|
2855
|
+
componentState: t,
|
|
2856
|
+
hasChanged: !0,
|
|
2857
|
+
shouldCancelPending: !1,
|
|
2858
|
+
scheduledEvents: []
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2861
|
+
allowConductivity(e, t, n, i, s) {
|
|
2862
|
+
if (i === s) return !0;
|
|
2863
|
+
const r = t.effectiveState;
|
|
2864
|
+
if (r === "indeterminate") return !1;
|
|
2865
|
+
const a = e.getPinMetadata(i), o = e.getPinMetadata(s);
|
|
2866
|
+
if (!a || !o) return !1;
|
|
2867
|
+
let c, p = 0;
|
|
2868
|
+
if (a.subtype === "logicOutput" && (p++, c = a), o.subtype === "logicOutput" && (p++, c = o), p !== 1 || !c?.logicPinData) return !1;
|
|
2869
|
+
let l = 0;
|
|
2870
|
+
if (l += a.subtype === "vcc" ? 1 : a.subtype === "gnd" ? -1 : 0, l += o.subtype === "vcc" ? 1 : o.subtype === "gnd" ? -1 : 0, l !== 1 && l !== -1) return !1;
|
|
2871
|
+
const d = t;
|
|
2872
|
+
return (parseInt(r, 16) >> (c.logicPinData.interface === "sum" ? c.logicPinData.index * 2 : d.outputCount - 1) & 1) === 1 ? l === 1 : l === -1;
|
|
2873
|
+
}
|
|
2874
|
+
vccGuardBehavior(e, t, n) {
|
|
2875
|
+
if (t.get("vcc").hasVoltage) return null;
|
|
2876
|
+
const i = e.allLowState;
|
|
2877
|
+
return e.state === i ? {
|
|
2878
|
+
componentState: e,
|
|
2879
|
+
hasChanged: !1,
|
|
2880
|
+
shouldCancelPending: !1,
|
|
2881
|
+
scheduledEvents: []
|
|
2882
|
+
} : (e.setState(i, n), e.parameters.delete("prevState"), {
|
|
2883
|
+
componentState: e,
|
|
2884
|
+
hasChanged: !0,
|
|
2885
|
+
shouldCancelPending: !0,
|
|
2886
|
+
scheduledEvents: []
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
nonLogicInputGuardBehavior(e, t, n) {
|
|
2890
|
+
const i = this.typeMetadata.pins;
|
|
2891
|
+
let s = !1;
|
|
2892
|
+
for (const [r, a] of t) {
|
|
2893
|
+
const o = i.get(r);
|
|
2894
|
+
if (!(!o || o.subtype !== "logicInput") && (a.hasVoltage && a.hasCurrent || !a.hasVoltage && !a.hasCurrent)) {
|
|
2895
|
+
s = !0;
|
|
2896
|
+
break;
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
return s ? e.state === "indeterminate" ? {
|
|
2900
|
+
componentState: e,
|
|
2901
|
+
hasChanged: !1,
|
|
2902
|
+
shouldCancelPending: !1,
|
|
2903
|
+
scheduledEvents: []
|
|
2904
|
+
} : (e.setState("indeterminate", n), e.parameters.delete("prevState"), {
|
|
2905
|
+
componentState: e,
|
|
2906
|
+
hasChanged: !0,
|
|
2907
|
+
shouldCancelPending: !0,
|
|
2908
|
+
scheduledEvents: []
|
|
2909
|
+
}) : null;
|
|
2910
|
+
}
|
|
2911
|
+
scheduleTransition(e, t, n, i) {
|
|
2912
|
+
const s = `to${n}`;
|
|
2913
|
+
if (t.state === n || t.state === s) return this.noChange(t);
|
|
2914
|
+
const r = x(e.config), a = t.expirationTick < 1 ? r : Math.max(i - t.startTick, 1), o = t.effectiveState, c = o === "indeterminate" ? t.allLowState : o;
|
|
2915
|
+
return t.setState(s, i), t.setNextState(n, i + a), t.parameters.set("prevState", c), {
|
|
2916
|
+
componentState: t,
|
|
2917
|
+
hasChanged: !0,
|
|
2918
|
+
shouldCancelPending: !0,
|
|
2919
|
+
scheduledEvents: [{
|
|
2920
|
+
targetId: e.id,
|
|
2921
|
+
scheduledAtTick: t.startTick,
|
|
2922
|
+
readyAtTick: t.expirationTick,
|
|
2923
|
+
type: s,
|
|
2924
|
+
parameters: void 0
|
|
2925
|
+
}]
|
|
2926
|
+
};
|
|
2927
|
+
}
|
|
2928
|
+
noChange(e) {
|
|
2929
|
+
return {
|
|
2930
|
+
componentState: e,
|
|
2931
|
+
hasChanged: !1,
|
|
2932
|
+
shouldCancelPending: !1,
|
|
2933
|
+
scheduledEvents: []
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
}, pe = class extends B {
|
|
2937
|
+
constructor() {
|
|
2938
|
+
super(u.HalfAdder);
|
|
2939
|
+
}
|
|
2940
|
+
createInitialState(e) {
|
|
2941
|
+
if (e.type !== this._componentType) throw new Error(`Invalid component type for HalfAdderBehavior: ${e.type}`);
|
|
2942
|
+
return new zt(e.id, "0");
|
|
2943
|
+
}
|
|
2944
|
+
computeTargetStableState(e) {
|
|
2945
|
+
const t = e.get("inputA").hasVoltage, n = e.get("inputB").hasVoltage;
|
|
2946
|
+
return ((t !== n ? 1 : 0) | (t && n ? 2 : 0)).toString(16);
|
|
2947
|
+
}
|
|
2948
|
+
}, de = class extends B {
|
|
2949
|
+
constructor() {
|
|
2950
|
+
super(u.Adder);
|
|
2951
|
+
}
|
|
2952
|
+
createInitialState(e) {
|
|
2953
|
+
if (e.type !== this._componentType) throw new Error(`Invalid component type for AdderBehavior: ${e.type}`);
|
|
2954
|
+
return new Ht(e.id, "0");
|
|
2955
|
+
}
|
|
2956
|
+
computeTargetStableState(e) {
|
|
2957
|
+
const t = e.get("inputA").hasVoltage, n = e.get("inputB").hasVoltage, i = e.get("carryIn").hasVoltage, s = (t ? 1 : 0) + (n ? 1 : 0) + (i ? 1 : 0);
|
|
2958
|
+
return ((s % 2 === 1 ? 1 : 0) | (s >= 2 ? 2 : 0)).toString(16);
|
|
2959
|
+
}
|
|
2960
|
+
}, N = 8, he = class extends B {
|
|
2961
|
+
constructor() {
|
|
2962
|
+
super(u.EightBitAdder);
|
|
2963
|
+
}
|
|
2964
|
+
createInitialState(e) {
|
|
2965
|
+
if (e.type !== this._componentType) throw new Error(`Invalid component type for EightBitAdderBehavior: ${e.type}`);
|
|
2966
|
+
return new Ft(e.id, "0000");
|
|
2967
|
+
}
|
|
2968
|
+
onPinsChange(e, t, n, i) {
|
|
2969
|
+
const s = this.getPinStates(e, n);
|
|
2970
|
+
t.pinStates = s;
|
|
2971
|
+
const r = t, a = this.vccGuardBehavior(r, s, i);
|
|
2972
|
+
if (a) return a;
|
|
2973
|
+
const o = this.nonLogicInputGuardBehavior(r, s, i);
|
|
2974
|
+
if (o) return o;
|
|
2975
|
+
if (i === 0) {
|
|
2976
|
+
const h = this.computeTargetStableState(s);
|
|
2977
|
+
return this.scheduleTransition(e, r, h, i);
|
|
2978
|
+
}
|
|
2979
|
+
const c = r.effectiveState, p = c === "indeterminate" ? 0 : parseInt(c, 16), l = s.get("carryIn").hasVoltage;
|
|
2980
|
+
let d = 0;
|
|
2981
|
+
for (let h = 0; h < N; h++) {
|
|
2982
|
+
const S = s.get(`inputA-${h}`).hasVoltage, ut = s.get(`inputB-${h}`).hasVoltage, { sum: lt, carry: pt } = k(S, ut, h === 0 ? l : (p >> 2 * (h - 1) + 1 & 1) === 1);
|
|
2983
|
+
d = G(d, h, lt, pt);
|
|
2984
|
+
}
|
|
2985
|
+
const y = _(d);
|
|
2986
|
+
if (y === c) return this.noChange(t);
|
|
2987
|
+
const f = x(e.config), v = c === "indeterminate" ? r.allLowState : c;
|
|
2988
|
+
return r.setState(`to${y}`, i), r.setNextState(y, i + f), r.parameters.set("prevState", v), {
|
|
2989
|
+
componentState: r,
|
|
2990
|
+
hasChanged: !0,
|
|
2991
|
+
shouldCancelPending: !0,
|
|
2992
|
+
scheduledEvents: [{
|
|
2993
|
+
targetId: e.id,
|
|
2994
|
+
scheduledAtTick: i,
|
|
2995
|
+
readyAtTick: i + f,
|
|
2996
|
+
type: `to${y}`,
|
|
2997
|
+
parameters: /* @__PURE__ */ new Map([["nextStage", "1"]])
|
|
2998
|
+
}]
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
onEventFiring(e, t, n) {
|
|
3002
|
+
if (!n.type.startsWith("to")) return this.noChange(t);
|
|
3003
|
+
const i = n.type.slice(2), s = parseInt(n.parameters?.get("nextStage") ?? `${N}`), r = t;
|
|
3004
|
+
if (r.state === i) return this.noChange(r);
|
|
3005
|
+
if (r.setState(i, n.readyAtTick), r.parameters.delete("prevState"), s >= N) return {
|
|
3006
|
+
componentState: r,
|
|
3007
|
+
hasChanged: !0,
|
|
3008
|
+
shouldCancelPending: !1,
|
|
3009
|
+
scheduledEvents: []
|
|
3010
|
+
};
|
|
3011
|
+
const a = parseInt(i, 16), o = (a >> 2 * (s - 1) + 1 & 1) === 1, c = r.pinStates.get(`inputA-${s}`).hasVoltage, p = r.pinStates.get(`inputB-${s}`).hasVoltage, { sum: l, carry: d } = k(c, p, o), y = (a >> 2 * s & 1) === 1, f = (a >> 2 * s + 1 & 1) === 1;
|
|
3012
|
+
if (l === y && d === f) return {
|
|
3013
|
+
componentState: r,
|
|
3014
|
+
hasChanged: !0,
|
|
3015
|
+
shouldCancelPending: !1,
|
|
3016
|
+
scheduledEvents: []
|
|
3017
|
+
};
|
|
3018
|
+
const v = _(G(a, s, l, d)), h = x(e.config);
|
|
3019
|
+
return r.setState(`to${v}`, n.readyAtTick), r.setNextState(v, n.readyAtTick + h), r.parameters.set("prevState", i), {
|
|
3020
|
+
componentState: r,
|
|
3021
|
+
hasChanged: !0,
|
|
3022
|
+
shouldCancelPending: !1,
|
|
3023
|
+
scheduledEvents: [{
|
|
3024
|
+
targetId: e.id,
|
|
3025
|
+
scheduledAtTick: n.readyAtTick,
|
|
3026
|
+
readyAtTick: n.readyAtTick + h,
|
|
3027
|
+
type: `to${v}`,
|
|
3028
|
+
parameters: /* @__PURE__ */ new Map([["nextStage", `${s + 1}`]])
|
|
3029
|
+
}]
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
computeTargetStableState(e) {
|
|
3033
|
+
let t = e.get("carryIn").hasVoltage, n = 0;
|
|
3034
|
+
for (let i = 0; i < N; i++) {
|
|
3035
|
+
const s = e.get(`inputA-${i}`).hasVoltage, r = e.get(`inputB-${i}`).hasVoltage, a = k(s, r, t);
|
|
3036
|
+
n = G(n, i, a.sum, a.carry), t = a.carry;
|
|
3037
|
+
}
|
|
3038
|
+
return _(n);
|
|
3039
|
+
}
|
|
3040
|
+
};
|
|
3041
|
+
function k(e, t, n) {
|
|
3042
|
+
return {
|
|
3043
|
+
sum: e !== t !== n,
|
|
3044
|
+
carry: e && t || e && n || t && n
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
3047
|
+
function G(e, t, n, i) {
|
|
3048
|
+
const s = 2 * t, r = s + 1;
|
|
3049
|
+
let a = e;
|
|
3050
|
+
return a = a & ~(1 << s) | (n ? 1 : 0) << s, a = a & ~(1 << r) | (i ? 1 : 0) << r, a;
|
|
3051
|
+
}
|
|
3052
|
+
function _(e) {
|
|
3053
|
+
return e.toString(16).padStart(4, "0");
|
|
3054
|
+
}
|
|
3055
|
+
var U = 8, ge = class extends B {
|
|
3056
|
+
constructor() {
|
|
3057
|
+
super(u.EightBitOnesComplement);
|
|
3058
|
+
}
|
|
3059
|
+
createInitialState(e) {
|
|
3060
|
+
if (e.type !== this._componentType) throw new Error(`Invalid component type for EightBitOnesComplementBehavior: ${e.type}`);
|
|
3061
|
+
return new Jt(e.id, "000");
|
|
3062
|
+
}
|
|
3063
|
+
allowConductivity(e, t, n, i, s) {
|
|
3064
|
+
if (i === s) return !0;
|
|
3065
|
+
const r = t.effectiveState;
|
|
3066
|
+
if (r === "indeterminate") return !1;
|
|
3067
|
+
const a = e.getPinMetadata(i), o = e.getPinMetadata(s);
|
|
3068
|
+
if (!a || !o) return !1;
|
|
3069
|
+
let c, p = 0;
|
|
3070
|
+
if (a.subtype === "logicOutput" && (p++, c = a), o.subtype === "logicOutput" && (p++, c = o), p !== 1 || !c?.logicPinData) return !1;
|
|
3071
|
+
let l = 0;
|
|
3072
|
+
return l += a.subtype === "vcc" ? 1 : a.subtype === "gnd" ? -1 : 0, l += o.subtype === "vcc" ? 1 : o.subtype === "gnd" ? -1 : 0, l !== 1 && l !== -1 ? !1 : (parseInt(r, 16) >> c.logicPinData.index & 1) === 1 ? l === 1 : l === -1;
|
|
3073
|
+
}
|
|
3074
|
+
computeTargetStableState(e) {
|
|
3075
|
+
const t = e.get("invert").hasVoltage;
|
|
3076
|
+
let n = 0;
|
|
3077
|
+
for (let i = 0; i < U; i++) e.get(`input-${i}`).hasVoltage !== t && (n |= 1 << i);
|
|
3078
|
+
return t && (n |= 1 << U), n.toString(16).padStart(3, "0");
|
|
3079
|
+
}
|
|
3080
|
+
}, fe = class {
|
|
2243
3081
|
heap;
|
|
2244
3082
|
constructor() {
|
|
2245
3083
|
this.heap = [];
|
|
@@ -2301,7 +3139,7 @@ var _t = class extends T {
|
|
|
2301
3139
|
const e = this.heap[0], t = this.heap.pop();
|
|
2302
3140
|
return this.heap.length > 0 && t && (this.heap[0] = t, this.bubbleDown(0)), e;
|
|
2303
3141
|
}
|
|
2304
|
-
},
|
|
3142
|
+
}, ye = class {
|
|
2305
3143
|
dirtyComponents;
|
|
2306
3144
|
dirtyWires;
|
|
2307
3145
|
dirtyEnodes;
|
|
@@ -2349,7 +3187,7 @@ var _t = class extends T {
|
|
|
2349
3187
|
getDirtyEnodeCount() {
|
|
2350
3188
|
return this.dirtyEnodes.size;
|
|
2351
3189
|
}
|
|
2352
|
-
},
|
|
3190
|
+
}, ve = class {
|
|
2353
3191
|
currentState;
|
|
2354
3192
|
history;
|
|
2355
3193
|
historyEnabled;
|
|
@@ -2357,7 +3195,7 @@ var _t = class extends T {
|
|
|
2357
3195
|
historyWriteIndex;
|
|
2358
3196
|
constructor(e = !1, t = 1e3) {
|
|
2359
3197
|
if (t < 1) throw new RangeError(`historyLimit must be at least 1 (got ${t})`);
|
|
2360
|
-
this.historyEnabled = e, this.historyLimit = t, this.currentState = new
|
|
3198
|
+
this.historyEnabled = e, this.historyLimit = t, this.currentState = new J(0), this.history = [], this.historyWriteIndex = 0;
|
|
2361
3199
|
}
|
|
2362
3200
|
getCurrentState() {
|
|
2363
3201
|
return this.currentState;
|
|
@@ -2388,7 +3226,7 @@ var _t = class extends T {
|
|
|
2388
3226
|
this.history = [], this.historyWriteIndex = 0;
|
|
2389
3227
|
}
|
|
2390
3228
|
reset() {
|
|
2391
|
-
this.currentState = new
|
|
3229
|
+
this.currentState = new J(0), this.clearHistory();
|
|
2392
3230
|
}
|
|
2393
3231
|
isHistoryEnabled() {
|
|
2394
3232
|
return this.historyEnabled;
|
|
@@ -2402,7 +3240,7 @@ var _t = class extends T {
|
|
|
2402
3240
|
saveToHistory(e) {
|
|
2403
3241
|
this.history.length < this.historyLimit ? this.history.push(e) : (this.history[this.historyWriteIndex] = e, this.historyWriteIndex = (this.historyWriteIndex + 1) % this.historyLimit);
|
|
2404
3242
|
}
|
|
2405
|
-
},
|
|
3243
|
+
}, Pe = class {
|
|
2406
3244
|
circuit;
|
|
2407
3245
|
stateManager;
|
|
2408
3246
|
eventQueue;
|
|
@@ -2410,7 +3248,7 @@ var _t = class extends T {
|
|
|
2410
3248
|
dirtyTracker;
|
|
2411
3249
|
behaviorRegistry;
|
|
2412
3250
|
constructor(e, t, n = {}) {
|
|
2413
|
-
this.circuit = e, this.behaviorRegistry = t, this.stateManager = new
|
|
3251
|
+
this.circuit = e, this.behaviorRegistry = t, this.stateManager = new ve(n.enableHistory ?? !1, n.historyLimit ?? 1e3), this.eventQueue = new fe(), this.commands = /* @__PURE__ */ new Map(), this.dirtyTracker = new ye();
|
|
2414
3252
|
try {
|
|
2415
3253
|
this.initializeState();
|
|
2416
3254
|
} catch (i) {
|
|
@@ -2460,10 +3298,10 @@ var _t = class extends T {
|
|
|
2460
3298
|
processCommands() {
|
|
2461
3299
|
const e = this.stateManager.getCurrentState(), t = [], n = /* @__PURE__ */ new Set(), i = [];
|
|
2462
3300
|
for (const s of this.commands.values()) {
|
|
2463
|
-
const
|
|
2464
|
-
|
|
2465
|
-
for (const
|
|
2466
|
-
t.push(
|
|
3301
|
+
const r = this.circuit.getComponent(s.targetId), a = this.behaviorRegistry.get(r.type).onUserCommand(r, e.componentStates.get(r.id), s);
|
|
3302
|
+
a.shouldCancelPending && n.add(r.id);
|
|
3303
|
+
for (const o of a.scheduledEvents) i.push(o);
|
|
3304
|
+
t.push(a), a.hasChanged && this.dirtyTracker.markComponentDirty(r.id);
|
|
2467
3305
|
}
|
|
2468
3306
|
return this.eventQueue.scheduleMany(i, n), this.commands.clear(), t;
|
|
2469
3307
|
}
|
|
@@ -2477,10 +3315,10 @@ var _t = class extends T {
|
|
|
2477
3315
|
const e = this.stateManager.getCurrentState();
|
|
2478
3316
|
for (const c of this.circuit.getAllComponents()) {
|
|
2479
3317
|
if (c.pins.length < 1) continue;
|
|
2480
|
-
const
|
|
2481
|
-
if (!
|
|
2482
|
-
const
|
|
2483
|
-
e.componentStates.set(c.id,
|
|
3318
|
+
const p = this.behaviorRegistry.get(c.type);
|
|
3319
|
+
if (!p) continue;
|
|
3320
|
+
const l = p.createInitialState(c);
|
|
3321
|
+
e.componentStates.set(c.id, l), this.dirtyTracker.markComponentDirty(c.id);
|
|
2484
3322
|
}
|
|
2485
3323
|
for (const c of this.circuit.getAllENodes()) e.nodeStates.set(c.id, {
|
|
2486
3324
|
hasVoltage: c.source === g.Voltage,
|
|
@@ -2494,113 +3332,115 @@ var _t = class extends T {
|
|
|
2494
3332
|
});
|
|
2495
3333
|
const t = this.circuit.getAllComponents(), n = /* @__PURE__ */ new Map();
|
|
2496
3334
|
for (const c of t) {
|
|
2497
|
-
const
|
|
2498
|
-
|
|
3335
|
+
const p = this.getInitializationOrder(c.config), l = n.get(p) ?? [];
|
|
3336
|
+
l.push(c), n.set(p, l);
|
|
2499
3337
|
}
|
|
2500
|
-
const i = Array.from(n.keys()).sort((c,
|
|
2501
|
-
for (const c of i) n.get(c).sort((
|
|
2502
|
-
let s = !0,
|
|
2503
|
-
const
|
|
2504
|
-
for (; s &&
|
|
2505
|
-
s = !1,
|
|
3338
|
+
const i = Array.from(n.keys()).sort((c, p) => c - p);
|
|
3339
|
+
for (const c of i) n.get(c).sort((p, l) => p.id.localeCompare(l.id));
|
|
3340
|
+
let s = !0, r = 0;
|
|
3341
|
+
const a = 100;
|
|
3342
|
+
for (; s && r < a; ) {
|
|
3343
|
+
s = !1, r++;
|
|
2506
3344
|
for (const c of i) {
|
|
2507
|
-
const
|
|
2508
|
-
for (const
|
|
2509
|
-
const
|
|
2510
|
-
if (!
|
|
2511
|
-
const
|
|
2512
|
-
if (!
|
|
3345
|
+
const p = n.get(c);
|
|
3346
|
+
for (const l of p) {
|
|
3347
|
+
const d = this.behaviorRegistry.get(l.type);
|
|
3348
|
+
if (!d) continue;
|
|
3349
|
+
const y = e.componentStates.get(l.id);
|
|
3350
|
+
if (!y) continue;
|
|
2513
3351
|
this.propagateConductivity();
|
|
2514
|
-
const f =
|
|
3352
|
+
const f = d.onStart(l, y);
|
|
2515
3353
|
if (f) {
|
|
2516
|
-
e.componentStates.set(
|
|
2517
|
-
for (const
|
|
3354
|
+
e.componentStates.set(l.id, f.componentState), f.shouldCancelPending && this.eventQueue.removeEventsForTarget(l.id);
|
|
3355
|
+
for (const h of f.scheduledEvents) this.eventQueue.schedule(h);
|
|
2518
3356
|
continue;
|
|
2519
3357
|
}
|
|
2520
|
-
const
|
|
2521
|
-
|
|
2522
|
-
for (const
|
|
2523
|
-
const
|
|
2524
|
-
|
|
3358
|
+
const v = d.onPinsChange(l, y, e.nodeStates, 0);
|
|
3359
|
+
v.hasChanged && (s = !0, e.componentStates.set(l.id, v.componentState));
|
|
3360
|
+
for (const h of v.scheduledEvents) {
|
|
3361
|
+
const S = d.onEventFiring(l, y, h);
|
|
3362
|
+
S.hasChanged && (s = !0, e.componentStates.set(l.id, S.componentState));
|
|
2525
3363
|
}
|
|
2526
3364
|
}
|
|
2527
3365
|
}
|
|
2528
3366
|
}
|
|
2529
|
-
const
|
|
2530
|
-
return this.dirtyTracker.setDirtyComponents(/* @__PURE__ */ new Set([...this.circuit.getAllComponents().map((c) => c.id)])), this.dirtyTracker.setDirtyEnodes(/* @__PURE__ */ new Set([...this.circuit.getAllENodes().map((c) => c.id)])), this.dirtyTracker.setDirtyWires(/* @__PURE__ */ new Set([...this.circuit.getAllWires().map((c) => c.id)])),
|
|
3367
|
+
const o = this.updateState(0);
|
|
3368
|
+
return this.dirtyTracker.setDirtyComponents(/* @__PURE__ */ new Set([...this.circuit.getAllComponents().map((c) => c.id)])), this.dirtyTracker.setDirtyEnodes(/* @__PURE__ */ new Set([...this.circuit.getAllENodes().map((c) => c.id)])), this.dirtyTracker.setDirtyWires(/* @__PURE__ */ new Set([...this.circuit.getAllWires().map((c) => c.id)])), o;
|
|
2531
3369
|
}
|
|
2532
3370
|
updateState(e) {
|
|
2533
|
-
const t = this.stateManager.getCurrentState(), { updatedNodes: n, updatedWires: i } = this.propagateConductivity(), s = this.circuit.getComponentsOfPins(n),
|
|
2534
|
-
let
|
|
2535
|
-
e === 0 && (
|
|
2536
|
-
const
|
|
2537
|
-
return
|
|
3371
|
+
const t = this.stateManager.getCurrentState(), { updatedNodes: n, updatedWires: i } = this.propagateConductivity(), s = this.circuit.getComponentsOfPins(n), r = [], a = /* @__PURE__ */ new Set();
|
|
3372
|
+
let o = Array.from(s);
|
|
3373
|
+
e === 0 && (o = o.sort((l, d) => {
|
|
3374
|
+
const y = this.circuit.getComponent(l), f = this.circuit.getComponent(d), v = this.getInitializationOrder(y.config), h = this.getInitializationOrder(f.config);
|
|
3375
|
+
return v !== h ? v - h : l.localeCompare(d);
|
|
2538
3376
|
}));
|
|
2539
|
-
const c = /* @__PURE__ */ new Set(),
|
|
2540
|
-
for (const
|
|
2541
|
-
const
|
|
2542
|
-
if (!
|
|
2543
|
-
const f =
|
|
2544
|
-
f.shouldCancelPending && c.add(
|
|
2545
|
-
for (const
|
|
3377
|
+
const c = /* @__PURE__ */ new Set(), p = [];
|
|
3378
|
+
for (const l of o) {
|
|
3379
|
+
const d = this.circuit.getComponent(l), y = this.behaviorRegistry.get(d.type);
|
|
3380
|
+
if (!y) continue;
|
|
3381
|
+
const f = y.onPinsChange(d, t.componentStates.get(l), t.nodeStates, e);
|
|
3382
|
+
f.shouldCancelPending && c.add(l), f.hasChanged && (a.add(l), r.push(f));
|
|
3383
|
+
for (const v of f.scheduledEvents) p.push(v);
|
|
2546
3384
|
}
|
|
2547
|
-
return this.eventQueue.scheduleMany(
|
|
3385
|
+
return this.eventQueue.scheduleMany(p, c), this.dirtyTracker.setDirtyComponents(a), this.dirtyTracker.setDirtyEnodes(n), this.dirtyTracker.setDirtyWires(i), {
|
|
2548
3386
|
startTick: this.getCurrentTick(),
|
|
2549
3387
|
endTick: this.getCurrentTick(),
|
|
2550
|
-
componentUpdateCount:
|
|
3388
|
+
componentUpdateCount: a.size,
|
|
2551
3389
|
nodeUpdateCount: n.size,
|
|
2552
3390
|
wireUpdateCount: i.size,
|
|
2553
3391
|
processedCommandCount: 0,
|
|
2554
|
-
scheduledEventCount:
|
|
3392
|
+
scheduledEventCount: p.length,
|
|
2555
3393
|
firedEventCount: 0
|
|
2556
3394
|
};
|
|
2557
3395
|
}
|
|
2558
3396
|
propagateConductivity() {
|
|
2559
|
-
const e = this.stateManager.getCurrentState(), t = (
|
|
2560
|
-
const
|
|
2561
|
-
for (const
|
|
2562
|
-
const
|
|
2563
|
-
|
|
3397
|
+
const e = this.stateManager.getCurrentState(), t = (a) => {
|
|
3398
|
+
const o = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), p = this.circuit.getAllENodes().filter((h) => h.source == a).map((h) => h.id), l = /* @__PURE__ */ new Set([...this.circuit.getAllENodes().filter((h) => !h.source).map((h) => h.id)]), d = /* @__PURE__ */ new Set([...this.circuit.getAllWires().map((h) => h.id)]), { nodes: y, wires: f } = this.computeReachability(a, p, e.componentStates), v = a == g.Voltage ? "hasVoltage" : "hasCurrent";
|
|
3399
|
+
for (const h of y) {
|
|
3400
|
+
const S = e.nodeStates.get(h);
|
|
3401
|
+
S && !S.locked && (S[v] || (S[v] = !0, o.add(h)), l.delete(h));
|
|
2564
3402
|
}
|
|
2565
|
-
for (const
|
|
2566
|
-
const
|
|
2567
|
-
|
|
3403
|
+
for (const h of l) {
|
|
3404
|
+
const S = e.nodeStates.get(h);
|
|
3405
|
+
S && !S.locked && S[v] && (S[v] = !1, o.add(h));
|
|
2568
3406
|
}
|
|
2569
|
-
for (const
|
|
2570
|
-
const
|
|
2571
|
-
|
|
3407
|
+
for (const h of f) {
|
|
3408
|
+
const S = e.wireStates.get(h);
|
|
3409
|
+
S && (S[v] || (S[v] = !0, c.add(h)), d.delete(h));
|
|
2572
3410
|
}
|
|
2573
|
-
for (const
|
|
2574
|
-
const
|
|
2575
|
-
|
|
3411
|
+
for (const h of d) {
|
|
3412
|
+
const S = e.wireStates.get(h);
|
|
3413
|
+
S && S[v] && (S[v] = !1, c.add(h));
|
|
2576
3414
|
}
|
|
2577
3415
|
return {
|
|
2578
|
-
updatedNodes:
|
|
3416
|
+
updatedNodes: o,
|
|
2579
3417
|
updatedWires: c
|
|
2580
3418
|
};
|
|
2581
|
-
}, { updatedNodes: n, updatedWires: i } = t(g.Voltage), { updatedNodes: s, updatedWires:
|
|
3419
|
+
}, { updatedNodes: n, updatedWires: i } = t(g.Voltage), { updatedNodes: s, updatedWires: r } = t(g.Current);
|
|
2582
3420
|
return {
|
|
2583
3421
|
updatedNodes: /* @__PURE__ */ new Set([...n, ...s]),
|
|
2584
|
-
updatedWires: /* @__PURE__ */ new Set([...i, ...
|
|
3422
|
+
updatedWires: /* @__PURE__ */ new Set([...i, ...r])
|
|
2585
3423
|
};
|
|
2586
3424
|
}
|
|
2587
3425
|
computeReachability(e, t, n) {
|
|
2588
|
-
const i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(),
|
|
2589
|
-
for (const
|
|
2590
|
-
|
|
2591
|
-
for (;
|
|
2592
|
-
const
|
|
2593
|
-
for (const c of this.circuit.getWiresByNode(
|
|
2594
|
-
const
|
|
2595
|
-
i.has(
|
|
3426
|
+
const i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), r = [];
|
|
3427
|
+
for (const a of t)
|
|
3428
|
+
r.push(a), i.add(a);
|
|
3429
|
+
for (; r.length > 0; ) {
|
|
3430
|
+
const a = r.shift();
|
|
3431
|
+
for (const c of this.circuit.getWiresByNode(a)) {
|
|
3432
|
+
const p = c.node1 === a ? c.node2 : c.node1;
|
|
3433
|
+
i.has(p) || (i.add(p), r.push(p)), s.has(c.id) || s.add(c.id);
|
|
2596
3434
|
}
|
|
2597
|
-
const
|
|
2598
|
-
if (
|
|
2599
|
-
const c = this.circuit.getComponent(
|
|
2600
|
-
if (!
|
|
2601
|
-
const
|
|
2602
|
-
|
|
2603
|
-
|
|
3435
|
+
const o = this.circuit.getENode(a);
|
|
3436
|
+
if (o.type === P.Pin) {
|
|
3437
|
+
const c = this.circuit.getComponent(o.component), p = this.behaviorRegistry.get(c.type);
|
|
3438
|
+
if (!p) continue;
|
|
3439
|
+
const l = c.getPinMetadata(a);
|
|
3440
|
+
if (l?.subtype === "logicInput" || l?.subtype === "logicOutput") continue;
|
|
3441
|
+
const d = n.get(c.id);
|
|
3442
|
+
for (const y of c.pins)
|
|
3443
|
+
y !== a && (i.has(y) || p.allowConductivity(c, d, e, a, y) && (i.add(y), r.push(y)));
|
|
2604
3444
|
}
|
|
2605
3445
|
}
|
|
2606
3446
|
return {
|
|
@@ -2609,99 +3449,112 @@ var _t = class extends T {
|
|
|
2609
3449
|
};
|
|
2610
3450
|
}
|
|
2611
3451
|
applyReadyEvents(e) {
|
|
2612
|
-
const t = this.stateManager.getCurrentState(), n = this.eventQueue.getReadyEvents(e), i = [], s = /* @__PURE__ */ new Set(),
|
|
2613
|
-
for (const
|
|
2614
|
-
const
|
|
3452
|
+
const t = this.stateManager.getCurrentState(), n = this.eventQueue.getReadyEvents(e), i = [], s = /* @__PURE__ */ new Set(), r = [];
|
|
3453
|
+
for (const a of n) {
|
|
3454
|
+
const o = this.circuit.getComponent(a.targetId), c = this.behaviorRegistry.get(o.type);
|
|
2615
3455
|
if (!c) continue;
|
|
2616
|
-
const
|
|
2617
|
-
|
|
2618
|
-
for (const
|
|
2619
|
-
i.push(
|
|
3456
|
+
const p = t.componentStates.get(o.id), l = c.onEventFiring(o, p, a);
|
|
3457
|
+
l.shouldCancelPending && s.add(o.id);
|
|
3458
|
+
for (const d of l.scheduledEvents) r.push(d);
|
|
3459
|
+
i.push(l);
|
|
2620
3460
|
}
|
|
2621
|
-
return this.eventQueue.scheduleMany(
|
|
3461
|
+
return this.eventQueue.scheduleMany(r, s), i;
|
|
2622
3462
|
}
|
|
2623
3463
|
};
|
|
2624
|
-
function
|
|
2625
|
-
return e.register(new
|
|
3464
|
+
function xe(e) {
|
|
3465
|
+
return e.register(new Ut()).register(new Xt()).register(new Qt()).register(new Kt()).register(new Yt()).register(new Zt()).register(new jt()).register(new te()), e;
|
|
3466
|
+
}
|
|
3467
|
+
function Ie(e) {
|
|
3468
|
+
return e.register(new ee()).register(new ie()).register(new ne()).register(new se()).register(new re()).register(new ae()).register(new oe()).register(new ce()).register(new ue()).register(new le()), e;
|
|
2626
3469
|
}
|
|
2627
|
-
function
|
|
2628
|
-
return e.register(new
|
|
3470
|
+
function Te(e) {
|
|
3471
|
+
return e.register(new pe()).register(new de()).register(new he()).register(new ge()), e;
|
|
2629
3472
|
}
|
|
2630
3473
|
export {
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
O as
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
3474
|
+
Tt as $,
|
|
3475
|
+
x as A,
|
|
3476
|
+
Se as At,
|
|
3477
|
+
Vt as B,
|
|
3478
|
+
jt as C,
|
|
3479
|
+
yt as Ct,
|
|
3480
|
+
Qt as D,
|
|
3481
|
+
Q as Dt,
|
|
3482
|
+
Kt as E,
|
|
3483
|
+
M as Et,
|
|
3484
|
+
zt as F,
|
|
3485
|
+
Mt as G,
|
|
3486
|
+
Gt as H,
|
|
3487
|
+
A as I,
|
|
3488
|
+
At as J,
|
|
3489
|
+
Dt as K,
|
|
3490
|
+
Wt as L,
|
|
3491
|
+
Jt as M,
|
|
3492
|
+
Ft as N,
|
|
3493
|
+
Xt as O,
|
|
3494
|
+
O as Ot,
|
|
3495
|
+
Ht as P,
|
|
3496
|
+
ct as Q,
|
|
3497
|
+
Rt as R,
|
|
3498
|
+
te as S,
|
|
3499
|
+
$ as St,
|
|
3500
|
+
Yt as T,
|
|
3501
|
+
ht as Tt,
|
|
3502
|
+
kt as U,
|
|
3503
|
+
_t as V,
|
|
3504
|
+
Lt as W,
|
|
3505
|
+
Et as X,
|
|
3506
|
+
Nt as Y,
|
|
3507
|
+
Ot as Z,
|
|
3508
|
+
re as _,
|
|
3509
|
+
I as _t,
|
|
3510
|
+
ve as a,
|
|
3511
|
+
at,
|
|
3512
|
+
ie as b,
|
|
3513
|
+
g as bt,
|
|
3514
|
+
ge as c,
|
|
3515
|
+
xt as ct,
|
|
3516
|
+
pe as d,
|
|
3517
|
+
H as dt,
|
|
3518
|
+
It as et,
|
|
3519
|
+
le as f,
|
|
3520
|
+
z as ft,
|
|
3521
|
+
ae as g,
|
|
3522
|
+
Z as gt,
|
|
3523
|
+
oe as h,
|
|
3524
|
+
we as ht,
|
|
3525
|
+
Pe as i,
|
|
3526
|
+
be as it,
|
|
3527
|
+
Ce as j,
|
|
3528
|
+
Ut as k,
|
|
3529
|
+
dt as kt,
|
|
3530
|
+
he as l,
|
|
3531
|
+
bt as lt,
|
|
3532
|
+
ce as m,
|
|
3533
|
+
L as mt,
|
|
3534
|
+
xe as n,
|
|
3535
|
+
J as nt,
|
|
3536
|
+
ye as o,
|
|
3537
|
+
me as ot,
|
|
3538
|
+
ue as p,
|
|
3539
|
+
E as pt,
|
|
3540
|
+
Bt as q,
|
|
3541
|
+
Ie as r,
|
|
3542
|
+
T as rt,
|
|
3543
|
+
fe as s,
|
|
3544
|
+
Pt as st,
|
|
3545
|
+
Te as t,
|
|
3546
|
+
b as tt,
|
|
3547
|
+
de as u,
|
|
3548
|
+
F as ut,
|
|
3549
|
+
se as v,
|
|
3550
|
+
u as vt,
|
|
3551
|
+
Zt as w,
|
|
3552
|
+
V as wt,
|
|
3553
|
+
ee as x,
|
|
3554
|
+
P as xt,
|
|
3555
|
+
ne as y,
|
|
3556
|
+
j as yt,
|
|
3557
|
+
$t as z
|
|
2705
3558
|
};
|
|
2706
3559
|
|
|
2707
|
-
//# sourceMappingURL=core-
|
|
3560
|
+
//# sourceMappingURL=core-b6Q8w2sn.js.map
|