cocotb_nvc_sim

Rules

cocotb_nvc_sim

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

cocotb_nvc_sim(name, env, nvc, nvc_libpath, vhdl_libs)

A simulator configuration for running NVC (open-source VHDL simulator) in cocotb tests.

Status

Working against the BCR nvc module from version 1.21.0 onward, which links the nvc binary with -Wl,--dynamic-list=src/symbols.txt so cocotb's libcocotbvpi_nvc.so plugin can resolve unprefixed vpi_* / vhpi_* symbols at dlopen time.

Notes

NVC only supports VHDL (VhdlInfo); pair it with a vhdl_library target as the module. The integration is build-at-test-time: cocotb's runner runs nvc -a / -e / -r in a writable build_dir via Runner.build() / Runner.test().

vhdl_libs accepts a list of per-library TreeArtifact targets — typically ["@nvc//:vhdl_libs"], the BCR nvc module's filegroup of per-library directories laid out exactly like a system install under <prefix>/lib/nvc/<library>/. The rule's implementation stages those TreeArtifacts side-by-side under a single root and points NVC_LIBPATH at it so nvc finds every shipped library (STD, IEEE, NVC, plus the SYNOPSYS / VITAL extras inside IEEE) at simulation time.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
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{}
nvcThe nvc simulator binary.Labelrequired
nvc_libpathLiteral value to set as NVC_LIBPATH at simulation time. Use this for nvc installs where the prefix is a stable absolute path on disk — typically a system / .deb / Homebrew install (e.g. "/usr/local/lib/nvc").

When unset (default), NVC_LIBPATH is auto-derived from vhdl_libs if it's populated (per-library TreeArtifacts staged into one root by this rule), otherwise left unset so nvc falls back to its own compiled-in search paths.
Stringoptional""
vhdl_libsPer-library TreeArtifact targets to stage side-by-side under a single NVC_LIBPATH root. Typically ["@nvc//:vhdl_libs"] — the BCR nvc module's filegroup of per-library directories. Empty (the default) leaves NVC_LIBPATH unset.List of labelsoptional[]