File format

A recording made by fdrec is a 4096-byte header followed by the raw data, exactly as the AXI DMA wrote it to memory:

Offset

Size

Content

0

4096

Header (struct fdrec_file_header), little-endian, zero-padded

4096

data_bytes

Beats 0, 1, 2, … — beat_bytes (32) bytes each, little-endian

The 4 KB header keeps the data aligned for O_DIRECT. The header is written once when the recording starts (without the complete flag) and rewritten when it stops, with the final counts and flags.bit1 set. A file whose header lacks the complete flag was interrupted (power loss, crash) and is reported as such by fdverify.

The structure is defined as a packed C struct in include/fdrec_file.h (its size is checked at compile time).

Data

Each beat is one AXI-Stream transfer of the fabric datapath as it came out of the data source, beat_bytes bytes, little-endian: byte k of the beat is TDATA[8k+7:8k]. On the 256-bit reference designs a beat is 32 bytes (TDATA[255:0]); on a 128-bit datapath it is 16 bytes. The recorder adds no framing, padding or timestamps, so a file of N beats has data_bytes = beat_bytes × N.

With the test pattern generator as the source, the data is a sequence of 16-byte words, whatever the beat size. Word n carries:

  • bytes 0–7 = lower = seq, a 64-bit counter that advances by one per word the generator emits, including the words of beats that are later dropped,

  • bytes 8–15 = upper = ~seq.

A 32-byte beat holds two consecutive words: TDATA[127:0] is the word with seq and TDATA[255:128] the word with seq + 1, and seq advances by two per beat. A clean recording is therefore byte-identical whether it was made with 16-byte or 32-byte beats: word n of the data carries seq = first_seq + n, and the file’s data_bytes = 16 × (number of words) in both cases.

So in a clean recording lower increases by exactly one from word to word, starting at first_seq, and upper == ~lower in every word. A jump in lower is a gap left by dropped beats (its size, the jump minus one, is beat_bytes / 16 words per dropped beat, starting at a beat boundary); a word with upper != ~lower is corrupted. This is what fdverify checks, per word, for both beat sizes. The playback checker (fdrec_check) applies the same pattern to every word of every beat it receives.

A recording made with 16-byte beats can be played on a 256-bit design: a clean one verifies exactly. If it has drops, a gap of an odd number of words cannot be represented in 32-byte beats (see fdplay); an odd number of words in total leaves the last word unplayed.

With your own data source, the data is whatever your logic presents on the TDATA interface (256 bits wide on the reference designs); see Replacing the test pattern generator.

Reading a recording

Python:

import struct, numpy as np

with open("rec.dat", "rb") as f:
    hdr = f.read(4096)
    magic, ver, hsize, beat, flags, dver = struct.unpack_from("<8s5I", hdr, 0)
    src_clk, rate, t0, t1, nbytes, drops, first = struct.unpack_from("<7Q", hdr, 28)
    # 16-byte pattern words, for any beat size: [:,0] = lower, [:,1] = upper
    data = np.fromfile(f, dtype="<u8").reshape(-1, 2)
    beats = data.reshape(-1, beat // 16, 2)              # [beat, word in beat, lower/upper]

C: include fdrec_file.h and read the first 4096 bytes into a struct fdrec_file_header.