Replacing the test pattern generator with your own data source
The reference design records data from a test pattern generator (fdrec_tpg). For a real
application you replace it with your own ADC, sensor or processing logic. Everything you
need to change is inside one block design hierarchy, user_data_source. The rest of the
design (nvrec_core, the NVMe Host Accelerator, the driver and the apps) stays the same.
For the playback direction, see Replacing the checker with your own data sink.
The insertion point, its pins and the stream contract are identical to those of fpga-drive-recorder, so a source written for one design drops into the other unchanged.
The insertion point
The user_data_source hierarchy has these pins:
Pin |
Direction |
Width |
Description |
|---|---|---|---|
|
in |
1 |
Source clock. PS |
|
in |
1 |
Active-low reset, synchronous to |
|
out |
AXI4-Stream |
|
|
in |
1 |
|
|
in |
1 |
|
|
in |
32 |
|
|
out |
64 |
Read back as |
M_AXIS and all the tpg_* signals are in the src_clk domain. nvrec_core does every
clock-domain crossing, so your logic only has to deal with src_clk.
The no-backpressure contract
The recorder assumes your source cannot be stalled, like an ADC:
Drive
TVALIDhigh for onesrc_clkcycle for every beat (256 bits on the Zynq UltraScale+ targets, 512 bits onvck190_fmcp1) you produce.TREADYis always 1. You can leave it unconnected. Do not wait for it.If the ingest FIFO is full,
nvrec_coredrops the beat and counts it (RUN_DROP_COUNTwhile a recording runs). The data is never delayed and never corrupted. A beat is either recorded or counted as dropped. A recording is only valid if the drop count is 0, andnvrecexits with code 2 if it is not.Data is recorded byte-for-byte as it appears on
TDATA, little-endian:TDATA[7:0]is the first byte of each beat (32 or 64 bytes) in the file.There is no framing on the source side. The ring writer cuts the stream into chunks itself, downstream of the drop point. If you need markers in the data (frame starts, timestamps, channel numbers), put them in
TDATA.
Clocking
You can use any clock for src_clk. At the top level of the block design, remove the
src_clk net’s connection to the PS clock (pl_clk2 on Zynq UltraScale+, pl2_ref_clk on
Versal) and connect your own clock (for example an ADC data clock, or the output of a
clocking wizard). Connect rst_src_clk/slowest_sync_clk to the same clock, so that
src_resetn stays synchronous to it. The same net also clocks nvrec_core’s source side
and the user_data_sink hierarchy (snk_clk): the playback sink always runs on src_clk.
Then set the SRC_CLK_HZ parameter of nvrec_core_0 to the real frequency, so that
software can compute rates from it. The block design script sets it from the PS clock with:
set_property -dict [list CONFIG.SRC_CLK_HZ $src_clk_hz ...] [get_bd_cells nvrec_core_0]
The clock is asynchronous to dp_clk, and needs no extra constraints for the recorder (the
crossings use XPM macros). Your own clock still needs its usual create_clock constraint if
it comes from a pin.
Rate limits. The average input rate must stay below what the rest of the chain can sustain, otherwise beats are dropped:
The source interface: one beat per
src_clkcycle, 250 MHz × 32 B = 8 GB/s on the Zynq UltraScale+ targets, 250 MHz × 64 B = 16 GB/s onvck190_fmcp1.The fabric datapath:
dp_clk× the beat, the same 8 or 16 GB/s (250 MHzdp_clk).src_clkanddp_clkrun at the same frequency, so a source at one beat every cycle leaves the ingest FIFO no time to drain after a pause of the ring writer.The path into memory: on
zcu106_hpc0andvck190_fmcp1the ring of a RAID0 or fabric-only run is split over two memories, each with its own ring port. On Versal a 512-bit NoC port into the DDR4 and one into the LPDDR4 (QoS 14 000 MB/s per direction each; the two PCIe Root Ports each have their own NoC ports). On the ZCU106 theS_AXI_HP2_FPDport into PS DDR (128 bits at 322.19 MHz, 5.16 GB/s peak; 333 MHz requested) and a port into the PL DDR4 through a DDR4 controller in the PL; the ring writer streams in order through both, so their mix, not the fabric, sets the ceiling. The UltraZed-EV has the HP port only (327.77 MHz, 5.24 GB/s peak).nvrec --no-writemeasures this path on its own, without an SSD (see Applications).The SSDs read the ring from the same DDR, so a recording crosses DDR twice; and the SSD (or the RAID0 array) sustained write rate is usually lower still. Use
nvbench.shornvbench-suite.shto measure it for your board and SSDs.
Measured without an SSD (nvrec --no-write, see
Benchmarks), the fabric fills the ring without a dropped
beat up to 6000 MB/s on zcu106_hpc0 with the default whole-chunk stripes (7000 MB/s with
4 KB stripes; a single ring in PS DDR stops at 5000 MB/s, where the HP port delivers 5155 MB/s)
and up to 14 750 MB/s on vck190_fmcp1, whose datapath is 512 bits wide (15 750 MB/s with
4 KB stripes, just below the 16 000 MB/s source maximum). uzev was not measured (its HP port
peaks at 5.24 GB/s). A source whose average stays below these rates loses no beat on its way
into the ring; whether the SSDs keep up is the next question (see
Benchmarks).
The ingest FIFO (256 KB: 8192 beats of 32 bytes on the Zynq UltraScale+ targets, 4096 beats
of 64 bytes on vck190_fmcp1) only absorbs short bursts and the ring writer’s 4 KB burst
cadence (32 µs at 8 GB/s, 16 µs at 16 GB/s); the ring (1 GB by default when split over two
memories, 512 MB otherwise) absorbs
the SSDs’ write stalls. If your source is bursty, its average over a few milliseconds is
what matters. You can make the FIFO deeper with the FIFO_DEPTH parameter of
nvrec_core_0 (a power of 2, in beats, block RAM); the block-design scripts size it at
256 KB for every width (nvrec_ing_fifo_depth in Vivado/src/bd/nvrec_params.tcl).
Data width
The stream is 256 bits (32 bytes) wide on the Zynq UltraScale+ targets (zcu106_hpc0,
uzev) and 512 bits (64 bytes) on the Versal target (vck190_fmcp1). The width is the
DATA_WIDTH parameter of nvrec_core and of the fdrec_tpg / fdrec_check modules: 128,
256 or 512. The block-design scripts set it from one variable, nvrec_data_width, which
Vivado/src/bd/nvrec_params.tcl reads from the target’s "data_width" entry in
config/data.json (default 256; 512 for vck190_fmcp1); a set nvrec_data_width <n> in the
Tcl console before the block design is built overrides it. The FIFO depths follow: the
ingest FIFO is 256 KB at every width, the egress FIFO 128 KB at 128 and 256 bits and 256 KB
at 512 bits ("egress_fifo_kb" overrides it). Software adapts by itself: the driver reads the
beat size from the BEAT_BYTES register (see Kernel driver) and
the file header records it. If your source produces words of the build’s width, connect it
directly.
If your source is narrower, pack its samples into beats of the build’s width before
M_AXIS. There are two common ways:
AXI4-Stream Data Width Converter (
axis_dwidth_converter). Put it inuser_data_sourcebetween your source andM_AXIS, with the slave side at your width (for example 4 bytes, or 16 bytes for a source written for the 128-bit interface of the previous revision) and the master side at the beat size (32 bytes, or 64 onvck190_fmcp1). At 32 bytes it collects 8 × 32-bit words (or 2 × 128-bit words) into one beat, the first one in the lowest bits. The converter has aTREADYinput, butnvrec_corealways drives it high, so the converter never stalls your source.Your own packing logic. A shift register that collects N samples and pulses
TVALIDevery Nth sample. This is a few lines of RTL and costs almost nothing.
In both cases the first sample ends up in the lowest bits (TDATA[W-1:0]), so it is the first
in the file. If you stop with a partly filled beat, those samples are not recorded.
A source that delivers 128-bit words at up to one per src_clk cycle (4 GB/s at 250 MHz)
can also keep a 128-bit interface: build the design with "data_width": 128. A 256-bit beat
per cycle is needed only above 4 GB/s, a 512-bit one above 8 GB/s.
If your source is wider than the build’s datapath, or faster than one beat per src_clk
cycle, use a faster src_clk and a width converter, or split the data into beats yourself;
the fabric datapath (8 GB/s at 256 bits, 16 GB/s at 512) and the memory path above still
bound the average rate (a 512-bit build doubles the fabric datapath, not the memory path of
the Zynq UltraScale+ targets).
What about the TPG controls?
The tpg_* pins exist so that the built-in test pattern generator can be controlled from
software. Your source can use them however you like, or not at all:
Use
tpg_enableas a run/stop control, so thatnvreccan start and stop your source through the driver’stpg_enablesysfs attribute (/sys/class/misc/nvrec/tpg_enable). Otherwise runnvrec --no-tpg, so that it leaves the TPG registers alone.Leave
tpg_seq_rstandtpg_rate_incunconnected if they mean nothing to your source.Tie
tpg_seq_nextto 0 if you do not have a sample counter. Software only uses it to fill infirst_seqin the file header for TPG recordings.
Note that nvverify checks the TPG pattern (16-byte words, each a sequence number in the
low half and its complement in the high half; a 32-byte beat holds two consecutive words).
It cannot verify recordings from your own source. Use
your own tools to check them, and use the drop count (nvrec summary, file header
drop_count) to know that no data was lost.
Step by step
In the block-design script of your target’s device family (
Vivado/src/bd/bd_zynqmp.tclfor Zynq UltraScale+,Vivado/src/bd/bd_versal.tclfor Versal), find theuser_data_sourcehierarchy. Replacecreate_bd_cell -type module -reference fdrec_tpg user_data_source/fdrec_tpg_0and its connections with your own IP or module reference. Keep the hierarchy pins as they are.Put your RTL in
Vivado/src/hdl/.build.tcladds every.v/.svfile there to the project. The top module of a module reference must be in a Verilog (.v) or VHDL file. Vivado 2025.2 does not accept a SystemVerilog file as a module-reference top ([filemgmt 56-195]), but SystemVerilog submodules are fine.If you change
src_clk, update its source andSRC_CLK_HZas described above. Leave thetpg_*pins that your logic does not use unconnected inside the hierarchy, and tietpg_seq_nextto 0 (anxlconstantof width 64) if you have no counter.Rebuild with
./build.sh xsa --target <target>and check timing, then rebuild the Linux image with./build.sh yocto --target <target>(the bitstream is inBOOT.BIN). The driver and the apps need no change. The build needs the NVMe Host Accelerator license, as for the reference design.Record with
nvrec --no-tpg --size <bytes> <file>and check that the exit code is 0 (drop count 0, no NVMe errors). If your source is not producing data, no chunk fills andnvrecstops after--timeoutseconds (default 10) with exit code 1 instead of waiting forever; the file keeps what was recorded.
You can also make the change interactively: build the project with
./build.sh project --target <target>, open it from Vivado/<target>/ in the Vivado GUI,
edit the user_data_source hierarchy, then copy the change back into the Tcl script so
that it survives a rebuild.