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
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | Additional CcInfo-providing dependencies to link into the verilator executable (e.g. @verilator//:verilated and your project's C++ shims). | List of labels | optional | [] |
| cocotb | The cocotb pip package (a py_library wrapping @cocotb_pip_deps//cocotb). Used to extract verilator.cpp and the cocotb VPI shared libraries. | Label | required | |
| copy_tree | A tool for copying a tree of files. Defaults to the rules_verilator helper. | Label | optional | "@rules_verilator//verilator/private:verilator_copy_tree" |
| env | Environment 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 -> String | optional | {} |
| process_wrapper | A process wrapper for verilator. Defaults to the rules_verilator helper. | Label | optional | "@rules_verilator//verilator/private:verilator_process_wrapper" |
| verilator | The Verilator binary to use (e.g. @verilator//:verilator_executable). | Label | required | |
| verilator_coverage | verilator_coverage_bin — invoked at test time under bazel coverage to translate coverage.dat into lcov. | Label | optional | "@verilator//:verilator_coverage_executable" |