Stream Blocks
A stream-only design – kernels that read and write only streams, joined by streams
(Stream-only modules and adaptors) – keeps needing the same few pieces
between its kernels: one stream to several stages, several streams into one. These are those pieces,
written once, verified once, in waveflow.streams.
Every block here follows the same shape:
- a Python model – a
FreeRunModwhoserun_itermoves whole bursts, so its framing in pysim is the RTL’s; - an HLS body in
waveflow/streams/src/, templated on the data width and on each port’s word type. The generator supplies the type where the block sits (KernelTask.framed):axi4s_word<W>on a top’s port,framed_word<W>on an internal FIFO. So one body serves the block as the top of its own harness, at a composite’s boundary, and deep inside one; - a build step that copies the body into a design’s
include/– aStreamBodyStepsubclass naming its body inKEY; - an RTL gate in its own harness (
waveflow.streams.rtl): every output recorded at RTL equal to pysim’s.
| block | what it does |
|---|---|
StreamBroadcast |
one framed stream in, n_out copies out: every word to every output, TLAST included |
StreamArbiter |
n_in framed streams into one, a whole frame at a time, strict priority or round-robin; the winner’s index on m_sel |
StreamDemux |
one framed stream out to n_out, a whole frame at a time, to the output s_sel or a header field names |
StreamFramer |
a stream framed by count alone into a framed one, TLAST every frame_words words: so a demux can sit after SsrFft |
StreamDispatch |
one framed job stream out to a pool of n_out identical workers, each job whole to a worker holding a credit, first-free or round-robin; credits back as a worker’s index on s_free (an arbiter’s m_sel) |
Table of contents
- StreamBroadcast - StreamBroadcast: one framed stream in, n_out copies out -- every word written to every output, TLAST included, so the framing travels with the data and the block knows nothing about messages. The way to give two stages each a part of one stream: each reads its copy and skips what is not its own. Two rules a design must respect: the outputs move in lockstep (a full output stalls them all), and a consumer must keep consuming its own copy, never waiting on a sibling for something queued behind its own unread data. Its body is templated on each port's word type; how to use it in a composite and build it.
- StreamArbiter - StreamArbiter: n framed streams into one, a whole frame at a time -- the way several clients share one stream, and so one kernel behind it. A frame is frame_bursts TLAST bursts (1 for a message, 2 for a header and its payload); the policy is strict priority (input 0 first) or round-robin, fixed at build time; the winner's index goes out on m_sel, one word before each frame, so a StreamDemux after the kernel can return each frame to its client. Two rules: announce a frame only once it is all there, and read m_sel as the frames go by. Its interleave depends on timing, so its RTL gate is the arbiter-demux pair. Why it is written in HLS rather than taken from AMD (the AXI4-Stream Switch, the Vitis Utility Library's streamNToOne).
- StreamDemux - StreamDemux: one framed stream out to n, a whole frame at a time, to the output a side stream names (s_sel, one word a frame -- what a StreamArbiter's m_sel carries) or a field of the frame's first word names (route='header'). The return half of a shared kernel: arbiter -> K -> demux returns every frame to its client, for any K that keeps frames in order. An index naming no output drops the frame and counts it. The outputs do not move in lockstep: a full output stalls them all. Its body, its build step and its RTL gates.
- StreamFramer - StreamFramer: a stream framed by count alone (no TLAST) into a framed one, TLAST every frame_words words, the words unchanged. Put it after a unit that frames by count -- SsrFft's L/R words a frame -- so a StreamDemux, or any stage that reads whole frames, can sit after it. A word a cycle, a cycle of latency, nothing in rate; it drains its input whenever its output has room, so a link into it is no loop hazard. Its body, its build step and its RTL gate.
- StreamDispatch - StreamDispatch: one framed job stream out to a pool of n identical workers, each job whole to a worker holding a credit -- the other direction from StreamArbiter, for jobs of data-dependent length that a fixed split would leave one worker queued behind. Credits per worker (the jobs it may hold), given back as a worker's index on s_free: exactly what a StreamArbiter merging the workers' results writes on m_sel, so dispatch -> workers -> arbiter, m_sel -> s_free, closes the loop. Policies first_free and round_robin, fixed at build time; a returned credit before a new job. Three rules: the credit link holds every outstanding credit, a job is announced only when it is all there, a credit is room for a whole job. Its assignment depends on timing, so its gate is the pool, checked as a multiset.