Skip to content

Waveform Output (VCD and FST) ​

Celox can write waveform files in two formats for viewing in tools like GTKWave or Surfer:

  • Value Change Dump (VCD): the universal text format. Human-readable, but large for long runs.
  • Fast Signal Trace (FST): GTKWave's compressed binary format. The same signals and timestamps at a fraction of the size, with fast random access in viewers. Prefer it for long simulations.

Both formats record the same signals with the same dump points; every option, method, and HDL control on this page applies to whichever output is selected. vcd and fst options are mutually exclusive.

CLI ​

Use --vcd <FILE> or --fst <FILE> with celox run to record a SystemVerilog or Veryl testbench without adding HDL dump tasks:

sh
celox run top.sv --top Top --backend native --vcd waves.vcd
celox run top.veryl --top Top --fst waves.fst

The CLI records each simulation time step and flushes the file when the run ends, including on a test failure or step limit. Recording keeps eligible compiled schedulers enabled; they return to the host at waveform boundaries. Waveform recording cannot be combined with --compile-only.

Interactive simulation with Surfer ​

Use --cdsp <PORT> to run a SystemVerilog testbench under Surfer's control:

sh
celox run top.sv --top Top --cdsp 12345
surfer cxxrtl+tcp://127.0.0.1:12345

Run the commands in separate terminals. Celox initializes the design at time zero and waits on loopback for one desktop Surfer client. Use Surfer's simulation controls to run, pause, or resume. You can browse the signal hierarchy and inspect the recorded waveforms while paused and after the testbench finishes. Closing the client ends the Celox session. Interactive sessions start from time zero and cannot save or restore CLI checkpoints.

Use FST to inspect X and Z

The live CDSP waveform displays both X and Z as zero. To distinguish them, record an FST file in four-state mode and open it in Surfer.

sh
celox run top.sv --top Top --four-state --fst waves.fst
surfer waves.fst

To also control execution from Surfer, add --cdsp 12345 to the Celox command.

The server uses CXXRTL Debug Server Protocol version 0. Celox keeps the live waveform history in memory for the duration of the session.

Basic Usage ​

Pass vcd (or fst) with the output file path when creating a simulator:

typescript
const sim = Simulator.fromSource(SOURCE, "Top", {
  vcd: "./dump.vcd",
  // fst: "./dump.fst",
});

In Rust, use SimulatorBuilder::vcd or SimulatorBuilder::fst.

Then call sim.dump(timestamp) at each point in time you want recorded:

typescript
sim.dut.a = 10n;
sim.dump(0);      // record initial state at t=0

sim.dut.a = 20n;
sim.tick();
sim.dump(10);     // record state at t=10

sim.dispose();    // flushes and closes the file

WARNING

Waveform output is buffered. Always call dispose() when you are done so the remaining bytes are written — or use a try/finally block. Disposing also finalizes an FST file's header.

In Rust, call Simulator::flush_vcd() or Simulation::flush_vcd() to make buffered output visible before dropping the simulator and to handle write errors. (Despite the name, it flushes FST output too, patching the file header so the file is readable mid-run.) Standalone VcdWriter/FstWriter instances provide flush() and into_inner().

The VCD performance notes describe change tracking, shared-memory behavior, and reproducible benchmarks.

With Time-Based Simulation ​

With Simulation, sim.time() gives you the current time to pass to dump():

typescript
const sim = Simulation.fromSource(SOURCE, "Top", {
  vcd: "./dump.vcd",
});
sim.addClock("clk", { period: 10 });

sim.reset("rst");
sim.dump(sim.time());

sim.dut.en = 1n;
sim.runUntil(100);
sim.dump(sim.time());

sim.dispose();

Further Reading ​

SystemVerilog controls ​

A timed SystemVerilog simulation can select and control tracing from HDL:

systemverilog
initial begin
    $dumpfile("waves.vcd");
    $dumpvars(0, Top);
end

$dumpvars starts recording after the current simulation timestamp settles. All calls must execute at the same simulation time. A level of 0 includes all descendants; 1 includes only the named module's own variables. Individual variables and multiple module or variable selections are supported.

$dumpoff records unknown values and suspends tracing. $dumpon records current values and resumes it. $dumpall records every selected value without changing that state. $dumpflush publishes buffered output, and $dumplimit(bytes) stops recording at the size limit with a comment in the file. Complete records may extend past the limit. A zero limit removes the bound.

$dumpfile accepts a string literal or an integral expression containing the filename and must run before $dumpvars. The default filename is dump.vcd. As a Celox extension (following Icarus Verilog), a filename ending in .fst records FST instead of the VCD format the standard defines; the dump controls above drive it the same way, with $dumpoff/$dumpon also written as FST blackout records. $dumplimit applies approximately for FST: already-queued, uncompressed changes can take the file past the limit before recording stops. Source controls enable the necessary trace storage automatically; a host waveform path is optional. Host waveform methods remain available.