Announcing Veryl 0.23.0

The Veryl team has published a new release of Veryl, 0.23.0. Veryl is a new hardware description language as an alternate to SystemVerilog.

If you have a previous version of Veryl installed via verylup, you can get the latest version with:

$ verylup update

If you don't have it already, you can get verylup from release page.

Breaking Changes

Clock domains are inferred only for unannotated variables #3798

The rules of clock domain inference are changed as below.

DeclarationDomain
'aNamed domain 'a
'_Default domain, never inferred
Port without annotationDefault domain, never inferred
var / let / inst without annotationInferred from assignments, or the default domain if nothing infers it

Before this change, a port without annotation was inferred inside the module, while the parent still saw it in the default domain, so the crossing was not reported. Now an output port driven from a named domain must carry that annotation.

module ModuleA (
    i_clk: input  'a clock,
    i_d  : input  'a logic,
    o_d  : output 'a logic, // annotation is required
) {
    assign o_d = i_d;
}

A signal annotated with '_ and assigned from another domain is also a CDC error now. Remove the annotation to keep it inferred, or annotate the source domain.

Assigning a non-enum value to an enum is an error #3784

Like SystemVerilog, an enum variable is strongly typed. Assigning a non-enum value or a value of another enum type without an explicit cast is now reported as mismatch_type. Reading an enum into an integral type is still allowed.

package PackageA {
    enum EnumA: logic<2> {
        A,
        B,
    }
}

module ModuleB (
    i_a: input  logic<2>       ,
    o_b: output PackageA::EnumA,
    o_c: output PackageA::EnumA,
) {
    assign o_b = i_a;                    // error: mismatch_type
    assign o_c = i_a as PackageA::EnumA; // OK
}

Struct members with clock/reset must be the same kind #3695

A struct having a clock or reset member, including nested structs, must have all its members of the same kind. Mixing clock/reset and other types (e.g. clock and logic), or different kinds (e.g. clock and reset), is reported as the new mixed_clock_reset_struct_member error.

With this restriction, a bit select or a part select of such a struct keeps the clock/reset kind, so it can be connected to a clock/reset port without implicit_clock_conversion.

struct S {
    a: clock,
    b: clock,
}

var s: S;
inst u: Sub (i_clk: s[1]); // OK: `s[1]` is a clock

New Tool Features

Runtime arguments of veryl test #3717

veryl test takes --runtime-arg, so a test can choose values when it runs. NAME gives a flag and NAME=VALUE gives a value.

$ veryl test --runtime-arg VERBOSE --runtime-arg ROUNDS=4 --runtime-arg TESTNAME=random_test

A test module reads them through $tb::runtime_args.

var args: $tb::runtime_args;

initial {
    if args.exists("VERBOSE") == 1 { ... }
    rounds    = args.get_int("ROUNDS", 2);
    test_name = args.get_string("TESTNAME", "basic_test");
}

They are also passed to verification components, and to SystemVerilog simulators as plusargs.

Free running clock in native tests #3719

$tb::clock_gen advanced only while a process waited on it with clk.next(N). So when the end of a test was decided by a verification component, the test had to wait an arbitrary number of cycles fixed in advance.

The new clk.start() returns at once and keeps the clock running until the test ends by $finish(), a component's finish request, or a failure. clk.start(N) fails the test when the clock exceeds N cycles.

initial {
    tb.start("RegTest");
    clk.start();    // returns at once, and the clock keeps running
    rst.assert();
}                   // the clock does not stop here

Signal and modport references for component methods #3701 #3767

A method of a verification component can take a reference to a clock, a reset, a signal or a modport. The component uses the reference like a connected port, so a testbench can choose at run time which signals a component watches or drives.

initial {
    c.watch(clk);     // clock: fires `on_clock`
    c.reset_by(rst);  // reset: fires `on_reset`
    c.probe(dut.x);   // input: reads a variable, also inside the design
    c.drive(y);       // output: the component drives `y`
    c.attach(bus.tb); // modport of any interface
}

Exporting packages and interfaces to Rust #3772

A package or an interface marked #[export] can be used as Rust types in verification components. Constants, type aliases, enums, packed structs and modports are exported, and the crates using them are listed in [[exports]] of Veryl.toml.

#[export]
package bus_pkg {
    enum Mode: logic<2> {
        Idle = 1,
        Busy = 2,
    }
    struct BusConfig {
        mode: Mode    ,
        regs: logic<8>,
    }
}

#[export]
interface bus_if {
    var valid: logic;
    var ready: logic;
    modport master {
        valid: output,
        ready: input ,
    }
}
veryl_component::import!(bus_pkg);
veryl_component::import!(bus_if, use(bus_pkg = crate::bus_pkg));

let mut bus = bus_if::Master::bind(&modport_ref)?;
bus.load(ctx)?;
bus.valid = true;
bus.store(ctx);

Sharing compiled code across instances #3761

Modules listed in shared_modules of the [test] section share one schedule and one compiled code across their instances in the native simulator. This reduces the build time of a design that instantiates a large module many times, such as a multi-core SoC. The boundary between the instances and their parent costs some run time.

[test]
shared_modules = ["core"]

Bounded AOT-C cache #3763

The cache of compiled simulation code no longer keeps the generated C sources, and entries left unused for a week are removed. The retention can be changed by the VERYL_AOT_C_RETAIN_DAYS environment variable, and 0 keeps everything.

JSON output of veryl check #3732

veryl check --format json prints the diagnostics as JSON, with the code, severity, message, location and documentation link of each one. It is useful for AI coding agents and other tools.

--agent option of veryl new and veryl init #3733

veryl new --agent and veryl init --agent create AGENTS.md, a guide for AI coding agents that describes the project layout and the development loop of Veryl.

New Standard Library

Arbiter #3743

$std::arbiter grants one of the requests by round robin or fixed priority. It supports onehot or binary grant, keeping the grant until it is released, per-request priority, and weighted round robin. $std::round_robin_arbiter and $std::fixed_priority_arbiter can also be used directly.

Leading zero counter function #3667

$std::lzc is a function that counts the consecutive zero bits from the MSB or the LSB. The MSB of the result is set when all bits are zero, and the remaining bits hold the count.

assign o_result = $std::lzc::<8>(i_d, true); // count from the MSB

Other Changes

Check out everything that changed in Release v0.23.0.