Vector Unit
VecUnit (waveflow/vecunit/) is a small processor for complex fixed-point linear algebra. A
fixed-function block such as the (retired) CG vector unit does one algorithm, which is
built into its hardware. VecUnit instead runs programs: lists of instructions such as “add these
two vectors” or “multiply this vector by a scalar”, which the host sends with each job. The same
hardware then runs conjugate gradient (the CG example), a
multi-antenna matched filter (the matched-filter example),
or a toy kernel of a few instructions, without being rebuilt.
Nothing in it is new as computer architecture. The unit combines structures that have been standard for decades. The pages say where each comes from, so a reader who knows the field can place it at once:
| Structure | What it means here | Known from |
|---|---|---|
vector instructions, VL |
one instruction works on up to VLMAX elements; the program sets how many |
Cray-1; the RISC-V vector extension (RVV 1.0) |
| lanes, register groups | L copies of the datapath work side by side, each on its own vector |
multi-lane vector machines; RVV register groups |
| chaining | a chain of dependent instructions streams through the pipeline element by element | Cray-1 (Russell, CACM 1978) |
| decoupled access/execute | loading, computing and storing are three tasks with three programs, joined by queues | Smith, ISCA 1982; Espasa and Valero, HPCA 1996 |
| double-buffered queues | the loader fills one block while the execute task works on the other | ping-pong buffers; VTA (Moreau et al., IEEE Micro 2019) |
| banked register file | registers spread over memories so a pass can read several at once | Ara (Cavalcante et al., IEEE TVLSI 2020) |
| a fixed-point format per register | each value rounds and saturates once, to the format of the register it is written to | fixed-point DSPs; RVV’s fixed-point rounding modes, here fixed per register at build time |
What Waveflow adds is the flow rather than the architecture. One Python description gives four artefacts that agree bit for bit: the interpreter that defines what a program computes (the golden), the pysim model, the generated HLS, and the RTL.
Fixed function or programmable
CgVectorUnit |
VecUnit running CG |
|
|---|---|---|
| what it computes | CG’s vector steps, built in | whatever the program says |
| a new algorithm | new hardware | a new program |
CG, a job of 8 × 32, three iterations |
3,581 cycles, 21.5k LUT | 3,447 cycles, 83k LUT |
(Vitis HLS / Vivado xsim 2025.1, xczu48dr at 4 ns, examples/vecunit_cg/measured.json.) The
programmable unit is about four times the logic, and in return it runs other programs. It runs CG
at about the fixed-function unit’s speed only because the execute task fuses independent work into
long pipelined runs (see Timing and resources).
The pages
Read them in order the first time:
- How a vector processor works – the ideas, for a reader new to processor design:
instructions and an instruction set, registers, vectors and
VL, strip-mining, lanes, pipelines and chaining, decoupled access/execute, and fixed-point formats per register. - Vector unit architecture – what this unit has: the three tasks, the register file and its banks, the scalar file, the queues and the layout of their blocks, the slots, the formats and the ports.
- Vector unit program examples – programs read line by line, one idea an example, on the toy kernels.
- Configuring and constructing a vector unit – every configuration option, what it costs, and constructing the unit in Python.
- Vector unit instruction set – every instruction, how to read its formula, its 64-bit encoding, the rules a pass must keep, and how passes fuse into runs.
- Programming the vector unit – writing programs in Python, the assembler and its checks, the interpreter, pysim, errors, and what makes a program fast.
- Vector unit interface – the protocol: the streams, what a job sends and receives, the word formats and the ordering rules.
- Vector unit hardware – the generated HLS, the build flow and the RTL tests.
- Vector unit timing and resources – where a job’s cycles go, which task binds, and the calibrated timing and resource models.
The examples: toy kernels (the pages excerpt them), conjugate gradient and a matched filter.
Table of contents
- How a vector processor works - The ideas behind the vector unit, for a reader who knows signal processing but not processor design, with the standard computer-architecture name of each: a program of instructions and an instruction set (ISA), registers, vector instructions and the vector length VL, strip-mining, lanes and register groups, pipelines, the initiation interval and chaining, decoupled access/execute with double-buffered queues, and fixed-point formats per register. Worked on the toy kernels of examples/vecunit.
- Vector unit architecture - What the vector unit has, and why: three free-running tasks (load, execute, store) joined by double-buffered queues of blocks; the vector register file of NG groups of L members of VLMAX complex elements, in NB banks, and the one-read-one-write-per-bank rule; the scalar file of per-lane real values; how a k x n matrix lies in a queue block as rows of lane groups; the S slots of a pass and their capability masks; a fixed-point format per register and the union datapath; the ports and their words; the job, its programs and its status. Every size is a build parameter of VecUnitConfig, shown on the toy unit.
- Vector unit program examples - Vector unit programs read line by line, one idea an example, on the toy kernels of examples/vecunit: Y = X + X unchained and chained (passes, slots, forwarding, what chaining saves); an elementwise conj(X)·Y (a one-instruction pass, the conjugate form, a job's three programs); the same strip-mined over chunks of VLMAX; a per-column gain fit (reductions, the scalar file, the divide); a polynomial with constants (scalar immediates, a scalar with a vector) and its two dependent passes fused; a result shift (wf.setrs and an instruction's own); a job written as one program; and four programs the assembler refuses.
- Configuring and constructing a vector unit - How to describe and build a vector unit in Python: VecUnitConfig and every one of its options (formats, sizes, slots and their capabilities, fusion, the result shift, the divide, ports and words) with its default, meaning and limits; the sizes it derives; how it is checked; and constructing the unit -- the pysim VecUnit, an application's subclass that names its jobs, and the build of its hardware.
- Vector unit instruction set - Every instruction of the vector unit, with how to read the tables: operand names, what holds for each lane and element, and q_d(x) -- the one rounding and saturation to the destination's format, worked on a small format. Moves and adds, multiplies and their conjugate and broadcast forms, a scalar with a vector, reductions, queue reads and writes, scalar and control instructions, the load and store programs; the result shift; the 64-bit encoding, with one instruction encoded field by field; the rules a pass must keep, each with its reason; and how passes fuse into runs.
- Programming the vector unit - Writing vector-unit programs in Python: instructions as objects built by waveflow.vecunit.isa's constructors (.c to chain, conj, bcast and rs as options), a job's three programs or one program split into them, a program builder that strip-mines, the assembler's check and its messages, assemble into the bursts the unit takes, the bit-exact interpreter run_job and a NumPy golden, the unit in pysim in its harness, errors and their status codes, and what makes a program fast.
- Vector unit interface - How a host drives the vector unit: its six kinds of stream (three program streams, the data ports in and out, the status), what one job sends and receives and in what order (a sequence diagram), the word formats -- the VecJob header and instruction words of a program, a matrix's memory elements packed into data words, the VecResp header of each output matrix, the VecStatus word of each job -- the ordering rules, errors, and the Python that makes and checks these bursts.
- Vector unit hardware - How the vector unit becomes hardware: the per-configuration header that hls.py generates on vecunit_core.h, the build steps (VecUnitHeaderStep, VecUnitCodegenStep, build_dag), and the tests -- the interpreter against an exact-rational reference, pysim against the interpreter, and the XSI RTL gates.
- Vector unit timing and resources - Where the vector unit's time is measured and charged: a job's interval between statuses at RTL, pysim's per-item execute charge from VecTiming and its features, the loader and store at a word or a value a cycle; the calibrated timing model (pre-registered fit and held-out scores, Vitis HLS 2025.1) and the by-phase model that was tried and not kept; the calibrated resource model (LUT, FF, DSP, BRAM); and the unit's limits.