@celox-sim/celox 0.1.6 → 0.1.7

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/src/matchers.ts CHANGED
@@ -70,7 +70,7 @@ function isFourStateRef(v: unknown): v is FourStateRef {
70
70
  // Matcher implementations
71
71
  // ---------------------------------------------------------------------------
72
72
 
73
- function getMask(received: unknown): number | bigint {
73
+ function getMask(received: unknown): bigint {
74
74
  if (!isFourStateRef(received)) {
75
75
  throw new TypeError(
76
76
  "toBeX/toBeAllX/toBeNotX matchers require a FourStateRef. " +
@@ -84,7 +84,7 @@ function getMask(received: unknown): number | bigint {
84
84
  const customMatchers = {
85
85
  toBeX(received: unknown) {
86
86
  const mask = getMask(received);
87
- const pass = mask !== 0 && mask !== 0n;
87
+ const pass = mask !== 0n;
88
88
  return {
89
89
  pass,
90
90
  message: () =>
@@ -100,10 +100,7 @@ const customMatchers = {
100
100
  }
101
101
  const [, mask] = readFourState(received.buffer, received.layout);
102
102
  const width = received.layout.width;
103
- const allOnes =
104
- width <= 53
105
- ? (width === 53 ? Number.MAX_SAFE_INTEGER : (1 << width) - 1)
106
- : (1n << BigInt(width)) - 1n;
103
+ const allOnes = (1n << BigInt(width)) - 1n;
107
104
  const pass = mask === allOnes;
108
105
  return {
109
106
  pass,
@@ -116,7 +113,7 @@ const customMatchers = {
116
113
 
117
114
  toBeNotX(received: unknown) {
118
115
  const mask = getMask(received);
119
- const pass = mask === 0 || mask === 0n;
116
+ const pass = mask === 0n;
120
117
  return {
121
118
  pass,
122
119
  message: () =>
@@ -12,9 +12,9 @@ import { SimulationTimeoutError } from "./types.js";
12
12
  // ---------------------------------------------------------------------------
13
13
 
14
14
  interface TopPorts {
15
- rst: number;
16
- d: number;
17
- readonly q: number;
15
+ rst: bigint;
16
+ d: bigint;
17
+ readonly q: bigint;
18
18
  }
19
19
 
20
20
  const TopModule: ModuleDefinition<TopPorts> = {
@@ -127,11 +127,11 @@ describe("Simulation", () => {
127
127
  __nativeCreate: mock.create,
128
128
  });
129
129
 
130
- sim.dut.d = 42;
130
+ sim.dut.d = 42n;
131
131
  sim.runUntil(100);
132
132
 
133
133
  expect(mock.handle.runUntil).toHaveBeenCalledWith(100);
134
- expect(sim.dut.q).toBe(42);
134
+ expect(sim.dut.q).toBe(42n);
135
135
  });
136
136
 
137
137
  test("step", () => {
@@ -140,11 +140,11 @@ describe("Simulation", () => {
140
140
  __nativeCreate: mock.create,
141
141
  });
142
142
 
143
- sim.dut.d = 0xAB;
143
+ sim.dut.d = 0xABn;
144
144
  const t = sim.step();
145
145
 
146
146
  expect(t).toBe(5);
147
- expect(sim.dut.q).toBe(0xAB);
147
+ expect(sim.dut.q).toBe(0xABn);
148
148
  });
149
149
 
150
150
  test("time", () => {
@@ -240,7 +240,7 @@ describe("Simulation", () => {
240
240
  __nativeCreate: mock.create,
241
241
  });
242
242
 
243
- sim.dut.d = 42;
243
+ sim.dut.d = 42n;
244
244
  let callCount = 0;
245
245
  const t = sim.waitUntil(() => {
246
246
  callCount++;
package/src/simulation.ts CHANGED
@@ -381,8 +381,8 @@ export class Simulation<P = Record<string, unknown>> {
381
381
  );
382
382
  }
383
383
  const isActiveLow = typeKind === "reset_async_low" || typeKind === "reset_sync_low";
384
- const activeValue = isActiveLow ? 0 : 1;
385
- const inactiveValue = isActiveLow ? 1 : 0;
384
+ const activeValue = isActiveLow ? 0n : 1n;
385
+ const inactiveValue = isActiveLow ? 1n : 0n;
386
386
 
387
387
  const dut = this._dut as Record<string, unknown>;
388
388
  dut[signal] = activeValue;
@@ -11,10 +11,10 @@ import type {
11
11
  // ---------------------------------------------------------------------------
12
12
 
13
13
  interface AdderPorts {
14
- rst: number;
15
- a: number;
16
- b: number;
17
- readonly sum: number;
14
+ rst: bigint;
15
+ a: bigint;
16
+ b: bigint;
17
+ readonly sum: bigint;
18
18
  }
19
19
 
20
20
  const AdderModule: ModuleDefinition<AdderPorts> = {
@@ -80,11 +80,11 @@ describe("Simulator", () => {
80
80
  __nativeCreate: mock.create,
81
81
  });
82
82
 
83
- sim.dut.a = 100;
84
- sim.dut.b = 200;
83
+ sim.dut.a = 100n;
84
+ sim.dut.b = 200n;
85
85
  sim.tick();
86
86
 
87
- expect(sim.dut.sum).toBe(300);
87
+ expect(sim.dut.sum).toBe(300n);
88
88
  expect(mock.handle.tick).toHaveBeenCalledTimes(1);
89
89
  });
90
90
 
@@ -176,7 +176,7 @@ describe("Simulator", () => {
176
176
  __nativeCreate: mock.create,
177
177
  });
178
178
 
179
- sim.dut.a = 100;
179
+ sim.dut.a = 100n;
180
180
  sim.tick();
181
181
 
182
182
  // After tick, reading output should NOT trigger evalComb
package/src/simulator.ts CHANGED
@@ -234,12 +234,16 @@ export class Simulator<P = Record<string, unknown>> {
234
234
  ticks = 1;
235
235
  }
236
236
 
237
+ if (this._state.dirty) {
238
+ this._handle.evalComb();
239
+ this._state.dirty = false;
240
+ }
241
+
237
242
  if (ticks === 1) {
238
243
  this._handle.tick(eventId);
239
244
  } else if (ticks > 1) {
240
245
  this._handle.tickN(eventId, ticks);
241
246
  }
242
- this._state.dirty = false;
243
247
  }
244
248
 
245
249
  /** Resolve an event name to a handle for use with `tick()`. */
package/src/types.ts CHANGED
@@ -160,8 +160,8 @@ export const X = Symbol.for("veryl:X");
160
160
  /** A 4-state value with explicit bit-level mask. */
161
161
  export interface FourStateValue {
162
162
  readonly __fourState: true;
163
- readonly value: number | bigint;
164
- readonly mask: number | bigint;
163
+ readonly value: bigint;
164
+ readonly mask: bigint;
165
165
  }
166
166
 
167
167
  /** Construct a 4-state value. Mask bits set to 1 indicate X. */
@@ -169,7 +169,7 @@ export function FourState(
169
169
  value: number | bigint,
170
170
  mask: number | bigint,
171
171
  ): FourStateValue {
172
- return { __fourState: true, value, mask };
172
+ return { __fourState: true, value: BigInt(value), mask: BigInt(mask) };
173
173
  }
174
174
 
175
175
  export function isFourStateValue(v: unknown): v is FourStateValue {