@celox-sim/celox 0.1.13 → 0.1.15

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