Verification components in Rust

A heads-up ahead of the release: verification components are a major new feature, not in a stable release yet but arriving in the next version, due in early August. Everything below already works on the nightly toolchain.

Veryl's native test lets you write testbenches directly in Veryl, driven by the built-in simulator, with $tb::clock_gen, $tb::reset_gen, $assert, and $finish. You can now bring your own verification components written in Rust, such as a bus functional model, a protocol checker, or a golden model, all driven by the same simulator under the $comp namespace.

A component is ordinary Rust, so a verification model can lean on the language and its libraries instead of SystemVerilog boilerplate or hand-written DPI-C glue. A golden model, for instance, can be a handful of lines or a full instruction-set simulator, checked against the RTL as the test runs.

Here is a checker that watches a request/acknowledge handshake. In a native test it is instantiated like any module:

#[test(test_req_ack)]
module test_req_ack {
    inst clk: $tb::clock_gen;
    inst rst: $tb::reset_gen ( clk );

    var req: logic;
    var ack: logic;

    inst dut: Peripheral ( clk, rst, req, ack );

    inst chk: $comp::req_ack_checker ( clk, req, ack );

    initial {
        rst.assert();
        req = 1;
        clk.next(16);
        $finish();
    }
}

Its behavior is a plain struct and impl block that reads as idiomatic Rust, with fields for the ports and an on_clock hook that runs every cycle (implementation elided):

#[derive(Component)]
pub struct ReqAckChecker {
    clk: ClockPort,
    req: InputPort,
    ack: InputPort,
}

#[component_impl]
impl ReqAckChecker {
    fn on_clock(&mut self, ctx: &mut SimCtx) -> Result<()> {
        // check that `ack` follows `req` each cycle
        // ...
    }
}

For something closer to real use, veryl-lang/vip is a set of AXI verification components — masters, memory models, and checkers for AXI4-Lite, AXI4-Stream, AXI4, and AXI3 — all built this way.

What you can do

Getting started

You can try them now on the nightly toolchain with verylup install nightly. The language reference covers the details, from the component API to distribution: Writing a Component and Using a Component.