Parameters

Constructing one

from waveflow.dsp.ssr_fft.hw import SsrFft
from waveflow.hw.clock import Clock
from waveflow.simulation.simulation import Simulation

fft = SsrFft(name="fft", sim=Simulation(), clk=Clock(freq=250e6), L=1024)
print("input port: s_in", fft.s_in.bitwidth, "bits")
print("output port: m_out", fft.m_out.bitwidth, "bits")
print("output format: ap_fixed<%d,%d>" % (fft.out_fmt.W, fft.out_fmt.int_bits))
print("stages:", fft.geo.S)
print("tasks:", len(fft.tasks), "->", " ".join(c.task.inst for c in fft.tasks))
input port: s_in 128 bits
output port: m_out 216 bits
output format: ap_fixed<27,13>
stages: 5
tasks: 17 -> in_reg tp0 tp1 tp2 tp3 st0 cm0 st1 cm1 st2 cm2 st3 cm3 st4 rc rw rr

One port each way, one RadixWord – four complex samples – a beat. Inside, one child per task: in_reg a one-word register at the input (for timing; see Synthesis), tp* the transposer, st* the stages, cm* their commutators, rc/rw/rr the reorder.

With lanes=True it presents VitisFft’s port group instead – four ports each way, one sample a word – and is a drop-in replacement for it:

lf = SsrFft(name="fft", sim=Simulation(), clk=Clock(freq=250e6), L=1024, lanes=True)
print("with lanes:", len(lf.s_in), "ports in of", lf.s_in[0].bitwidth, "bits,",
      len(lf.m_out), "out of", lf.m_out[0].bitwidth)
with lanes: 4 ports in of 32 bits, 4 out of 54

Everything that follows from L and the formats lives in one object, Geometry, which the model, the module and the C++ generator all read:

from waveflow.dsp.ssr_fft.model import Geometry

geo = Geometry(1024)
print("transposer block sizes:", geo.transposer_ds)
print("stage commutator block sizes:", [geo.stage_d(s) for s in range(geo.S - 1)])
for name, fmt in geo.edges()[4:8]:
    print(f"edge {name}: ap_fixed<{fmt.W},{fmt.int_bits}>")
transposer block sizes: [1, 4, 16, 64]
stage commutator block sizes: [64, 16, 4, 1]
edge tp3: ap_fixed<16,2>
edge st0: ap_fixed<19,5>
edge cm0: ap_fixed<19,5>
edge st1: ap_fixed<21,7>

The reorder’s frame buffer has two implementations (Synthesis); the ping-pong one is a single task:

pp = SsrFft(name="fft", sim=Simulation(), clk=Clock(freq=250e6), L=1024, reorder="pingpong")
print("reorder tasks:", [c.task.inst for c in pp.tasks if c.task.inst.startswith("r")])
reorder tasks: ['rc', 'rp']

inverse=True gives the inverse transform, 1/L included. It is the same pipeline with conjugated twiddle ROMs (AMD’s REVERSE_TRANSFORM arithmetic, bit for bit). The 1/L costs nothing: the output words carry the same bits as the unscaled transform, read with log2 L fewer integer bits:

fwd = SsrFft(name="fft", sim=Simulation(), clk=Clock(freq=250e6), L=1024)
inv = SsrFft(name="ifft", sim=Simulation(), clk=Clock(freq=250e6), L=1024, inverse=True)
for f in (fwd, inv):
    o = f.out_fmt
    print(f"{f.name}: out ap_fixed<{o.W},{o.int_bits}>, port {f.m_out.bitwidth} bits")
fft: out ap_fixed<27,13>, port 216 bits
ifft: out ap_fixed<27,3>, port 216 bits

AMD’s library divides at the old resolution instead, truncating toward zero, so the low log2 L bits of its inverse are always zero; waveflow.vitis_l1.fft.ifft_scale maps these outputs onto its bits exactly.

The direction chosen per frame

direction="runtime" builds one FFT that runs either direction, chosen frame by frame on a third port, s_dir: one word a frame, bit 0 set for the inverse. This is the FFT a shared kernel needs, where one unit does a channel’s forward pass and then its inverse:

rt = SsrFft(name="fft", sim=Simulation(), clk=Clock(freq=250e6), L=1024, direction="runtime")
print("ports:", [n for n, _ in rt.boundary], "- s_dir", rt.s_dir.bitwidth, "bits")
o, i = rt.out_fmt, rt.inv_out_fmt
print(f"a forward frame reads ap_fixed<{o.W},{o.int_bits}>, an inverse one ap_fixed<{i.W},{i.int_bits}>")
ports: ['s_in', 's_dir', 'm_out'] - s_dir 8 bits
a forward frame reads ap_fixed<27,13>, an inverse one ap_fixed<27,3>
  • Each frame is the fixed build’s of its direction, bit for bit. The inverse tables are the forward ones conjugated, exactly. So an inverse frame needs only two moves in each stage, with the forward ROMs: the butterfly’s outputs 1 and 3 swap places, and the twiddle’s imaginary part is negated. Every product and every truncation is then the inverse build’s. Conjugating the frame at both ends would not give the same bits: truncation does not commute with negation, and negating the most negative input overflows.
  • The output port carries the forward format. An inverse frame’s words hold the inverse build’s bits, so read them through inv_out_fmt: that reinterpretation is the 1/L. The direction does not come back out of the FFT. Whoever reads the output knows each frame’s direction already, from the tag that travels beside it.
  • The timing is the fixed build’s. A frame still leaves every L/R cycles, with the ping-pong reorder, in both directions and when they alternate. See Timing.
  • What it costs (xczu48dr at 250 MHz, csynth Vitis HLS 2025.1, out-of-context place and route Vivado 2025.1, against the forward build): no timing – csynth’s estimate is the fixed build’s (2.855 ns at L = 64, 2.901 ns at L = 1024), every build meets 4 ns routed (WNS +0.962 ns and +0.886 ns for the runtime builds), and the worst of the six is a fixed inverse, +0.399 ns, a placement outcome. Resources: about 10% more FF and LUT in csynth, 1.5-6.5% routed (L = 64: +275 FF, +401 LUT; L = 1024: +326 FF, +629 LUT); the same DSPs and BRAM. The extra goes to the input register and one or two butterfly stages, each a pipeline stage deeper: latency, not rate (plans/shared_kernel_rfsoc_timing.md).
  • Inside, the input register reads the direction at each frame’s first word and hands a copy to every stage on its own small FIFO. Each stage reads its copy when that frame’s first word arrives. The FIFOs are sized for the frames the chain holds, so the register never waits on them.

It takes the RadixWord boundary only, and leaves inverse at False.

Every parameter

parameter type / binding default meaning
name, sim     as for every HwModule
clk Clock 250 MHz the module’s clock: the pysim times every task in its periods
L HwParam[int] 64 transform length, 4^S with S >= 2
in_w, in_i HwParam[int] 16, 2 input ap_fixed<in_w, in_i>, per real/imaginary part
tw_w, tw_i HwParam[int] 18, 2 twiddle table ap_fixed<tw_w, tw_i>
reorder str "sob" the reorder’s frame buffer: "sob" (a stream_of_blocks between two tasks) or "pingpong" (both halves in one task)
lanes bool False the boundary: one RadixWord port each way (s_in, m_out), or with True VitisFft’s four-lane group (s_in_0..3, m_out_0..3)
inverse bool False the inverse transform: conjugated twiddle ROMs, 1/L as log2 L fewer integer bits on the output
direction str "fixed" "fixed": the direction is inverse; "runtime": chosen per frame on s_dir (bit 0 = inverse), each frame bit-exact with the fixed build of its direction – see above
timed bool True False gives exact bits in zero simulated time
pysim str "tasks" the pysim’s granularity: "tasks", one process per task; or "flat", one process for the whole FFT with the same frames at the same cycles (ping-pong reorder only) – see Timing

L and the widths are HwParams: they reach the C++ as the generated configuration (formats, ROMs), so two values are two artifacts. There is no R parameter: 4 is the only radix the model and the task bodies cover.

No timing parameters. Unlike VitisFft, nothing is calibrated per length: every task runs at one word a cycle, so the interval is L/R by construction, and each task’s latency follows from its structure. See Timing.

What it derives

  • geo, the Geometry: stages S, words per frame L/R, every commutator’s block size, every edge’s format (geo.edges()), the twiddle table and the reorder’s permutation.
  • out_fmt, the output format – read it rather than computing it. With direction="runtime", inv_out_fmt is how an inverse frame’s bits read.
  • tasks: the children, in pipeline order, each with its kernel_task() – the generated wrapper it synthesizes to.
  • The ports: s_in / m_out, one endpoint each; with lanes=True, s_in / m_out are lists and s_in_0..3 / m_out_0..3 attributes – see Interfaces.

What it refuses

for kwargs in ({"L": 32}, {"L": 4}, {"L": 64, "reorder": "fifo"}):
    try:
        SsrFft(name="bad", sim=Simulation(), **kwargs)
    except (ValueError, NotImplementedError) as exc:
        print(type(exc).__name__ + ":", exc)
ValueError: 32 is not a power of 4
ValueError: L=4: need L = 4^S with S >= 2.
ValueError: reorder='fifo': one of ('sob', 'pingpong')

Also refused, in Geometry: a radix other than 4, and a scaling mode other than NO_SCALING – the modes the per-stage model has measured. And pysim="flat" with reorder="sob": that reorder’s frames queue inside the chain, which one process would not reproduce.