Skip to content

@celox-sim/celox / index / Simulator

Class: Simulator<P>

Defined in: packages/celox/src/simulator.ts:60

Type Parameters

P

P = Record<string, unknown>

Accessors

dut

Get Signature

get dut(): P

Defined in: packages/celox/src/simulator.ts:413

The DUT accessor object — read/write ports as plain properties.

Returns

P


warnings

Get Signature

get warnings(): readonly string[]

Defined in: packages/celox/src/simulator.ts:418

Analyzer warnings emitted during compilation.

Returns

readonly string[]

Methods

dispose()

dispose(): void

Defined in: packages/celox/src/simulator.ts:496

Release native resources.

Returns

void


dump()

dump(timestamp): void

Defined in: packages/celox/src/simulator.ts:490

Write current signal values to VCD at the given timestamp.

Parameters

timestamp

number

Returns

void


event()

event(name): EventHandle

Defined in: packages/celox/src/simulator.ts:464

Resolve an event name to a handle for use with tick().

Parameters

name

string

Returns

EventHandle


fourState()

fourState(portName): FourStateValue

Defined in: packages/celox/src/simulator.ts:477

Read the raw 4-state (value + mask) pair for the named port.

Parameters

portName

string

Returns

FourStateValue


tick()

Call Signature

tick(event?, count?): void

Defined in: packages/celox/src/simulator.ts:429

Trigger a clock edge.

Parameters
event?

number | EventHandle

Optional event handle from this.event(). If omitted, ticks the first (default) event.

count?

number

Number of ticks. Default: 1.

Returns

void

Call Signature

tick(count?): void

Defined in: packages/celox/src/simulator.ts:430

Trigger a clock edge.

Parameters
count?

number

Number of ticks. Default: 1.

Returns

void


create()

static create<P>(module, options?): Simulator<P>

Defined in: packages/celox/src/simulator.ts:99

Create a Simulator for the given module.

ts
import { Adder } from "./generated/Adder.js";
const sim = Simulator.create(Adder);

Type Parameters

P

P

Parameters

module

ModuleDefinition<P>

options?

SimulatorOptions & object

Returns

Simulator<P>


fromFrontendArtifact()

static fromFrontendArtifact<P>(artifactJson, options?): Simulator<P>

Defined in: packages/celox/src/simulator.ts:259

Create a Simulator from a versioned artifact emitted by an external frontend built with celox-frontend-sdk.

Type Parameters

P

P = Record<string, unknown>

Parameters

artifactJson

string

options?

SimulatorOptions & object

Returns

Simulator<P>


fromFrontendHandle()

static fromFrontendHandle<P>(raw, options?): Simulator<P>

Defined in: packages/celox/src/simulator.ts:287

Wrap a raw simulator handle returned by a frontend-owned native or WASM addon.

This is the adapter boundary for frontend packages. A frontend's public API can accept its own artifact type, call its native fromMyArtifact function, then pass the returned handle here. No Celox artifact JSON is involved.

Type Parameters

P

P = Record<string, unknown>

Parameters

raw

FrontendSimulatorHandle

options?

Pick<SimulatorOptions, "deadStorePolicy">

Returns

Simulator<P>


fromProject()

static fromProject<P>(projectPath, top, options?): Simulator<P>

Defined in: packages/celox/src/simulator.ts:347

Create a Simulator from a Veryl project directory.

Searches upward from projectPath for Veryl.toml, gathers all .veryl source files, and builds the simulator using the project's clock/reset settings.

ts
const sim = Simulator.fromProject<MyPorts>("./my-project", "Top");

Type Parameters

P

P = Record<string, unknown>

Parameters

projectPath

string

top

string

options?

SimulatorOptions & object

Returns

Simulator<P>


fromSource()

static fromSource<P>(source, top, options?): Simulator<P>

Defined in: packages/celox/src/simulator.ts:187

Create a Simulator directly from Veryl source code.

Automatically discovers ports from the NAPI layout — no ModuleDefinition needed.

ts
const sim = Simulator.fromSource<AdderPorts>(ADDER_SOURCE, "Adder");
sim.dut.a = 100;
sim.dut.b = 200;
sim.tick();
expect(sim.dut.sum).toBe(300);

Type Parameters

P

P = Record<string, unknown>

Parameters

source

string

top

string

options?

SimulatorOptions & object

Returns

Simulator<P>