@celox-sim/celox 0.1.14 → 0.1.16
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/napi-helpers.d.ts +8 -2
- package/dist/napi-helpers.d.ts.map +1 -1
- package/dist/napi-helpers.js +18 -7
- package/dist/napi-helpers.js.map +1 -1
- package/dist/simulation.d.ts +5 -2
- package/dist/simulation.d.ts.map +1 -1
- package/dist/simulation.js +14 -6
- package/dist/simulation.js.map +1 -1
- package/dist/simulator.d.ts +5 -2
- package/dist/simulator.d.ts.map +1 -1
- package/dist/simulator.js +14 -6
- package/dist/simulator.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/e2e.bench.ts +1 -1
- package/src/e2e.test.ts +242 -33
- package/src/index.ts +1 -0
- package/src/napi-helpers.ts +37 -9
- package/src/simulation.test.ts +1 -1
- package/src/simulation.ts +40 -11
- package/src/simulator.test.ts +1 -1
- package/src/simulator.ts +47 -7
- package/src/types.ts +9 -1
package/src/simulator.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
NativeSimulatorHandle,
|
|
24
24
|
SignalLayout,
|
|
25
25
|
SimulatorOptions,
|
|
26
|
+
SourceFile,
|
|
26
27
|
} from "./types.js";
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -33,7 +34,7 @@ import type {
|
|
|
33
34
|
* @internal
|
|
34
35
|
*/
|
|
35
36
|
export type NativeCreateFn = (
|
|
36
|
-
|
|
37
|
+
sources: ReadonlyArray<SourceFile>,
|
|
37
38
|
moduleName: string,
|
|
38
39
|
options: SimulatorOptions,
|
|
39
40
|
) => CreateResult<NativeSimulatorHandle>;
|
|
@@ -61,6 +62,7 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
61
62
|
private readonly _state: DirtyState;
|
|
62
63
|
private readonly _buffer: ArrayBuffer | SharedArrayBuffer;
|
|
63
64
|
private readonly _layout: Record<string, SignalLayout>;
|
|
65
|
+
private readonly _warnings: readonly string[];
|
|
64
66
|
private _disposed = false;
|
|
65
67
|
|
|
66
68
|
private constructor(
|
|
@@ -70,6 +72,7 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
70
72
|
state: DirtyState,
|
|
71
73
|
buffer: ArrayBuffer | SharedArrayBuffer,
|
|
72
74
|
layout: Record<string, SignalLayout>,
|
|
75
|
+
warnings: string[],
|
|
73
76
|
) {
|
|
74
77
|
this._handle = handle;
|
|
75
78
|
this._dut = dut;
|
|
@@ -77,6 +80,7 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
77
80
|
this._state = state;
|
|
78
81
|
this._buffer = buffer;
|
|
79
82
|
this._layout = layout;
|
|
83
|
+
this._warnings = warnings;
|
|
80
84
|
const keys = Object.keys(events);
|
|
81
85
|
this._defaultEventId = keys.length > 0 ? events[keys[0]!]! : -1;
|
|
82
86
|
}
|
|
@@ -122,7 +126,7 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
122
126
|
parameters,
|
|
123
127
|
deadStorePolicy,
|
|
124
128
|
} = merged ?? {};
|
|
125
|
-
const result = createFn(module.
|
|
129
|
+
const result = createFn(module.sources, module.name, {
|
|
126
130
|
fourState,
|
|
127
131
|
vcd,
|
|
128
132
|
optimize,
|
|
@@ -159,6 +163,7 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
159
163
|
state,
|
|
160
164
|
result.buffer,
|
|
161
165
|
result.layout,
|
|
166
|
+
result.warnings ?? [],
|
|
162
167
|
);
|
|
163
168
|
}
|
|
164
169
|
|
|
@@ -183,12 +188,19 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
183
188
|
): Simulator<P> {
|
|
184
189
|
const addon = loadNativeAddon(options?.nativeAddonPath);
|
|
185
190
|
const napiOpts = buildNapiOpts(options);
|
|
186
|
-
const raw = new addon.NativeSimulatorHandle(
|
|
191
|
+
const raw = new addon.NativeSimulatorHandle(
|
|
192
|
+
[{ content: source, path: "" }],
|
|
193
|
+
top,
|
|
194
|
+
napiOpts,
|
|
195
|
+
);
|
|
187
196
|
|
|
188
197
|
const layout = parseNapiLayout(raw.layoutJson);
|
|
189
198
|
const events: Record<string, number> = JSON.parse(raw.eventsJson);
|
|
190
199
|
const rawHierarchy = parseHierarchyLayout(raw.hierarchyJson, events);
|
|
191
|
-
const hierarchy = filterHierarchyForDse(
|
|
200
|
+
const hierarchy = filterHierarchyForDse(
|
|
201
|
+
rawHierarchy,
|
|
202
|
+
options?.deadStorePolicy,
|
|
203
|
+
);
|
|
192
204
|
|
|
193
205
|
const ports = buildPortsFromLayout(hierarchy.signals, events);
|
|
194
206
|
|
|
@@ -205,7 +217,17 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
205
217
|
hierarchy,
|
|
206
218
|
);
|
|
207
219
|
|
|
208
|
-
|
|
220
|
+
const warnings: string[] = JSON.parse(raw.warningsJson ?? "[]");
|
|
221
|
+
|
|
222
|
+
return new Simulator<P>(
|
|
223
|
+
handle,
|
|
224
|
+
dut,
|
|
225
|
+
events,
|
|
226
|
+
state,
|
|
227
|
+
buf,
|
|
228
|
+
layout.forDut,
|
|
229
|
+
warnings,
|
|
230
|
+
);
|
|
209
231
|
}
|
|
210
232
|
|
|
211
233
|
/**
|
|
@@ -235,7 +257,10 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
235
257
|
const layout = parseNapiLayout(raw.layoutJson);
|
|
236
258
|
const events: Record<string, number> = JSON.parse(raw.eventsJson);
|
|
237
259
|
const rawHierarchy = parseHierarchyLayout(raw.hierarchyJson, events);
|
|
238
|
-
const hierarchy = filterHierarchyForDse(
|
|
260
|
+
const hierarchy = filterHierarchyForDse(
|
|
261
|
+
rawHierarchy,
|
|
262
|
+
options?.deadStorePolicy,
|
|
263
|
+
);
|
|
239
264
|
|
|
240
265
|
const ports = buildPortsFromLayout(hierarchy.signals, events);
|
|
241
266
|
|
|
@@ -252,7 +277,17 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
252
277
|
hierarchy,
|
|
253
278
|
);
|
|
254
279
|
|
|
255
|
-
|
|
280
|
+
const warnings: string[] = JSON.parse(raw.warningsJson ?? "[]");
|
|
281
|
+
|
|
282
|
+
return new Simulator<P>(
|
|
283
|
+
handle,
|
|
284
|
+
dut,
|
|
285
|
+
events,
|
|
286
|
+
state,
|
|
287
|
+
buf,
|
|
288
|
+
layout.forDut,
|
|
289
|
+
warnings,
|
|
290
|
+
);
|
|
256
291
|
}
|
|
257
292
|
|
|
258
293
|
/** The DUT accessor object — read/write ports as plain properties. */
|
|
@@ -260,6 +295,11 @@ export class Simulator<P = Record<string, unknown>> {
|
|
|
260
295
|
return this._dut;
|
|
261
296
|
}
|
|
262
297
|
|
|
298
|
+
/** Analyzer warnings emitted during compilation. */
|
|
299
|
+
get warnings(): readonly string[] {
|
|
300
|
+
return this._warnings;
|
|
301
|
+
}
|
|
302
|
+
|
|
263
303
|
/**
|
|
264
304
|
* Trigger a clock edge.
|
|
265
305
|
*
|
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
|
|
@@ -20,7 +26,7 @@
|
|
|
20
26
|
export interface ModuleDefinition<Ports = Record<string, unknown>> {
|
|
21
27
|
readonly __celox_module: true;
|
|
22
28
|
readonly name: string;
|
|
23
|
-
readonly
|
|
29
|
+
readonly sources: ReadonlyArray<SourceFile>;
|
|
24
30
|
readonly ports: Record<string, PortInfo>;
|
|
25
31
|
readonly events: string[];
|
|
26
32
|
/** Absolute path to the Veryl project directory (set by Vite plugin). */
|
|
@@ -119,6 +125,8 @@ export interface CreateResult<H extends NativeHandle = NativeHandle> {
|
|
|
119
125
|
readonly handle: H;
|
|
120
126
|
/** Full instance hierarchy (optional — present when NAPI provides it). */
|
|
121
127
|
readonly hierarchy?: import("./napi-helpers.js").HierarchyNode;
|
|
128
|
+
/** Analyzer warnings emitted during compilation. */
|
|
129
|
+
readonly warnings?: string[];
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
// ---------------------------------------------------------------------------
|