Skip to content

SystemVerilog Support ​

Celox can simulate SystemVerilog through its Rust API. Supply your source files and choose a top module. The Vite plugin currently loads Veryl only; the TypeScript package compiles the sources of a module definition whose paths end in .sv or .svh as SystemVerilog.

Celox follows IEEE Std 1800™-2023. Instead of restating the standard, the conformance and deviations page separates unsupported features, partially supported subsets (with Supported / Not supported tables), narrow limitations, and intentional deviations. Valid IEEE 1800-2023 code not listed there behaves as the standard specifies (an unlisted difference is a bug). Default mode accepts several warn-by-default compatibility relaxations; in strict mode (strict = true / --strict), accepting unlisted non-IEEE 1800-2023 code is also a bug.

Start with a module ​

Add Celox to your Rust project:

toml
[dependencies]
celox = "*"

Pass the source text and its path to Simulator::from_sv_sources, followed by the name of the top module:

rust
use celox::Simulator;
use std::path::Path;

let source = r#"
    module Counter(input logic clk, input logic rst, output logic [7:0] q);
        always_ff @(posedge clk) q <= rst ? 8'd0 : q + 8'd1;
    endmodule
"#;
let mut sim = Simulator::from_sv_sources(
    vec![(source, Path::new("counter.sv"))],
    "Counter",
)
.build()?;

let clk = sim.event("clk");
let rst = sim.signal("rst");
let q = sim.signal("q");
sim.modify(|io| io.set(rst, 1u8))?;
sim.tick(clk)?; // Reset the counter.
sim.modify(|io| io.set(rst, 0u8))?;
sim.tick(clk)?; // Count one rising edge.
assert_eq!(sim.get(q), 1u8.into());

Supply additional files in the same source list. Each file is a separate compilation unit; choose the top by its SystemVerilog module name.

Choose how to drive the design ​

What your test needsAPI
Set inputs, evaluate logic and advance clock events from RustSimulator::from_sv_sources
Advance simulation time, run timed processes and execute final proceduresSimulation::from_sv_sources
Include both Veryl and SystemVerilog sourcesSimulator::from_mixed_sources

Simulator::tick drives the rising edge of the selected event. Simulation tracks time and runs scheduled edges. A Simulator runs no process, so a design with timed processes, non-constant initial blocks, or final procedures needs Simulation; building a Simulator for one fails with SimulatorErrorKind::ProcessRequiresSimulation. See the execution model for exactly which processes need Simulation.

Use .four_state(true) on the builder when your test needs X/Z values. The 4-state guide explains the state model. For a mixed hierarchy, build the Simulation with Simulation::from_sources(veryl).with_sv_sources(sv).

Support overview and deviations ​

Unsupported constructs are rejected with an Unsupported error naming the construct and its tracking issue; nothing is silently ignored.

CategorySummaryReference
Not supportedcheckers, specify blocks, UDPs, disable (other than disable fork), wait_order, and unpacked/tagged unionsUnsupported features
Partially supportedSide-by-side Supported / Not supported tables for ports/ref ports/nets/defparam/gates, hierarchical references, interfaces, virtual interfaces, programs, clocking blocks, unpacked structs, procedural force/assign, delays, event controls, classes, randomization, dynamic containers, concurrent assertions, covergroups (coverpoints with automatic bins and the bins of values: arrays, default, ignore_bins, illegal_bins, wildcard, guards and with filters; crosses with binsof and intersect selections; options and the predefined methods of covergroups, coverpoints and crosses; clocking events, also of embedded covergroups; transition bins; covergroups of interfaces; without cross with selections), and I/OPartially supported features
Narrow limitationsSpecific restrictions such as non-ANSI port expressions, nonblocking assignments in always_comb/always_latch, and loop unrolling boundsNarrow limitations
Deviations (standard code)Deliberate differences on valid IEEE 1800-2023 code: program continuous assignment region, cross-module interface static storage, procedural assign override timing, run-time %p, and $exit warningsDeviations affecting standard code
Permissive non-standard acceptanceOptional/warn-by-default relaxations (strict = true / --strict promotes warnings to errors) plus non-standard extensions such as variable force selects and $psprintfPermissive non-standard acceptance

Mix SystemVerilog and Veryl ​

Either language may be the top, and a hierarchy may cross the boundary in both directions. Use Simulator::from_mixed_sources to supply both source lists. Veryl refers to an SV module as $sv::Module; SV uses a Veryl module's emitted name, such as prj_Module. Interfaces and input / output modports can also cross the boundary. See mixed-language designs.

DPI-C imports ​

Procedural code can call C functions. Register functions or shared libraries with dpi_function or dpi_library; these are unsafe APIs because the C signatures must match the SV imports. The celox run command links shared libraries with --dpi-lib PATH. See DPI-C imports for the supported types and call sites.

Read covergroup coverage ​

Simulation::coverage() and Simulator::coverage() return the coverage of the design's covergroups, and coverage() of a TypeScript Simulation returns the same report as an object. celox run --coverage-report FILE writes it to FILE as JSON when the run ends, also when the run fails. A run that does not start, such as one that fails to compile, writes none and leaves an existing FILE, an earlier run's report, as it was:

sh
celox run tb.sv --top tb --coverage-report coverage.json

See Coverage for what the report contains and the CLI guide for the option.

Find a specific behavior ​

SystemVerilog emitted by Veryl ​

The Veryl conformance suite also checks the SystemVerilog emitted by Veryl. Some cases cannot be emitted or have different language semantics; see the remaining exclusions.