cocotb_riviera_sim

Rules

cocotb_riviera_sim

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

cocotb_riviera_sim(name, coverage_args, coverage_data_glob, coverage_tool, env, vsimsa)

A simulator configuration for running Aldec Riviera-PRO simulations in cocotb tests.

Status

Infrastructure only. Riviera-PRO is commercial, with no BCR module and no redistributable binary; rules_cocotb cannot validate this rule in CI. Wire it up downstream by pointing the binary attrs at your own install and registering a cocotb_toolchain that routes sim = "riviera" through this rule. Cocotb's runner handles the actual build/sim via Runner.build / Runner.test.

Downstream wiring

Expose vsimsa to Bazel and register a custom cocotb_toolchain. vsimsa is the only binary cocotb's Riviera runner invokes; the rest of the Aldec install (alib/alog/acom/asim engines, libraries, license config) is loaded internally by vsimsa through $RIVIERA_HOME. Pull those into the action sandbox by attaching them as data on the vsimsa target — anything reachable through its runfiles will be staged alongside the binary.

Typically this means a local repository (e.g. new_local_repository or a custom repository rule pointed at $RIVIERA_HOME) whose BUILD.bazel wraps vsimsa as a native_binary (or sh_binary) target with the rest of the install as its data deps, then:

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

cocotb_riviera_sim(
    name = "cocotb_riviera",
    vsimsa = "@riviera//:vsimsa",
)

cocotb_toolchain(
    name = "my_cocotb_toolchain",
    cocotb = "//path/to:cocotb_py_library",
    simulators = {":cocotb_riviera": "riviera"},
)

Then register_toolchains("//path/to:my_cocotb_toolchain") in MODULE.bazel (ahead of the default //cocotb/toolchain registration) and cocotb_test(sim = "riviera", ...) will resolve through it.

Riviera-PRO accepts both Verilog/SystemVerilog (VerilogInfo) and VHDL (VhdlInfo) modules.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
coverage_argsTemplate fragments forwarded to coverage_tool after the cocotb runner exits under bazel coverage. {output} is substituted with $COVERAGE_OUTPUT_FILE; {data_files} is expanded into one positional arg per file matched by coverage_data_glob. Only meaningful when coverage_tool is set.List of stringsoptional[]
coverage_data_globShell glob (relative to the cocotb sim's build dir) selecting the raw coverage data files coverage_tool consumes. For Riviera-PRO, **/coverage.acdb matches every per-test ACDB the run produces. Only meaningful when coverage_tool is set.Stringoptional""
coverage_toolOptional Riviera coverage post-processor. When set AND the test's HDL module is exercised under bazel coverage (via ctx.coverage_instrumented(module)), the rules_cocotb process wrapper invokes this binary after the cocotb runner exits with the coverage_args template (substituting {output} and {data_files}) so it can translate the raw ACDBs into lcov at $COVERAGE_OUTPUT_FILE. Leave unset to ship raw ACDBs under the test outputs dir without an lcov roll-up.LabeloptionalNone
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{}
vsimsaThe vsimsa standalone batch simulator binary. Cocotb's Riviera runner invokes only vsimsa; the rest of the Aldec install (alib/alog/acom/asim engines, libraries, license config) is loaded internally by vsimsa via $RIVIERA_HOME. Attach those install files as data deps on the target you pass here so they're staged alongside the binary.Labelrequired