Simulator Backends & CI/CD Strategy
This document outlines the supported simulator backends in RouteRTL, their licensing implications, and strategies for CI/CD integration.
1. Supported Simulators
RouteRTL uses Cocotb as its testbench framework, which supports various simulators via standard interfaces (VPI, VHPI, FLI).
| Simulator | Backend Type | License | CI/CD Suitability | Status in RouteRTL |
|---|---|---|---|---|
| GHDL | ghdl_backend.py | Open Source (GPL) | Excellent (Free, Docker-friendly) | ✅ Fully Supported |
| NVC | nvc_backend.py | Open Source (GPL) | Excellent (Fast, VHDL-2008) | ✅ Fully Supported (v1.19.3+) |
| Riviera-PRO | riviera_backend.py | Commercial (Aldec) | Low (Requires License Server) | 🚧 Planned (Optional) |
| Verilator | verilator_backend.py | Open Source (LGPL) | Excellent (Fast, Verilog only) | ✅ Fully Supported |
| Icarus Verilog | icarus_backend.py | Open Source (GPL-2) | Excellent (Free, Docker-friendly, Verilog) | ✅ Fully Supported |
GHDL code coverage
The normal LLVM/mcode GHDL remains the fast lint and simulation default. Statement and branch coverage require GHDL's GCC backend:
rr eda install ghdl-gcc rr sim run test_my_dut
The installer builds an isolated toolchain under
~/.local/opt/ghdl-gcc, exposes it as ghdl-gcc, and does not replace the
normal ghdl. When a project requests coverage, RouteRTL automatically
selects that executable, instruments the analysis/elaboration with GCC profile
flags, runs gcov, and writes the usual additive coverage.json. Without
ghdl-gcc, the run remains a visible backend_unsupported result; it never
claims unmeasured coverage.
The GCC build is deliberately opt-in because it compiles a GCC/VHDL toolchain and is substantially heavier than the normal GHDL install. See the upstream GCC-backend build requirements.
2. Adding a New Backend
To add support for a new simulator (e.g., Riviera-PRO), implement a backend class in sim/cocotb/engine/backends/ (relative to SDK root).
Implementation Pattern
- Backend Class: Create
riviera_backend.pyinheriting fromSimulatorBackend. - Compilation: Implement
compile()using the vendor's tools (e.g.,vlib,vcom). - Elaboration/Run: Implement
simulate()to invoke the simulator with Cocotb's VPI hooks. - Auto-Detection: Update
sim_engine.pyto detect the simulator executable and register the backend.
# Example Pattern
class RivieraBackend(SimulatorBackend):
def compile(self):
self.exec("vlib", "work")
self.exec("vcom", "-work", "work", *self.sources)
def simulate(self):
# Cocotb requires specific VPI lib arguments
self.exec("vsim", "-c", "-do", "run -all", ...)
3. CI/CD Strategy
Open Source Simulators (GHDL, NVC, Icarus Verilog)
- Default Choice: These should be the default for all CI pipelines.
- Installation: We recommend installing NVC via the upstream
.debpackage (v1.19.3+) to avoid building from source. See the NVC Releases page. - Cost: Free.
Detached NVC runs
By default, rr sim run owns the NVC process lifecycle: it installs a parent-death SIGKILL backstop and reaps the simulator process group when rr exits. This is intentional orphan protection. A long NVC run launched in the background from a short-lived shell wrapper will therefore die when the launcher exits.
Use rr sim run --detach or RR_SIM_DETACH=1 only when the sim must survive the launcher. In detached mode, rr uses a transient systemd-run --user --scope when available and otherwise warns before falling back to a no-PDEATHSIG/no-reap launch.
NVC foreign C / VHPIDIRECT libraries
Encrypted vendor secureip cannot be elaborated by an open simulator. When the
vendor supplies a bit-accurate C model, bind that model behind a VHDL
VHPIDIRECT shim and declare the shim in project.yml:
simulation:
simulator: nvc
foreign_libraries:
- name: vendor_bitacc
sources:
- sim/vendor_bitacc_shim.c
include_dirs:
- vendor/cmodel/include
link_libraries:
- vendor/cmodel/lib/libvendor_model.so
Each entry declares name and exactly one of:
path: a prebuilt.so.sources: C source files RouteRTL compiles as a position-independent shared library. Optionalinclude_dirs,link_libraries,compile_args, andlink_argsare passed without a shell.
Compiled shims are content-addressed under the NVC simulation cache. RouteRTL
loads them in declaration order before the cocotb VHPI library. The descriptor
is re-read inside a queue-dispatched run, so inline and queued simulations use
the same shim build and load path; environment variables used in paths must be
declared with sim.pass_env when their values come from the submitting shell.
rr sim rejects a secureip reference before compilation under NVC/GHDL and
points to this bridge. It does not silently treat the encrypted library as
available and defer the failure to elaboration.
Commercial Simulators (Riviera-PRO, Questa, Vivado)
- Licensing: These require a valid license (floating or node-locked).
- Strategy:
- Conditional Execution: Only run these tests if the environment variable
ALDEC_LICENSE_FILE(or equivalent) is present. - Self-Hosted Runners: Use self-hosted runners that have VPN/LAN access to your license server.
- Manual Trigger: Configure CI to skip these tests by default and run them only on manual triggers or specific protected branches.
- Conditional Execution: Only run these tests if the environment variable
4. Recommendations for RouteRTL Users
- Primary Workflow: Develop and verify locally using GHDL, NVC, Verilator, or Icarus Verilog.
- Release Validation: If you have a commercial license (e.g., Vivado WebPACK or Enterprise), validating critical IP blocks on the commercial simulator before tape-out is recommended to catch backend-specific bugs.
- CI/CD: Stick to GHDL/NVC/Icarus/Verilator for pull requests to ensure fast, free feedback loops.