cocotb_verilator_sim

Rules

cocotb_verilator_sim

load("@rules_cocotb//cocotb:cocotb_verilator_sim.bzl", "cocotb_verilator_sim")

cocotb_verilator_sim(name, deps, cocotb, copy_tree, env, process_wrapper, verilator,
                     verilator_coverage)

A simulator configuration for compiling Verilator binaries to be run in cocotb tests.

Status

Fully functional. Sourced from the verilator and rules_verilator BCR modules; the default toolchain wires @verilator//:verilator_executable together with cocotb's share/lib/verilator/verilator.cpp entrypoint. Used by the in-tree adder_test smoke test, which passes end-to-end.

Notes

Verilator only supports Verilog/SystemVerilog (VerilogInfo); pair it with a verilog_library target as the module. The sim_opts attribute on cocotb_test is forwarded to the underlying verilator invocation — e.g. sim_opts = ["--trace-fst"] enables FST waveform capture.

The BCR verilator binary needs the rules_verilator process wrapper to set up its include / lib paths, and cocotb's verilator.cpp front-end plus its VPI shared libraries to link against. The rule locates those inside the cocotb pip wheel automatically — point cocotb at any py_library wrapping @cocotb_pip_deps//cocotb and the rule extracts what it needs internally.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsAdditional CcInfo-providing dependencies to link into the verilator executable (e.g. @verilator//:verilated and your project's C++ shims).List of labelsoptional[]
cocotbThe cocotb pip package (a py_library wrapping @cocotb_pip_deps//cocotb). Used to extract verilator.cpp and the cocotb VPI shared libraries.Labelrequired
copy_treeA tool for copying a tree of files. Defaults to the rules_verilator helper.Labeloptional"@rules_verilator//verilator/private:verilator_copy_tree"
envEnvironment variables to set when the cocotb runner invokes this simulator at test time (license-server pointers, install root vars, …). Precedence: toolchain env < sim env < rule-level cocotb_test(env = ...).Dictionary: String -> Stringoptional{}
process_wrapperA process wrapper for verilator. Defaults to the rules_verilator helper.Labeloptional"@rules_verilator//verilator/private:verilator_process_wrapper"
verilatorThe Verilator binary to use (e.g. @verilator//:verilator_executable).Labelrequired
verilator_coverageverilator_coverage_bin — invoked at test time under bazel coverage to translate coverage.dat into lcov.Labeloptional"@verilator//:verilator_coverage_executable"