@vessel-dsp/runtime 0.14.0 → 0.15.0

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.
Binary file
@@ -1610,6 +1610,7 @@ var IMPLEMENTED_OPERATORS = {
1610
1610
  vccs: true,
1611
1611
  optocoupler: true,
1612
1612
  "logic-divider": true,
1613
+ "d-flip-flop": true,
1613
1614
  "analog-switch": true,
1614
1615
  ota: true,
1615
1616
  compandor: true,
@@ -5494,6 +5495,56 @@ var ReferenceRuntime = class {
5494
5495
  rhs[row] = Q * stamp.highVolts;
5495
5496
  break;
5496
5497
  }
5498
+ case "d-flip-flop": {
5499
+ const stateIdx = stamp.stateIndex;
5500
+ const dffKey = `${block.id}_dff_${stamp.stateIndex}`;
5501
+ if (this.elapsedSamples !== (this.lastShiftedSample.get(dffKey) ?? -1)) {
5502
+ this.lastShiftedSample.set(dffKey, this.elapsedSamples);
5503
+ const vSup = (solution[stamp.vddNode] ?? 0) - (solution[stamp.vssNode] ?? 0);
5504
+ const vThr = (solution[stamp.vssNode] ?? 0) + vSup / 2;
5505
+ const vClkPrev = state[stateIdx + 2] ?? 0;
5506
+ const vClk = (solution[stamp.clockNode] ?? 0) - (solution[stamp.vssNode] ?? 0);
5507
+ const vD = (solution[stamp.dNode] ?? 0) - (solution[stamp.vssNode] ?? 0);
5508
+ const vSet = (solution[stamp.setNode] ?? 0) - (solution[stamp.vssNode] ?? 0);
5509
+ const vReset = (solution[stamp.resetNode] ?? 0) - (solution[stamp.vssNode] ?? 0);
5510
+ const setHigh = vSet >= vThr;
5511
+ const resetHigh = vReset >= vThr;
5512
+ if (setHigh && resetHigh) {
5513
+ state[stateIdx] = 1;
5514
+ state[stateIdx + 1] = 1;
5515
+ } else if (setHigh) {
5516
+ state[stateIdx] = 1;
5517
+ state[stateIdx + 1] = 0;
5518
+ } else if (resetHigh) {
5519
+ state[stateIdx] = 0;
5520
+ state[stateIdx + 1] = 1;
5521
+ } else if (vClkPrev < vThr && vClk >= vThr) {
5522
+ const q = vD >= vThr ? 1 : 0;
5523
+ state[stateIdx] = q;
5524
+ state[stateIdx + 1] = 1 - q;
5525
+ }
5526
+ state[stateIdx + 2] = vClk;
5527
+ }
5528
+ const Q = state[stateIdx] ?? 0;
5529
+ const Qbar = state[stateIdx + 1] ?? 1;
5530
+ const vSupOut = (solution[stamp.vddNode] ?? 0) - (solution[stamp.vssNode] ?? 0);
5531
+ const vSsOut = solution[stamp.vssNode] ?? 0;
5532
+ const rowQ = block.nodeCount + stamp.sourceIndex;
5533
+ matrix[rowQ][stamp.qNode] += 1;
5534
+ matrix[stamp.qNode][rowQ] += 1;
5535
+ matrix[rowQ][stamp.vssNode] -= 1;
5536
+ matrix[stamp.vssNode][rowQ] -= 1;
5537
+ matrix[rowQ][rowQ] -= 1;
5538
+ rhs[rowQ] = vSsOut + Q * vSupOut;
5539
+ const rowQbar = block.nodeCount + stamp.sourceIndex2;
5540
+ matrix[rowQbar][stamp.qBarNode] += 1;
5541
+ matrix[stamp.qBarNode][rowQbar] += 1;
5542
+ matrix[rowQbar][stamp.vssNode] -= 1;
5543
+ matrix[stamp.vssNode][rowQbar] -= 1;
5544
+ matrix[rowQbar][rowQbar] -= 1;
5545
+ rhs[rowQbar] = vSsOut + Qbar * vSupOut;
5546
+ break;
5547
+ }
5497
5548
  case "analog-switch": {
5498
5549
  const vA = solution[stamp.a] ?? 0;
5499
5550
  const vB = solution[stamp.b] ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vessel-dsp/runtime",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Real-time MNA simulation runtime and solver console for VesselDSP Program ROMs.",
5
5
  "keywords": [
6
6
  "guitar-pedal",
@@ -58,7 +58,7 @@
58
58
  "generate-kernels": "bun scripts/generate-kernels.ts"
59
59
  },
60
60
  "dependencies": {
61
- "@vessel-dsp/compiler": "0.16.0"
61
+ "@vessel-dsp/compiler": "0.18.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"