Skip to content

Vivado xsim DPI-C Rogue co-simulation orchestration#399

Merged
ruck314 merged 3 commits into
pre-releasefrom
cosim-xsim
Jul 8, 2026
Merged

Vivado xsim DPI-C Rogue co-simulation orchestration#399
ruck314 merged 3 commits into
pre-releasefrom
cosim-xsim

Conversation

@ruck314

@ruck314 ruck314 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the ruckus-side orchestration for the new Vivado xsim SystemVerilog DPI-C co-simulation backend, alongside the existing GHDL (VHPIDIRECT) and VCS (VHPI) paths. Pairs with the surf axi/simlink/xsim/ DPI backends for RogueTcpStream, RogueTcpMemory, and RogueSideBand, which link into one combined RogueTcpDpi.so (slaclab/surf#1452).

Additive only — the GHDL and VCS co-sim paths are unchanged.

Changes (vivado/)

DPI build & bind

  • run/pre/xsim.tcl (new): the xsim.compile.tcl.pre hook — detects the Rogue co-sim sources, builds the combined RogueTcpDpi.so via xsc, and stages it for the xsim run. Registered unconditionally by project.tcl; a fast no-op for non-Rogue projects. Lives under the standard run/pre/ hook directory.
  • sources.tcl: register the DPI shared library via xelab -sv_lib RogueTcpDpi at project generation (guarded on the xsim Rogue backend).
  • project.tcl: register the pre-compile hook and DPI / xsc project properties.
  • xsim.tcl: batch-path parity for the DPI .so (LD_LIBRARY_PATH, libstdc++ LD_PRELOAD, libzmq check).

Robustness / diagnostics

  • All three modules (RogueTcpStream / RogueTcpMemory / RogueSideBand) handled by one uniform flow.
  • Missing/old libzmq produces a clear diagnostic and hard-fail instead of a silent hang.
  • libstdc++ LD_PRELOAD resolves a libstdc++ new enough for the co-sim's libzmq dynamically (libzmq's prefix → active gcc → RHEL/Rocky and Debian system paths), prepending rather than clobbering LD_PRELOAD. This fixes the earlier hardcoded Debian-only path that silently no-op'd on RHEL/Rocky. (Vivado's loader injects its own older libstdc++ via LD_LIBRARY_PATH; LD_PRELOAD outranks it, so it is the robust override.)

Shared procs (vivado/proc/sim_management.tcl)

  • RogueSimSources {backend} — Rogue co-sim source detector, shared by the VCS and xsim flows.
  • RogueCheckLibZmq — the libzmq availability check.
  • RoguePreloadLibStdCpp — the libstdc++ LD_PRELOAD resolver.

Docs

  • docs/how-to/xsim_rogue_cosim.rst — GUI and batch co-sim how-to, including the batch make xsim VIVADO_PROJECT_SIM=<DemoTb> VIVADO_PROJECT_SIM_TIME=all invocation (the sim must free-run while the external peer drives it).
  • docs/reference/makefile_reference.rst — cross-referenced co-sim usage of VIVADO_PROJECT_SIM / VIVADO_PROJECT_SIM_TIME.

ruck314 added 3 commits July 8, 2026 10:33
Add the ruckus-side orchestration for a Vivado xsim SystemVerilog DPI-C
co-simulation backend, alongside the existing GHDL (VHPIDIRECT) and VCS
(VHPI) paths. Pairs with the surf axi/simlink/xsim/ DPI backends
(RogueTcpStream/RogueTcpMemory/RogueSideBand), which link into one
combined RogueTcpDpi.so. Additive only -- the GHDL and VCS paths are
unchanged.

- run/pre/xsim.tcl: the xsim.compile.tcl.pre hook -- detects the Rogue
  co-sim sources, builds RogueTcpDpi.so via xsc, and stages it for the
  xsim run. Registered unconditionally by project.tcl; a fast no-op for
  non-Rogue projects. Fails fast with a pointer to "make vcs" when the
  surf version predates axi/simlink/xsim/ (legacy sim + src VHPI layout),
  and enforces the Vivado 2023.1+ floor the xsc link driver requires.
- sources.tcl: bind the DPI library via xelab -sv_lib RogueTcpDpi at
  project generation (guarded on the xsim Rogue backend).
- project.tcl: register the pre-compile hook and DPI/xsc project
  properties.
- xsim.tcl: batch-path parity for the DPI .so (LD_LIBRARY_PATH, libstdc++
  LD_PRELOAD, libzmq check).
- gui.tcl: set the libstdc++ LD_PRELOAD and RogueTcpDpi.so
  LD_LIBRARY_PATH at GUI startup, before Run Simulation.
  launch_simulation freezes the xsim subprocess environment before the
  run/pre hook fires, so the preload must be established here to reach the
  GUI-launched xsim; otherwise the co-sim dies with 'GLIBCXX_3.4.29 not
  found'.
- proc/sim_management.tcl: shared RogueSimSources / RogueCheckLibZmq /
  RoguePreloadLibStdCpp procs used by both the VCS and xsim flows.

Backend selection: surf's simlink loader chose its backend by sniffing
VCS_VERSION, which is set whenever VCS is sourced -- even for a Vivado
xsim run. Export RUCKUS_SIM_BACKEND per make target (xsim/gui -> xsim,
vcs -> vcs) so the backend follows the invoked target regardless of which
tools are on the environment. Older surf ignores the variable, so the
change is backward compatible.

Simulation variables: VIVADO_PROJECT_SIM now defaults to empty so the
sim_1 top configured by the target's ruckus.tcl (set_property top ...
[get_filesets sim_1]) is honored by "make xsim"; set it only to override
the top. VIVADO_PROJECT_SIM_TIME now defaults to "all" so a batch
"make xsim" co-sim free-runs until the testbench calls $finish/$stop or
is interrupted -- the old "1000 ns" default exited before the external
peer connected. Pass a time value (e.g. "1000 ns") to bound a run.

The libstdc++ LD_PRELOAD resolves a compatible libstdc++ dynamically
(libzmq's prefix -> active gcc -> RHEL/Rocky and Debian system paths)
instead of a hardcoded Debian-only path; Vivado injects an older
libstdc++ via LD_LIBRARY_PATH, which LD_PRELOAD outranks. Missing/old
libzmq fails fast with a clear diagnostic. All three modules are handled
by one uniform flow.

Verified end-to-end against Vivado 2025.2 + the rogue_v6.13.0 conda env:
the surf RogueTcpStream loopback demo reports rxCount == 10 /
rxErrors == 0.
- how-to/xsim_rogue_cosim.rst: GUI and batch co-sim guide, including the
  batch "make xsim VIVADO_PROJECT_SIM=<DemoTb>" invocation. The sim
  free-runs under the default VIVADO_PROJECT_SIM_TIME=all while the
  external peer drives it. Covers automatic backend selection, the surf
  axi/simlink/xsim/ requirement, and troubleshooting.
- reference/makefile_reference.rst: note the co-sim DPI auto-build on the
  gui/xsim targets and cross-reference the co-sim usage of
  VIVADO_PROJECT_SIM / VIVADO_PROJECT_SIM_TIME (default "all").
- how-to/index.rst: add the how-to to the toctree.
The "wis" target and vivado/wis.tcl generated an init_wis.tcl script to
seed a Windows Vivado session's environment variables without Cygwin. It
is no longer used. Drop the target, the script, and its entry in the
makefile reference documentation.
@ruck314 ruck314 changed the title Vivado xsim DPI-C co-simulation orchestration (RogueTcpDpi) Vivado xsim DPI-C Rogue co-simulation orchestration Jul 8, 2026
@ruck314
ruck314 marked this pull request as ready for review July 8, 2026 18:02
@ruck314
ruck314 merged commit 879e9ba into pre-release Jul 8, 2026
2 checks passed
@ruck314
ruck314 deleted the cosim-xsim branch July 8, 2026 18:02
@ruck314 ruck314 mentioned this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant