rules_riviera

Bazel rules for Aldec Riviera-PRO, a mixed-language (Verilog / SystemVerilog / VHDL) HDL simulator.

The public surface is three rules:

  • riviera_library — compile a verilog_library / vhdl_library DAG into ONE self-contained Riviera library.
  • riviera_sim_test — vmap one or more riviera_library deps, elaborate a top, and simulate under vsimsa as a Bazel test.
  • riviera_toolchain — bind the Riviera executables to the toolchain type the rules resolve. See its generated reference for the full attr list.

Everything else — coverage collection under bazel coverage, //tools/acdb2lcov for ACDB -> lcov conversion — is designed around those rules.

Setup

Riviera-PRO is a commercial simulator; this repo does not distribute it. rules_riviera provides the Bazel rules and the toolchain type contract — how Riviera actually reaches your Bazel actions is deployment infrastructure and lives entirely in your own repo.

MODULE.bazel

bazel_dep(name = "rules_riviera", version = "0.0.1")

register_toolchains("//tools/riviera:my_riviera_toolchain")

Author a toolchain

vsimsa is the only mandatory attr: it is the one binary the rules invoke across the Bazel action boundary, from both riviera_library's compile action and riviera_sim_test at test time. Every other tool attr (acdb included — its coverage reports are generated by an acdb report TCL command inside that same vsimsa invocation) defaults to a PATH-resolving shim.

Bind it to anything Bazel can exec. The ideal is a hermetic toolchain that vendors the install into the action graph; how that install is provisioned is up to you. A wrapper's own data deps reach the action — the toolchain carries each tool's runfiles, not just its executable.

# tools/riviera/BUILD.bazel
load("@rules_riviera//riviera:riviera_toolchain.bzl", "riviera_toolchain")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

# Simplest possible binding: resolve vsimsa from PATH. Appropriate when
# actions already run inside an image with Riviera installed. Swap in an
# absolute install path, or a wrapper that sources a license env file.
sh_binary(
    name = "vsimsa",
    srcs = ["vsimsa.sh"],   # #!/bin/sh + `exec vsimsa "$@"`
)

riviera_toolchain(
    name = "my_riviera_toolchain_def",
    vsimsa = ":vsimsa",
    requires_network = True,   # set True when the license server is remote
    version = "2025.04",
)

toolchain(
    name = "my_riviera_toolchain",
    toolchain = ":my_riviera_toolchain_def",
    toolchain_type = "@rules_riviera//riviera:toolchain_type",
)

A complete, buildable version of this lives in examples/simple.