Skip to content

Verilator

Useful Links

Initialisation

To use verilator, load the verilator package in your script, you can choose to use either a local binary provided by KISSB, or the docker image provided by verilator:

  • To use the local version

    package require kissb.eda.verilator
    verilator.init.local VERSION
    

    Warning

    Using verilator via local binary requires installing g++ and ccach on your host - the init command will check for their availability.

  • To use the docker version

    package require kissb.eda.verilator
    verilator.init.docker VERSION
    

To set the version, replace "vVERSION" by the desired version. For example 5.040 for version v5.040:

package require kissb.eda.verilator

# For example:
verilator.init.local 5.040

# To use the official verilator docker image
verilator.init.docker 5.040

Two Step verilator usage

1. Compilation

After initialisation, first you must compile your design using the verilator verilate command:

# For example to compile a counter design with a simple testbench
verilator.verilate --binary counter.sv counter_tb.sv
// A very simple counter to demonstrate simulator usage
module counter(
    input wire clk,
    input wire resn,
    output reg [3:0] value
);

    always @(posedge clk) begin
        if (!resn) begin
            value <= 4'h0;
        end
        else begin
            value <= value + 4'd1;
        end

    end

endmodule
/**
A very simple testbenck to demonstrate simulating the counter
*/
module counter_tb;

    logic resn;
    logic clk;

    always begin
        #10ns clk <= ! clk;
    end

    initial begin
        $dumpfile("waves.fst");
        $dumpvars();
        resn = 0;
        clk = 0;
        @(posedge clk);
        @(posedge clk);
        resn=1;

        repeat(10) begin
            @(posedge clk);
        end

        #5000 $finish();
    end

    counter dut(
        .clk(clk),
        .resn(resn),
        .value()
    );
endmodule

This command accepts the same arguments as the Verilator verilate command, see https://verilator.org/guide/latest/verilating.html

To enable waveform tracing, and add support for GtkWage fst file format, add the following arguments:

# For example to compile a counter design with a simple testbench
verilator.verilate --binary --trace --trace-fst counter.sv counter_tb.sv

2. Running

After verilating, you can run your compiled design directly as executable, but best is to use the verilator.simulate command which will execute the binary from your host or via the docker image depending on how you loaded the package.

# Run
verilator.simulate Vcounter_tb

Single Step Usage

To ease usage, users can use the verilator.vrun command, which will compile and run the design in one pass.

Pre-Build Binaries

Version System URL
GIT master linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-master.zip
GIT stable linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-stable.zip
v5.040 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.040.zip
v5.038 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.038.zip
v5.036 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.036.zip
v5.034 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.034.zip
v5.032 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.032.zip
v5.030 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.030.zip
v5.028 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.028.zip
v5.026 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.026.zip
v5.024 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.024.zip
v5.022 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.022.zip
v5.020 linux https://kissb.s3.de.io.cloud.ovh.net/hdl/verilator/verilator-v5.020.zip

Verilator Package Variables

Before or after Loading the flow, you can set configuration variables:

package require kissb.eda.verilator

vars.set CONFIGURATION VALUE
Variable Description Default Value Env. Override
verilator.version default verilator version 5.040 VERILATOR_VERSION
verilator.runtime local VERILATOR_RUNTIME
verilator.lint.args --no-decoration VERILATOR_LINT_ARGS
verilator.verilate.args VERILATOR_VERILATE_ARGS

Verilator Commands Reference

verilator.coverage.enable

verilator.coverage.enable ?args?

Parameters

verilator.coverage.toInfo

verilator.coverage.toInfo coverageDat coverageInfo

Parameters

coverageDat Not documented.
coverageInfo Not documented.

verilator.image.run

verilator.image.run script

Parameters

script Not documented.

verilator.init

verilator.init ?args?

Parameters

verilator.init.docker

verilator.init.docker version

Parameters

version Not documented.

verilator.init.local

verilator.init.local version

Parameters

version Not documented.

verilator.isDockerRuntime

verilator.isDockerRuntime ?args?

Parameters

verilator.lint

Run linter

verilator.lint ?args?

Parameters

verilator.root

verilator.root path

Parameters

path Not documented.

verilator.runtime.docker

verilator.runtime.docker ?args?

Parameters

verilator.runtime.local

verilator.runtime.local ?args?

Parameters

verilator.simulate

Run simulation from exe located in obj_dir

verilator.simulate name ?args?

Parameters

name Not documented.

verilator.verilate

verilator.verilate ?args?

Parameters

verilator.vrun

verilator.vrun top compileArgs simulateArgs

Parameters

top Not documented.
compileArgs Not documented.
simulateArgs Not documented.