@celox-sim/celox 0.1.13 → 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/dist/dut.d.ts +1 -1
- package/dist/dut.d.ts.map +1 -1
- package/dist/dut.js +23 -10
- package/dist/dut.js.map +1 -1
- package/dist/index.d.ts +8 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/napi-bridge.d.ts +1 -1
- package/dist/napi-bridge.d.ts.map +1 -1
- package/dist/napi-bridge.js +1 -1
- package/dist/napi-bridge.js.map +1 -1
- package/dist/napi-helpers.d.ts +11 -2
- package/dist/napi-helpers.d.ts.map +1 -1
- package/dist/napi-helpers.js +23 -0
- package/dist/napi-helpers.js.map +1 -1
- package/dist/simulation.d.ts.map +1 -1
- package/dist/simulation.js +29 -13
- package/dist/simulation.js.map +1 -1
- package/dist/simulator.d.ts.map +1 -1
- package/dist/simulator.js +28 -12
- package/dist/simulator.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/dut.test.ts +1037 -742
- package/src/dut.ts +580 -528
- package/src/e2e.bench.ts +512 -509
- package/src/e2e.test.ts +1847 -1574
- package/src/index.ts +46 -46
- package/src/matchers.ts +81 -81
- package/src/napi-bridge.ts +5 -5
- package/src/napi-helpers.ts +475 -400
- package/src/simulation.test.ts +395 -368
- package/src/simulation.ts +502 -430
- package/src/simulator.test.ts +201 -168
- package/src/simulator.ts +317 -267
- package/src/types.ts +102 -98
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 {
|
|
14
|
+
export { createChildDut, createDut, readFourState } from "./dut.js";
|
|
46
15
|
/** @internal */
|
|
47
|
-
export type {
|
|
48
|
-
|
|
16
|
+
export type {
|
|
17
|
+
HierarchyNode,
|
|
18
|
+
RawNapiAddon,
|
|
19
|
+
RawNapiSimulationHandle,
|
|
20
|
+
RawNapiSimulatorHandle,
|
|
21
|
+
} from "./napi-helpers.js";
|
|
49
22
|
/** @internal */
|
|
50
23
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 {
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
readonly __fourStateRef: true;
|
|
50
|
+
readonly buffer: SharedArrayBuffer;
|
|
51
|
+
readonly layout: SignalLayout;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export function fourStateRef(
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
buffer: SharedArrayBuffer,
|
|
56
|
+
layout: SignalLayout,
|
|
57
57
|
): FourStateRef {
|
|
58
|
-
|
|
58
|
+
return { __fourStateRef: true, buffer, layout };
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function isFourStateRef(v: unknown): v is FourStateRef {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
}
|
package/src/napi-bridge.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
createSimulationBridge,
|
|
9
|
+
createSimulatorBridge,
|
|
10
|
+
type RawNapiAddon,
|
|
11
|
+
type RawNapiSimulationHandle,
|
|
12
|
+
type RawNapiSimulatorHandle,
|
|
13
13
|
} from "./napi-helpers.js";
|