Skip to content

Add Vivado xsim DPI-C co-simulation backend for RogueTcpStream, RogueTcpMemory, and RogueSideBand#1452

Open
ruck314 wants to merge 4 commits into
ci-RogueTcpMemoryWrap-RogueTcpStreamWrapfrom
cosim-xsim
Open

Add Vivado xsim DPI-C co-simulation backend for RogueTcpStream, RogueTcpMemory, and RogueSideBand#1452
ruck314 wants to merge 4 commits into
ci-RogueTcpMemoryWrap-RogueTcpStreamWrapfrom
cosim-xsim

Conversation

@ruck314

@ruck314 ruck314 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a Vivado xsim/SystemVerilog DPI-C co-simulation backend for RogueTcpStream, RogueTcpMemory, and RogueSideBand alongside the existing GHDL/VHPIDIRECT and VCS/VHPI paths. The VHDL forwarding entities, SystemVerilog DPI leaves, and C adapters reuse the shared axi/simlink/shared/*Core.h ZeroMQ models and link into one RogueTcpDpi.so built by xsc.

Each elaborated model now owns an independent DPI chandle, native model state, ZeroMQ context, and two-port endpoint pair. Explicit create/update/destroy APIs, normal/fallback cleanup, cross-model port collision checks, and multi-instance regressions support established multi-link users without changing the public VHDL interfaces or Rogue TCP wire formats.

The xsim usage guide now references only checked-in examples and documents the clock/reset, unique-port, peer, and connected-and-draining transport requirements for external targets.

Details

This pull request is stacked on #1450 because it uses that pull request's backend split and shared C cores. It does not depend on #1450's later GHDL integer-handle implementation; after #1450 merges, this pull request can be retargeted to pre-release and any real integration conflicts resolved then.

The shared cores retain the established synchronous ZeroMQ send behavior used by VCS/VHPI and GHDL/VHPIDIRECT. Peers must be connected and draining before HDL produces outbound traffic. No-peer, saturation, linger, retry-queue, and worker-thread hardening is intentionally deferred to a separate cross-backend change so xsim does not acquire different transport semantics.

Validation:

  • The original backend was exercised end-to-end with Vivado 2025.2 and the rogue_v6.13.0 environment; the Stream PRBS loopback reported rxCount == 10 and rxErrors == 0.
  • The new host-native DPI adapter regression passes four tests, including four Stream, two Memory, and two SideBand contexts exchanging isolated tagged ZeroMQ traffic, lifecycle reuse, and negative ownership/port cases.
  • The checked-in Vivado regression elaborates the same eight-instance VHDL/SV topology, pulses reset twice, rejects duplicate port pairs, and compiles the C adapters against an xelab -dpiheader generated ABI. It skips explicitly when Vivado tools are unavailable; the new multi-instance xsim flow still needs a recorded Vivado-enabled run before merge.
  • Warning-enabled C compilation, Python lint, VSG, direct GHDL analysis of the xsim VHDL harness, and git diff --check pass locally.

Pairs with the ruckus-side xsc / -sv_lib RogueTcpDpi orchestration in slaclab/ruckus#399.

Related

@ruck314 ruck314 changed the title Vivado xsim DPI-C co-simulation backend (RogueTcp{Stream,Memory,SideBand}) Add Vivado xsim DPI-C co-simulation backend for RogueTcpStream, RogueTcpMemory, and RogueSideBand Jul 7, 2026
@ruck314
ruck314 force-pushed the cosim-xsim branch 2 times, most recently from 2ab50de to 0d40c56 Compare July 7, 2026 23:35
@ruck314
ruck314 force-pushed the ci-RogueTcpMemoryWrap-RogueTcpStreamWrap branch from 2c97b87 to a1e7ee7 Compare July 8, 2026 18:45
Add a third axi/simlink/ co-simulation backend -- Vivado xsim via
SystemVerilog DPI-C -- alongside the existing GHDL (VHPIDIRECT) and VCS
(VHPI) paths. A forwarding VHDL entity -> SV DPI leaf -> C adapter chain
implements RogueTcpStream, RogueTcpMemory, and RogueSideBand, reusing the
shared axi/simlink/shared/*Core.h ZeroMQ cores unchanged. All three link
into one combined RogueTcpDpi.so via xsc. Additive only -- the GHDL/VCS
backends and the cocotb regression are untouched.

axi/simlink/ruckus.tcl selects the backend from RUCKUS_SIM_BACKEND (set
by the ruckus make target: make xsim/gui -> xsim, make vcs -> vcs),
falling back to GHDLFLAGS/VCS_VERSION sniffing for older ruckus. Sniffing
VCS_VERSION alone is unreliable because users commonly source both Vivado
and VCS in one setup script, which would otherwise load the vcs/ VHPI
backend during a Vivado xsim run. Sibling-backend sources are purged from
a reused Vivado project before loading the selected one (guarded by
VIVADO_VERSION, since get_files/remove_files are Vivado-only and GHDL has
no persistent project to clean), so switching backends no longer requires
"make clean".

On Vivado <= 2024.1 the bundled gcc-9.3.0 xsc link step uses its own
binutils via -B and does not search the host multiarch lib dir, so the
link fails with 'cannot find crti.o / -lzmq / -lm'. Point the startfile
(-B) and library (-L) search at the active gcc's lib dir, derived
portably via 'gcc -print-file-name=crti.o' (/usr/lib/x86_64-linux-gnu on
Debian/Ubuntu, /usr/lib64 on RHEL). Harmless on Vivado >= 2024.2, whose
xsc already resolves these.

Add axi/simlink/README.md describing the three interchangeable backends
and how to run the xsim co-sim in the GUI, linked from axi/README.md.
Ignore the xsim/xsc build outputs in .gitignore and tidy a few stale
cocotb test comments (JESD204B RX/TX register tests and the AXI Stream
batcher test).

Verified end-to-end against Vivado 2025.2 + the rogue_v6.13.0 conda env:
the RogueTcpStream loopback demo exchanges PRBS frames through the DPI
and reports rxErrors == 0 (byte-correct marshalling).
@ruck314
ruck314 marked this pull request as ready for review July 8, 2026 19:48

@bengineerd bengineerd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for per-instance DPI state and runnable usage documentation. The focused static checks and GHDL analysis are otherwise clean.

Comment thread axi/simlink/xsim/RogueTcpStream.c Outdated
Comment thread axi/simlink/README.md Outdated
Comment thread axi/simlink/xsim/RogueTcpStream.c Outdated
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.

2 participants