@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/dist/dut.d.ts +1 -1
- package/dist/dut.d.ts.map +1 -1
- package/dist/dut.js +32 -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 +1040 -661
- package/src/dut.ts +580 -520
- package/src/e2e.bench.ts +627 -310
- package/src/e2e.test.ts +1872 -1550
- 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/types.ts
CHANGED
|
@@ -18,26 +18,28 @@
|
|
|
18
18
|
* a correctly-typed DUT accessor.
|
|
19
19
|
*/
|
|
20
20
|
export interface ModuleDefinition<Ports = Record<string, unknown>> {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
readonly __celox_module: true;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly source: string;
|
|
24
|
+
readonly ports: Record<string, PortInfo>;
|
|
25
|
+
readonly events: string[];
|
|
26
|
+
/** Absolute path to the Veryl project directory (set by Vite plugin). */
|
|
27
|
+
readonly projectPath?: string;
|
|
28
|
+
/** Default options baked in by the Vite plugin (e.g. via `?dse=` query). */
|
|
29
|
+
readonly defaultOptions?: SimulatorOptions;
|
|
30
|
+
/** Phantom field — never set at runtime. Carries the `Ports` type. */
|
|
31
|
+
readonly __ports?: Ports;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/** Metadata for a single port / interface member. */
|
|
33
35
|
export interface PortInfo {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
readonly direction: "input" | "output" | "inout" | "internal";
|
|
37
|
+
readonly type: "clock" | "reset" | "logic" | "bit";
|
|
38
|
+
readonly width: number;
|
|
39
|
+
readonly arrayDims?: readonly number[];
|
|
40
|
+
readonly is4state?: boolean;
|
|
41
|
+
/** Nested interface members (recursive). */
|
|
42
|
+
readonly interface?: Record<string, PortInfo>;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
// ---------------------------------------------------------------------------
|
|
@@ -49,19 +51,19 @@ export interface PortInfo {
|
|
|
49
51
|
* @internal
|
|
50
52
|
*/
|
|
51
53
|
export interface SignalLayout {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
/** Byte offset within the STABLE region. */
|
|
55
|
+
readonly offset: number;
|
|
56
|
+
/** Bit width of the signal. */
|
|
57
|
+
readonly width: number;
|
|
58
|
+
/** Number of bytes occupied (ceil(width/8)). */
|
|
59
|
+
readonly byteSize: number;
|
|
60
|
+
/** If true, an equal-sized mask follows immediately after the value. */
|
|
61
|
+
readonly is4state: boolean;
|
|
62
|
+
readonly direction: "input" | "output" | "inout" | "internal";
|
|
63
|
+
/** The Veryl type kind (e.g. "clock", "reset_async_high", "logic"). */
|
|
64
|
+
readonly typeKind?: string;
|
|
65
|
+
/** For reset signals, the name of the associated clock (from FfDeclaration). */
|
|
66
|
+
readonly associatedClock?: string;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
// ---------------------------------------------------------------------------
|
|
@@ -73,11 +75,11 @@ export interface SignalLayout {
|
|
|
73
75
|
* @internal
|
|
74
76
|
*/
|
|
75
77
|
export interface NativeSimulatorHandle {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
tick(eventId: number): void;
|
|
79
|
+
tickN(eventId: number, count: number): void;
|
|
80
|
+
evalComb(): void;
|
|
81
|
+
dump(timestamp: number): void;
|
|
82
|
+
dispose(): void;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
/**
|
|
@@ -85,15 +87,15 @@ export interface NativeSimulatorHandle {
|
|
|
85
87
|
* @internal
|
|
86
88
|
*/
|
|
87
89
|
export interface NativeSimulationHandle {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
addClock(eventId: number, period: number, initialDelay: number): void;
|
|
91
|
+
schedule(eventId: number, time: number, value: number): void;
|
|
92
|
+
runUntil(endTime: number): void;
|
|
93
|
+
step(): number | null;
|
|
94
|
+
time(): number;
|
|
95
|
+
nextEventTime(): number | null;
|
|
96
|
+
evalComb(): void;
|
|
97
|
+
dump(timestamp: number): void;
|
|
98
|
+
dispose(): void;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -107,16 +109,16 @@ export type NativeHandle = NativeSimulatorHandle | NativeSimulationHandle;
|
|
|
107
109
|
* @internal
|
|
108
110
|
*/
|
|
109
111
|
export interface CreateResult<H extends NativeHandle = NativeHandle> {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
/** The simulator's internal memory buffer shared zero-copy. */
|
|
113
|
+
readonly buffer: ArrayBuffer | SharedArrayBuffer;
|
|
114
|
+
/** Per-signal byte layout within `buffer`. */
|
|
115
|
+
readonly layout: Record<string, SignalLayout>;
|
|
116
|
+
/** Event name → internal event ID mapping. */
|
|
117
|
+
readonly events: Record<string, number>;
|
|
118
|
+
/** Native control handle. */
|
|
119
|
+
readonly handle: H;
|
|
120
|
+
/** Full instance hierarchy (optional — present when NAPI provides it). */
|
|
121
|
+
readonly hierarchy?: import("./napi-helpers.js").HierarchyNode;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
// ---------------------------------------------------------------------------
|
|
@@ -124,30 +126,32 @@ export interface CreateResult<H extends NativeHandle = NativeHandle> {
|
|
|
124
126
|
// ---------------------------------------------------------------------------
|
|
125
127
|
|
|
126
128
|
export interface SimulatorOptions {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
129
|
+
/** Enable 4-state (X) simulation. Default: false. */
|
|
130
|
+
fourState?: boolean;
|
|
131
|
+
/** Path to write VCD waveform output. */
|
|
132
|
+
vcd?: string;
|
|
133
|
+
/** Enable Cranelift optimization passes. */
|
|
134
|
+
optimize?: boolean;
|
|
135
|
+
/** False-loop declarations to ignore during compilation. */
|
|
136
|
+
falseLoops?: LoopBreak[];
|
|
137
|
+
/** True-loop declarations with convergence limits. */
|
|
138
|
+
trueLoops?: TrueLoopSpec[];
|
|
139
|
+
/** Clock polarity. Default: "posedge". */
|
|
140
|
+
clockType?: "posedge" | "negedge";
|
|
141
|
+
/** Reset type. Default: "async_low". */
|
|
142
|
+
resetType?: "async_high" | "async_low" | "sync_high" | "sync_low";
|
|
143
|
+
/** Additional Veryl source to append to the main source code. */
|
|
144
|
+
extraSource?: string;
|
|
145
|
+
/** Top-level module parameter overrides. */
|
|
146
|
+
parameters?: ParamOverride[];
|
|
147
|
+
/** Dead store elimination policy. Default: "off". */
|
|
148
|
+
deadStorePolicy?: "off" | "preserveTopPorts" | "preserveAllPorts";
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
/** A parameter override for a top-level module parameter. */
|
|
148
152
|
export interface ParamOverride {
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
name: string;
|
|
154
|
+
value: number | bigint;
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
// ---------------------------------------------------------------------------
|
|
@@ -156,8 +160,8 @@ export interface ParamOverride {
|
|
|
156
160
|
|
|
157
161
|
/** A resolved event reference for use with `tick()`. */
|
|
158
162
|
export interface EventHandle {
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
readonly name: string;
|
|
164
|
+
readonly id: number;
|
|
161
165
|
}
|
|
162
166
|
|
|
163
167
|
// ---------------------------------------------------------------------------
|
|
@@ -169,25 +173,25 @@ export const X = Symbol.for("veryl:X");
|
|
|
169
173
|
|
|
170
174
|
/** A 4-state value with explicit bit-level mask. */
|
|
171
175
|
export interface FourStateValue {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
readonly __fourState: true;
|
|
177
|
+
readonly value: bigint;
|
|
178
|
+
readonly mask: bigint;
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
/** Construct a 4-state value. Mask bits set to 1 indicate X. */
|
|
178
182
|
export function FourState(
|
|
179
|
-
|
|
180
|
-
|
|
183
|
+
value: number | bigint,
|
|
184
|
+
mask: number | bigint,
|
|
181
185
|
): FourStateValue {
|
|
182
|
-
|
|
186
|
+
return { __fourState: true, value: BigInt(value), mask: BigInt(mask) };
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
export function isFourStateValue(v: unknown): v is FourStateValue {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
return (
|
|
191
|
+
typeof v === "object" &&
|
|
192
|
+
v !== null &&
|
|
193
|
+
(v as FourStateValue).__fourState === true
|
|
194
|
+
);
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
// ---------------------------------------------------------------------------
|
|
@@ -198,15 +202,15 @@ export function isFourStateValue(v: unknown): v is FourStateValue {
|
|
|
198
202
|
* Thrown when a simulation helper exceeds its step budget.
|
|
199
203
|
*/
|
|
200
204
|
export class SimulationTimeoutError extends Error {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
readonly time: number;
|
|
206
|
+
readonly steps: number;
|
|
207
|
+
|
|
208
|
+
constructor(message: string, time: number, steps: number) {
|
|
209
|
+
super(message);
|
|
210
|
+
this.name = "SimulationTimeoutError";
|
|
211
|
+
this.time = time;
|
|
212
|
+
this.steps = steps;
|
|
213
|
+
}
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
// ---------------------------------------------------------------------------
|
|
@@ -215,11 +219,11 @@ export class SimulationTimeoutError extends Error {
|
|
|
215
219
|
|
|
216
220
|
/** Specifies a false-loop to ignore during compilation. */
|
|
217
221
|
export interface LoopBreak {
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
from: string;
|
|
223
|
+
to: string;
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
/** Specifies a true-loop with a convergence iteration limit. */
|
|
223
227
|
export interface TrueLoopSpec extends LoopBreak {
|
|
224
|
-
|
|
228
|
+
maxIter: number;
|
|
225
229
|
}
|