vunit_ghdl_sim
Rules
vunit_ghdl_sim
load("@rules_vunit//vunit:vunit_ghdl_sim.bzl", "vunit_ghdl_sim")
vunit_ghdl_sim(name, env, ghdl, ghdl_prefix, vhdl_libs)
A simulator configuration for running GHDL simulations in VUnit tests.
Status
Working against the BCR ghdl module from version 6.0.0.bcr.1 onward.
The backend is selectable with --@ghdl//:backend={mcode, llvm-jit}
(default mcode on x86_64, llvm-jit elsewhere).
Notes
GHDL only supports VHDL (VhdlInfo); pair it with vhdl_library targets
in the libraries map of vunit_test. VUnit drives ghdl directly via
its vu.main() at test time using sources surfaced through runfiles.
The vhdl_libs attribute should point at the pre-compiled IEEE/std
libraries from the BCR ghdl module — most projects want
["@ghdl//:vhdl_libs_v08"].
Coverage
GHDL only emits coverage when built with the gcc backend; the BCR
ghdl module ships only mcode and llvm-jit, neither of which
support it. Wiring up coverage flags here would be a no-op (or
runtime error) against a stock BCR build, so this rule omits the
sim-side coverage path. The generic VUnitSimInfo.coverage field
remains available for downstream toolchains that point
vunit_ghdl_sim(ghdl = ...) at a GHDL+gcc binary and want to thread
gcov output through bazel coverage.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| env | Environment variables to set when the vunit runner invokes this simulator at test time (license-server pointers, install root vars, …). Precedence: toolchain env < sim env < rule-level vunit_test(env = ...). | Dictionary: String -> String | optional | {} |
| ghdl | The ghdl binary. | Label | required | |
| ghdl_prefix | Literal value to set as GHDL_PREFIX at simulation time. Use this for ghdl installs where the prefix is a stable absolute path on disk — typically a system/.deb/Homebrew install (e.g. "/usr/lib/ghdl").When unset (default), GHDL_PREFIX is auto-derived from vhdl_libs if it's populated (BCR-shaped layout), otherwise left unset so ghdl falls back to its own compiled-in search paths. | String | optional | "" |
| vhdl_libs | Pre-compiled VHDL standard libraries (e.g. @ghdl//:vhdl_libs_v08). Assumes the BCR ghdl module's layout — <root>/{std,ieee}/v<XX>/<name>-objXX.cf — from which GHDL_PREFIX is derived. If you ship ghdl differently and the IEEE/std libs are already discoverable by the binary, leave this empty and (optionally) set ghdl_prefix to a literal path, or skip both for a system install that uses its compiled-in defaults. | List of labels | optional | [] |