@celox-sim/celox 0.1.12 → 0.1.14

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/index.ts CHANGED
@@ -8,59 +8,59 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
 
11
- // Core types
12
- export type {
13
- ModuleDefinition,
14
- PortInfo,
15
- SimulatorOptions,
16
- ParamOverride,
17
- EventHandle,
18
- FourStateValue,
19
- LoopBreak,
20
- TrueLoopSpec,
21
- } from "./types.js";
22
-
23
11
  /** @internal */
24
- export type {
25
- SignalLayout,
26
- CreateResult,
27
- NativeHandle,
28
- NativeSimulatorHandle,
29
- NativeSimulationHandle,
30
- } from "./types.js";
31
-
32
- // 4-state helpers
33
- export { X, FourState, isFourStateValue } from "./types.js";
34
-
35
- // Error types
36
- export { SimulationTimeoutError } from "./types.js";
37
-
38
- // Simulator (event-based)
39
- export { Simulator } from "./simulator.js";
40
-
41
- // Simulation (time-based)
42
- export { Simulation } from "./simulation.js";
43
-
12
+ export type { DirtyState } from "./dut.js";
44
13
  /** @internal */
45
- export { createDut, createChildDut, readFourState } from "./dut.js";
14
+ export { createChildDut, createDut, readFourState } from "./dut.js";
46
15
  /** @internal */
47
- export type { DirtyState } from "./dut.js";
48
-
16
+ export type {
17
+ HierarchyNode,
18
+ RawNapiAddon,
19
+ RawNapiSimulationHandle,
20
+ RawNapiSimulatorHandle,
21
+ } from "./napi-helpers.js";
49
22
  /** @internal */
50
23
  export {
51
- loadNativeAddon,
52
- parseNapiLayout,
53
- parseHierarchyLayout,
54
- buildPortsFromLayout,
55
- wrapDirectSimulatorHandle,
56
- wrapDirectSimulationHandle,
57
- createSimulatorBridge,
58
- createSimulationBridge,
59
- parseSignalPath,
60
- buildNapiOpts,
24
+ buildNapiOpts,
25
+ buildPortsFromLayout,
26
+ createSimulationBridge,
27
+ createSimulatorBridge,
28
+ loadNativeAddon,
29
+ parseHierarchyLayout,
30
+ parseNapiLayout,
31
+ parseSignalPath,
32
+ wrapDirectSimulationHandle,
33
+ wrapDirectSimulatorHandle,
61
34
  } from "./napi-helpers.js";
35
+ // Simulation (time-based)
36
+ export { Simulation } from "./simulation.js";
37
+ // Simulator (event-based)
38
+ export { Simulator } from "./simulator.js";
39
+ // Core types
62
40
  /** @internal */
63
- export type { HierarchyNode, RawNapiAddon, RawNapiSimulatorHandle, RawNapiSimulationHandle } from "./napi-helpers.js";
41
+ export type {
42
+ CreateResult,
43
+ EventHandle,
44
+ FourStateValue,
45
+ LoopBreak,
46
+ ModuleDefinition,
47
+ NativeHandle,
48
+ NativeSimulationHandle,
49
+ NativeSimulatorHandle,
50
+ ParamOverride,
51
+ PortInfo,
52
+ SignalLayout,
53
+ SimulatorOptions,
54
+ TrueLoopSpec,
55
+ } from "./types.js";
56
+ // 4-state helpers
57
+ // Error types
58
+ export {
59
+ FourState,
60
+ isFourStateValue,
61
+ SimulationTimeoutError,
62
+ X,
63
+ } from "./types.js";
64
64
 
65
65
  // NAPI bridge (backward compat — re-exports from napi-helpers)
66
66
  // Consumers that import from "./napi-bridge.js" still work.
package/src/matchers.ts CHANGED
@@ -9,28 +9,28 @@
9
9
  * expect(dut.y).not.toBeZ();
10
10
  */
11
11
 
12
- import type { SignalLayout } from "./types.js";
13
12
  import { readFourState } from "./dut.js";
13
+ import type { SignalLayout } from "./types.js";
14
14
 
15
15
  // ---------------------------------------------------------------------------
16
16
  // Matcher declarations (augment vitest's Assertion interface)
17
17
  // ---------------------------------------------------------------------------
18
18
 
19
19
  declare module "vitest" {
20
- interface Assertion {
21
- /** Assert that the value has any X bits (mask !== 0). */
22
- toBeX(): void;
23
- /** Assert that the value is all-X (mask === all-ones). */
24
- toBeAllX(): void;
25
- /** Assert that the value has no X bits (mask === 0). */
26
- toBeNotX(): void;
27
- }
20
+ interface Assertion {
21
+ /** Assert that the value has any X bits (mask !== 0). */
22
+ toBeX(): void;
23
+ /** Assert that the value is all-X (mask === all-ones). */
24
+ toBeAllX(): void;
25
+ /** Assert that the value has no X bits (mask === 0). */
26
+ toBeNotX(): void;
27
+ }
28
28
 
29
- interface AsymmetricMatchersContaining {
30
- toBeX(): void;
31
- toBeAllX(): void;
32
- toBeNotX(): void;
33
- }
29
+ interface AsymmetricMatchersContaining {
30
+ toBeX(): void;
31
+ toBeAllX(): void;
32
+ toBeNotX(): void;
33
+ }
34
34
  }
35
35
 
36
36
  // ---------------------------------------------------------------------------
@@ -46,24 +46,24 @@ declare module "vitest" {
46
46
  * expect(ref).toBeX();
47
47
  */
48
48
  export interface FourStateRef {
49
- readonly __fourStateRef: true;
50
- readonly buffer: SharedArrayBuffer;
51
- readonly layout: SignalLayout;
49
+ readonly __fourStateRef: true;
50
+ readonly buffer: SharedArrayBuffer;
51
+ readonly layout: SignalLayout;
52
52
  }
53
53
 
54
54
  export function fourStateRef(
55
- buffer: SharedArrayBuffer,
56
- layout: SignalLayout,
55
+ buffer: SharedArrayBuffer,
56
+ layout: SignalLayout,
57
57
  ): FourStateRef {
58
- return { __fourStateRef: true, buffer, layout };
58
+ return { __fourStateRef: true, buffer, layout };
59
59
  }
60
60
 
61
61
  function isFourStateRef(v: unknown): v is FourStateRef {
62
- return (
63
- typeof v === "object" &&
64
- v !== null &&
65
- (v as FourStateRef).__fourStateRef === true
66
- );
62
+ return (
63
+ typeof v === "object" &&
64
+ v !== null &&
65
+ (v as FourStateRef).__fourStateRef === true
66
+ );
67
67
  }
68
68
 
69
69
  // ---------------------------------------------------------------------------
@@ -71,57 +71,57 @@ function isFourStateRef(v: unknown): v is FourStateRef {
71
71
  // ---------------------------------------------------------------------------
72
72
 
73
73
  function getMask(received: unknown): bigint {
74
- if (!isFourStateRef(received)) {
75
- throw new TypeError(
76
- "toBeX/toBeAllX/toBeNotX matchers require a FourStateRef. " +
77
- "Use sim.fourStateRef(name) to get one.",
78
- );
79
- }
80
- const [, mask] = readFourState(received.buffer, received.layout);
81
- return mask;
74
+ if (!isFourStateRef(received)) {
75
+ throw new TypeError(
76
+ "toBeX/toBeAllX/toBeNotX matchers require a FourStateRef. " +
77
+ "Use sim.fourStateRef(name) to get one.",
78
+ );
79
+ }
80
+ const [, mask] = readFourState(received.buffer, received.layout);
81
+ return mask;
82
82
  }
83
83
 
84
84
  const customMatchers = {
85
- toBeX(received: unknown) {
86
- const mask = getMask(received);
87
- const pass = mask !== 0n;
88
- return {
89
- pass,
90
- message: () =>
91
- pass
92
- ? `expected signal NOT to have X bits, but mask = ${mask}`
93
- : `expected signal to have X bits, but mask = 0`,
94
- };
95
- },
85
+ toBeX(received: unknown) {
86
+ const mask = getMask(received);
87
+ const pass = mask !== 0n;
88
+ return {
89
+ pass,
90
+ message: () =>
91
+ pass
92
+ ? `expected signal NOT to have X bits, but mask = ${mask}`
93
+ : `expected signal to have X bits, but mask = 0`,
94
+ };
95
+ },
96
96
 
97
- toBeAllX(received: unknown) {
98
- if (!isFourStateRef(received)) {
99
- throw new TypeError("toBeAllX requires a FourStateRef");
100
- }
101
- const [, mask] = readFourState(received.buffer, received.layout);
102
- const width = received.layout.width;
103
- const allOnes = (1n << BigInt(width)) - 1n;
104
- const pass = mask === allOnes;
105
- return {
106
- pass,
107
- message: () =>
108
- pass
109
- ? `expected signal NOT to be all-X`
110
- : `expected signal to be all-X, but mask = ${mask}`,
111
- };
112
- },
97
+ toBeAllX(received: unknown) {
98
+ if (!isFourStateRef(received)) {
99
+ throw new TypeError("toBeAllX requires a FourStateRef");
100
+ }
101
+ const [, mask] = readFourState(received.buffer, received.layout);
102
+ const width = received.layout.width;
103
+ const allOnes = (1n << BigInt(width)) - 1n;
104
+ const pass = mask === allOnes;
105
+ return {
106
+ pass,
107
+ message: () =>
108
+ pass
109
+ ? `expected signal NOT to be all-X`
110
+ : `expected signal to be all-X, but mask = ${mask}`,
111
+ };
112
+ },
113
113
 
114
- toBeNotX(received: unknown) {
115
- const mask = getMask(received);
116
- const pass = mask === 0n;
117
- return {
118
- pass,
119
- message: () =>
120
- pass
121
- ? `expected signal to have X bits, but mask = 0`
122
- : `expected signal NOT to have X bits, but mask = ${mask}`,
123
- };
124
- },
114
+ toBeNotX(received: unknown) {
115
+ const mask = getMask(received);
116
+ const pass = mask === 0n;
117
+ return {
118
+ pass,
119
+ message: () =>
120
+ pass
121
+ ? `expected signal to have X bits, but mask = 0`
122
+ : `expected signal NOT to have X bits, but mask = ${mask}`,
123
+ };
124
+ },
125
125
  };
126
126
 
127
127
  // ---------------------------------------------------------------------------
@@ -138,14 +138,14 @@ const customMatchers = {
138
138
  * ```
139
139
  */
140
140
  export function setupMatchers(): void {
141
- // Dynamic import to keep vitest as an optional peer dependency
142
- try {
143
- // eslint-disable-next-line @typescript-eslint/no-require-imports
144
- const { expect } = require("vitest");
145
- expect.extend(customMatchers);
146
- } catch {
147
- throw new Error(
148
- "vitest is required for setupMatchers(). Install it as a dev dependency.",
149
- );
150
- }
141
+ // Dynamic import to keep vitest as an optional peer dependency
142
+ try {
143
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
144
+ const { expect } = require("vitest");
145
+ expect.extend(customMatchers);
146
+ } catch {
147
+ throw new Error(
148
+ "vitest is required for setupMatchers(). Install it as a dev dependency.",
149
+ );
150
+ }
151
151
  }
@@ -5,9 +5,9 @@
5
5
  */
6
6
 
7
7
  export {
8
- createSimulatorBridge,
9
- createSimulationBridge,
10
- type RawNapiAddon,
11
- type RawNapiSimulatorHandle,
12
- type RawNapiSimulationHandle,
8
+ createSimulationBridge,
9
+ createSimulatorBridge,
10
+ type RawNapiAddon,
11
+ type RawNapiSimulationHandle,
12
+ type RawNapiSimulatorHandle,
13
13
  } from "./napi-helpers.js";