A systolic matrix multiply, measured
The systolic matrix multiply in the guide describes two modules:
SystolicEngine, which multiplies complex fixed-point matrices fed on streams, and
SystolicEngineMem, which runs it in an outer loop over matrices in memory. This example puts each in
its own harness and measures it at RTL: how long a product takes, against the bounds
the theory predicts, which stage
sets the pace, and what it costs.
Learning objectives
What this adds to the examples before it, in the order the pages teach it:
- Put a composite kernel in its own harness (
harness(module)) and run a workload in pysim and at RTL from the same scenario files, every output checked against the model. - Read a steady interval and a completion cycle from the sinks’ arrival cycles, with no waveform.
- Calibrate a task’s timed phase inside a composite kernel at RTL, and score it on held-out shapes.
- Predict a design’s bound – compute, input or output – and compare it with the RTL.
- Find the stage that binds from a trace: how long a block is held, and the gaps in an input’s acceptances.
- Read a design’s resources from csynth’s XML and compare configurations.
The design
StreamDriver (s_in) -> SystolicEngine -> StreamSink (s_out), StreamSink (m_status)
StreamDriver (s_job) -> SystolicEngineMem -> StreamSink (s_done)
↕ m_axi read, m_axi write
memory (one arena: A, B and C)
| configuration | the guide’s centre: Mmax 8, Kmax 8, Nmax 32, Pmax 4, R 4, C 8, L 4, form 4 |
| formats | 12-bit complex operands (A, B, C with 3, 4 and 5 integer bits), 16-bit lanes |
| words | 64 and 128 bits (two and four elements a word) |
| target | xczu48dr-ffvg1517-2-e at 250 MHz (4 ns); Vitis HLS / Vivado xsim 2025.1 |
The task bodies are the framework’s (waveflow/build/systolic_engine_*_task.h); the tops come from
composite_top_spec on the modules and the testbenches from the harness graphs. Build output lands
under the root a run is given.
Running it
python -m examples.systolic.engine_harness --root C:/wfsc/eh --workload steady --word-bits 128
python -m examples.systolic.engine_mem_harness --root C:/wfsc/em --workload big --word-bits 128
pytest tests/examples/test_systolic.py # pysim against the model, both word widths
pytest tests/examples/test_systolic.py -m xsi # the RTL gates (needs Vitis and Vivado)
python -m examples.systolic.systolic_measure --root C:/wfsc/sm # every run -> measured.json
python -m examples.systolic.engine_harness --root C:/wfsc/cal --word-bits 128 --calibrate --through calib_phases
python -m examples.systolic.systolic_sweep --root C:/wfsc/sw # csynth 15 configurations -> resources.json
--through golden stops after pysim; the default, compare, adds csynth and XSI. Build from a short
root on Windows: past 260 characters a csynth path fails silently.
The pages
- The harnesses – the two harnesses, the workloads, how the RTL is timed, the gates.
- Timing – the engine against its bounds, how the binding stage was found, the wrapper and its read port, pysim against the RTL.
- Resources – what each costs at 64- and 128-bit words.
The core’s timed phase is calibrated at RTL (Timing), and pysim runs within 5 to 12% of the RTL; a resource model over the engine’s parameters is the next step, fitted on the sweep’s builds (Resources).
Table of contents
- Systolic harnesses - The systolic engine's and its memory wrapper's harnesses: harness(module) builds a driver per stream input, a sink per output, and one memory behind the m_axi ports; the module names its workloads (test, steady, short; test, big) and its golden. Each run goes pysim, csynth, XSI, and compare -- every output word against the model -- and the RTL is timed from the BFMs' arrival cycles. The gates, fast and -m xsi.
- Systolic timing results - What the RTL measured (Vitis 2025.1, centre): the engine at 171 cycles per 8×8×32 product with 64-bit words (the input bound) and 141 with short panels (the output bound); with 128-bit words 94 whatever the panel -- the core's own floor, 64 tile steps and about 30 cycles a command -- and 81 an output when a command carries four, at the input's bound. How the binding stage was found from block hold times and input gaps; the design's steps from 390 cycles to 94; the wrapper at 5,813 and 3,033 cycles on 32×32×64 once its feeder requests a tile's panels ahead; the core's panel phase calibrated at RTL, 5 + 1.00·steps cycles, exact on held-out panels; pysim within 5 to 11% of the RTL once the A loader's element a cycle is charged.
- Systolic resource results - What the engine and the wrapper cost on the xczu48dr, from csynth's XML (Vitis 2025.1): at the centre 154 DSP, 32k LUT and 36k FF for the engine, 32 to 36 BRAM18K by word width, and the wrapper 3 DSP and 6k LUT more. A sweep of 23 configurations, fifteen of the engine alone and eight of the memory-backed engine at the LTBF system's array shapes: DSPs are four per processing element plus the index products; LUTs and flip-flops grow with the array, about 0.5 to 0.6k LUT and 0.6 to 0.8k FF an element; the maxima and the panels barely move them. A half-size engine costs about what the earlier SystolicUnit did, and runs 2.3 times as fast. The resource model on the platform, a model per task: DSP and BRAM by rule, exact on all 23 builds; LUT and FF within 3.7 and 3.3% mean on the two held out.