Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tools/hdl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def _hdl_unit_impl(ctx: AnalysisContext) -> list[Provider]:
cmd.add("--output", out_run_py.as_output())
if ctx.attrs.simulator:
cmd.add("--simulator", ctx.attrs.simulator)
if ctx.attrs.rust_cosim:
cmd.add("--rust-cosim", ctx.attrs.rust_cosim)
ctx.actions.run(cmd, category="vunit")

# Left here as an example of how to put the vunit_out
Expand Down Expand Up @@ -225,6 +227,11 @@ vhdl_unit = rule(
doc="nvc or ghdl",
default="nvc",
),
"rust_cosim": attrs.option(
attrs.string(),
doc="Path to Rust cosim library (sets both GPI_USERS env var and NVC --load flag)",
default=None,
),
"_toolchain": attrs.toolchain_dep(
doc="Use system python toolchain for running VUnit",
default="toolchains//:python",
Expand Down Expand Up @@ -266,4 +273,4 @@ def third_party(**kwargs):
# are dropped from synthesis and simulation outputs
def black_box(**kwargs):
kwargs.update({"is_black_box": True})
vhdl_unit(**kwargs)
vhdl_unit(**kwargs)
12 changes: 10 additions & 2 deletions tools/vunit_gen/templates/run_py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ vu.add_verification_components()
vu.set_sim_option("disable_ieee_warnings", True)
{% if simulator == "nvc" %}
# Dump arrays of records, may have a perf penalty
vu.set_sim_option("nvc.sim_flags", ["--dump-arrays"])
nvc_sim_flags = ["--dump-arrays"]
{% if rust_cosim %}
# Load Rust cosimulation library
nvc_sim_flags.append("--load")
nvc_sim_flags.append("{{rust_cosim}}")
# Set GPI_USERS environment variable for Rust cosimulation
os.environ["GPI_USERS"] = "{{rust_cosim}}"
{% endif %}
vu.set_sim_option("nvc.sim_flags", nvc_sim_flags)
vu.set_sim_option("nvc.global_flags", ["--ignore-time"])
{% endif %}
# Run vunit function
vu.main()
vu.main()
2 changes: 2 additions & 0 deletions tools/vunit_gen/vunit_gen_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
parser.add_argument("--output", dest="output", help="Explicit output list")
parser.add_argument("--simulator", dest="simulator", default="", help="specify simulator name (ghdl or nvc)")
parser.add_argument("--rust-cosim", dest="rust_cosim", default="", help="Path to Rust cosim library")

args = parser.parse_args()

Expand Down Expand Up @@ -72,6 +73,7 @@ def main():
simulator=args.simulator,
vhdl_standard=inputs.get("vhdl_std"),
codec_packages=[],
rust_cosim=args.rust_cosim,
# vunit_out=args.vunit_out,
)
with open(args.output, mode="w", encoding="utf-8") as message:
Expand Down