Skip to content

aionhw/xezim

Repository files navigation

xezim — SystemVerilog Simulator (Rust)

xezim is a SystemVerilog simulator written in Rust designed for experimentation, learning, and exploring AI-assisted chip design workflows.

xezim was previously developed under the name sisSIM. The binary, library, and compiled-artifact magic were renamed in place; behavior is unchanged.

This project explores whether modern tools and AI can dramatically reduce the complexity of building core EDA infrastructure such as simulators.

The simulator parses SystemVerilog source code, builds an internal representation, and executes simulations for combinational and sequential logic.


Motivation

Traditional EDA tools require very large engineering teams and many years of development.

This project explores a key question:

Can a small team — or even a single engineer with AI assistance — build core EDA tools such as a SystemVerilog simulator?

The simulator is being developed incrementally, starting from simple combinational logic and gradually adding more SystemVerilog features.


Features

Current capabilities include:

  • IEEE 1800-2023 grammar by default (--sv2017 opts back to the earlier edition)
  • SystemVerilog module parsing
  • Signal and net representation
  • Continuous assignments
  • Basic expression evaluation
  • Combinational logic simulation
  • Sequential simulation infrastructure
  • Test execution framework
  • Waveform / trace dumps — VCD ($dumpfile/$dumpvars), XTrace v1.0 (--xtrace, optional zstd compression + scope filtering), and AITRACE-T (--aitrace)
  • UVM 1.2 runtime support with -DUVM_NO_DPI, demonstrated by running the riscv-dv instruction generator end-to-end (random RV32IMC programs that assemble cleanly with riscv64-unknown-elf-as -march=rv32imc_zicsr_zifencei)
  • Event-driven edge gating (XEZIM_EVENT_EDGE=1) — opt-in skip of clocked flop fires whose data inputs haven't changed; 1.13-1.30× wall on the C910 / C906 hello / memcpy / cmark benchmarks, correct-by-construction

Project Structure

xezim is split across two repos; xezim-core is vendored here as a submodule:

xezim-core/   — shared library: parser, elaboration, value, SDF, VCD sink (submodule)
./            — bytecode interpreter + simulator (this repo, binary: xezim)

This repo:

.
├── src/
│   ├── compiler/
│   │   ├── simulator.rs   — event-driven simulator + bytecode VM
│   │   ├── bytecode.rs    — bytecode compiler for cont_assigns and always blocks
│   │   └── mod.rs         — re-exports value/elaborate/sdf from xezim-core
│   ├── lib.rs             — wraps xezim_core::parse_and_elaborate_multi + Simulator
│   └── main.rs            — CLI entry point (binary: xezim)
├── tests/                 — Rust integration tests + SV compliance suite
├── examples/
└── Cargo.toml             — depends on xezim-core (path = xezim-core, a submodule)

Components

Parser & elaboration — live in xezim-core; consumed by both xezim and xezim-b.

Simulator — event-driven VM over a bytecode lowering of cont_assigns and always blocks.

Native compiler (xezim-b) — AOT-lowers an elaborated design to Rust and links a standalone binary.


Verified Workloads

End-to-end TEST PASSED with bit-identical results vs the workloads' own golden expectations:

Design Test sim_time / cycles baseline wall +O1 wall
XuanTie C910 (dual-core) hello sim_time 44695 95s 73s (1.30×)
XuanTie C910 memcpy ×7000 sim_time 101965 216s 166s (1.30×)
XuanTie C910 cmark ×1 (+iterations=1, INIT_ZERO=1) 167124 cycles 87 min 73 min (1.19×)
XuanTie C906 (single-core) memcpy ×50 99s 88s (1.13×)
XuanTie C906 cmark ×1 (INIT_ZERO=1) 295294 cycles 714s 587s (1.22×)
riscv-dv (UVM 1.2) +num_of_tests=10 random RV32IMC 10/10 assemble clean

Test Suite

Many test cases are included to validate functionality.

Credit: All pr*.v tests were taken from the Icarus Verilog test suite.

These tests help verify correctness against real-world Verilog/SystemVerilog edge cases.


Build

Install Rust: https://www.rust-lang.org/tools/install

xezim-core is vendored as a git submodule under this repo (xezim-core/, referenced by path = "xezim-core"), so clone recursively:

git clone --recursive git@github.com:<you>/xezim.git
cd xezim
# (if already cloned non-recursively: git submodule update --init)

Build the simulator:

cargo build            # debug
cargo build --release  # optimized (recommended for large designs)

The release binary is produced at target/release/xezim.


Run

Run a simple example via cargo:

cargo run --release -- examples/test.sv

Or invoke the binary directly:

./target/release/xezim <source_files> [+plusargs] [options]

Common options:

Option Purpose
-D<MACRO>[=val] Define a preprocessor macro
-I<dir> Add an include directory
--top <module> Select the top-level module
--max-time <N> Stop simulation at time N
+trace, +<plusarg> Passed through to $value$plusargs / $test$plusargs
--sdf <file> --sdf-{min,typ,max} Annotate standard delays
--sim_debug Print [DEBUG] / [OPT] diagnostics
--log <file> Redirect stdout/stderr to a log file
--xtrace <file> Emit an XTrace v1.0 dump (.zst/.zstd ⇒ zstd-compressed)
--xtrace-scope <hier> Restrict the XTrace dump to signals under <hier> (repeatable)
--aitrace Make $dumpfile/$dumpvars emit AITRACE-T text instead of VCD

Selected env knobs (off by default unless noted):

Env var Effect
XEZIM_EVENT_EDGE=1 Skip gateable clocked flop fires whose data is unchanged (1.13-1.30× wall on c910/c906)
XEZIM_INIT_ZERO=1 Coerce X-initialized signals/arrays to 0 (required for some C910/C906 workloads, e.g. cmark)
XEZIM_PROGRESS=N Emit a [PROGRESS] line every N wall-seconds (sim_time, iters, edges_fired, nba_q)

Example — run the picorv32 testbench against a gate-level netlist:

./target/release/xezim testbench.v synth.v \
    +firmware=firmware/firmware.hex --max-time 50000000

Development Workflow

Typical development loop:

edit code
↓
cargo build
↓
run tests
↓
add new SystemVerilog features

Rust provides strong guarantees for memory safety and concurrency, making it well suited for building large-scale EDA infrastructure.


Long-Term Vision

This project explores several long-term ideas:

  • AI-assisted EDA development
  • Rapid simulator prototyping
  • Cloud-scale simulation
  • Distributed multi-CPU simulation

The goal is to investigate whether modern software and AI tools can dramatically accelerate the creation of chip design infrastructure.


License

Apache License 2.0

See the LICENSE file for details.


Acknowledgements

  • Icarus Verilog project for the public test suite
  • The Rust community
  • Open-source EDA projects

About

SystemVerilog (IEEE 1800-2017) Simulator

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors