@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/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
- 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
- /** Phantom field never set at runtime. Carries the `Ports` type. */
29
- readonly __ports?: Ports;
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
- readonly direction: "input" | "output" | "inout";
35
- readonly type: "clock" | "reset" | "logic" | "bit";
36
- readonly width: number;
37
- readonly arrayDims?: readonly number[];
38
- readonly is4state?: boolean;
39
- /** Nested interface members (recursive). */
40
- readonly interface?: Record<string, PortInfo>;
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
- /** Byte offset within the STABLE region. */
53
- readonly offset: number;
54
- /** Bit width of the signal. */
55
- readonly width: number;
56
- /** Number of bytes occupied (ceil(width/8)). */
57
- readonly byteSize: number;
58
- /** If true, an equal-sized mask follows immediately after the value. */
59
- readonly is4state: boolean;
60
- readonly direction: "input" | "output" | "inout";
61
- /** The Veryl type kind (e.g. "clock", "reset_async_high", "logic"). */
62
- readonly typeKind?: string;
63
- /** For reset signals, the name of the associated clock (from FfDeclaration). */
64
- readonly associatedClock?: string;
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
- tick(eventId: number): void;
77
- tickN(eventId: number, count: number): void;
78
- evalComb(): void;
79
- dump(timestamp: number): void;
80
- dispose(): void;
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
- addClock(eventId: number, period: number, initialDelay: number): void;
89
- schedule(eventId: number, time: number, value: number): void;
90
- runUntil(endTime: number): void;
91
- step(): number | null;
92
- time(): number;
93
- nextEventTime(): number | null;
94
- evalComb(): void;
95
- dump(timestamp: number): void;
96
- dispose(): void;
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
- /** The simulator's internal memory buffer shared zero-copy. */
111
- readonly buffer: ArrayBuffer | SharedArrayBuffer;
112
- /** Per-signal byte layout within `buffer`. */
113
- readonly layout: Record<string, SignalLayout>;
114
- /** Event name → internal event ID mapping. */
115
- readonly events: Record<string, number>;
116
- /** Native control handle. */
117
- readonly handle: H;
118
- /** Full instance hierarchy (optional — present when NAPI provides it). */
119
- readonly hierarchy?: import("./napi-helpers.js").HierarchyNode;
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
- /** Enable 4-state (X) simulation. Default: false. */
128
- fourState?: boolean;
129
- /** Path to write VCD waveform output. */
130
- vcd?: string;
131
- /** Enable Cranelift optimization passes. */
132
- optimize?: boolean;
133
- /** False-loop declarations to ignore during compilation. */
134
- falseLoops?: LoopBreak[];
135
- /** True-loop declarations with convergence limits. */
136
- trueLoops?: TrueLoopSpec[];
137
- /** Clock polarity. Default: "posedge". */
138
- clockType?: "posedge" | "negedge";
139
- /** Reset type. Default: "async_low". */
140
- resetType?: "async_high" | "async_low" | "sync_high" | "sync_low";
141
- /** Additional Veryl source to append to the main source code. */
142
- extraSource?: string;
143
- /** Top-level module parameter overrides. */
144
- parameters?: ParamOverride[];
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
- name: string;
150
- value: number | bigint;
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
- readonly name: string;
160
- readonly id: number;
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
- readonly __fourState: true;
173
- readonly value: bigint;
174
- readonly mask: bigint;
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
- value: number | bigint,
180
- mask: number | bigint,
183
+ value: number | bigint,
184
+ mask: number | bigint,
181
185
  ): FourStateValue {
182
- return { __fourState: true, value: BigInt(value), mask: BigInt(mask) };
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
- return (
187
- typeof v === "object" &&
188
- v !== null &&
189
- (v as FourStateValue).__fourState === true
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
- readonly time: number;
202
- readonly steps: number;
203
-
204
- constructor(message: string, time: number, steps: number) {
205
- super(message);
206
- this.name = "SimulationTimeoutError";
207
- this.time = time;
208
- this.steps = steps;
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
- from: string;
219
- to: string;
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
- maxIter: number;
228
+ maxIter: number;
225
229
  }