A bit-exact NVFP4 tensor core and transformer engine on a small FPGA
Abstract. NVIDIA's Blackwell GPUs multiply matrices of 4-bit NVFP4 numbers in dedicated tensor cores, but NVIDIA does not publish the exact arithmetic of these units. We measure that arithmetic on two GPUs and build an open tensor core on an AMD Artix-7 FPGA whose results equal the GPU's bit for bit. The tensor core does 512 multiply-accumulates per cycle at 50 MHz in a 2 × 64 × 4 grid, with four 4-bit products packed into each DSP slice. An eight-lane FP32 vector unit adds softmax, normalization, activations and NVFP4 quantization, and a small programmable engine sequences the units without the host. Together they run a complete transformer layer (RMSNorm, FlashAttention and SwiGLU, 16 tokens) on the board in 139,244 cycles (2.8 ms). On the board, 60,416 of 60,416 tensor-core outputs equal those of an RTX 5090.
1Introduction
Neural networks spend most of their arithmetic in matrix multiplication, and the cost of each multiplication falls with the number of bits per operand. Recent GPUs therefore multiply 4-bit numbers. NVIDIA's NVFP4 format stores each element in 4 bits and gives each group of 16 elements a shared 8-bit scale [3]. Its tensor cores multiply such matrices and add the products into 32-bit floating-point (FP32) accumulators.
NVIDIA documents the formats and the instructions, but not the order in which a tensor core adds the products or where it rounds. These details decide the last bits of every result. A hardware design, a simulator or a numerical study that ignores them gives results that differ from the GPU in ways that are hard to explain. We take the rounding behavior from silicon, write it down as a precise contract, and build hardware that follows it exactly.
The hardware runs on an inexpensive test board with an AMD Artix-7 FPGA. A host computer controls it through a serial link. This document describes the complete design, and it is written so that a reader from outside computer architecture can follow it. §2 explains the background: floating-point rounding, 4-bit block-scaled numbers, tensor cores and FPGAs. §3 gives the system organization. §4 defines the arithmetic that the tensor core must reproduce, and §5 describes the tensor core. §6 describes the vector unit, and §7 the programmable engine and the transformer layer that it runs. §8 gives the verification method, §9 the cost and speed, and §10 the limitations.
Contributions. (1) A contract for NVFP4 and MXFP4 matrix multiply-accumulate, calibrated on an RTX 5090 and a Jetson AGX Thor. The two GPUs agree on all 920,079 test vectors, and the contract matches them on 600,005 of 600,054 random vectors. (2) A tensor core that implements the contract with 512 multiply-accumulates per cycle. It packs four 4-bit products into each multiplier slice of the FPGA, which saves a third of its logic. (3) A vector unit and a programmable engine with which the whole transformer layer runs on the device, with results that match an independent reference model. (4) A verification chain from a numerical model to the board, in which every level is compared with GPU silicon.
2Background
This section is for readers outside computer architecture. A reader who knows floating point and FPGAs can go to §3.
2.1Matrix multiplication
The product C = AB of an M × K matrix A and a K × N matrix B has M × N entries. Each entry is a dot product of length K: Cij = Σk Aik Bkj. One multiplication and one addition form a multiply-accumulate (MAC), so the product takes M N K MACs. A 64 × 256 by 256 × 64 product, the largest tile of our tensor core, takes 1,048,576 MACs. Hardware for matrix multiplication is fast when it does many MACs in parallel and when it reuses each operand that it reads from memory for many MACs. In a transformer, the layer that we run in §7, the matrix products compute the queries, keys and values, the attention scores, and the feed-forward network.
2.2Floating-point numbers and rounding
A floating-point number stores a sign, an exponent and a significand: x = (−1)s × 1.f × 2e. FP32 [11] uses 1 sign bit, 8 exponent bits and 23 fraction bits, so neighboring FP32 numbers differ by about one part in 224 of their size. This spacing is one unit in the last place (ULP). The exact result of an operation is usually not an FP32 number, so the hardware rounds it. Round-to-nearest-even (RNE) picks the nearest FP32 number and breaks ties toward an even last bit. Round-toward-zero (RZ) cuts off the extra bits.
Because every operation rounds, the order of operations changes the result. In FP32, 224 + 1 lies exactly between 224 and 224 + 2, and RNE rounds it down to 224. Thus (224 + 1) + 1 gives 224, but 224 + (1 + 1) gives 224 + 2. Two designs that add the same 64 products in a different order, or round at different points, can therefore return different bits. “Bit-exact” in this document means that our hardware returns the same 32 bits as the GPU for every input. For that, it must reproduce the order and the rounding points of the GPU, not only the mathematical result.
2.3Four-bit numbers with block scales
A 4-bit E2M1 number has 1 sign bit, 2 exponent bits and 1 mantissa bit. Its 16 codes give only 15 values: 0, ±0.5, ±1, ±1.5, ±2, ±3, ±4 and ±6 (Figure 1a). To store real data in this set, we divide the data by a scale so that the largest magnitudes land near 6, and round each quotient to the nearest E2M1 value. One scale for a whole tensor fits its largest values but wastes the few available values on the small ones. Block scaling solves this. NVFP4 gives each block of 16 consecutive elements its own scale, stored as an 8-bit UE4M3 number (an unsigned float with 4 exponent and 3 mantissa bits, up to 448), and adds one FP32 scale for the whole tensor [3] (Figure 1b). An element then costs 4.5 bits on average. MXFP4, an open standard [2], is similar but uses one power-of-two (E8M0) scale per 32 elements.
The product of two NVFP4 elements is the product of the two E2M1 values times the two block scales. A 64-element dot product thus has four blocks of 16 products, and each block has its own pair of scales. The tensor scales are applied once, after the matrix product.
2.4Tensor cores
A GPU tensor core is a unit that executes one small matrix multiply-accumulate per instruction. On the RTX 5090, the instruction mma.sync…m16n8k64 multiplies a 16 × 64 NVFP4 matrix by a 64 × 8 one and adds the result to a 16 × 8 FP32 accumulator [1]. A longer product, for example with K = 256, chains four such instructions: each takes the result of the previous one as its accumulator. The Jetson AGX Thor uses a different instruction family, tcgen05.mma, with the same formats. NVIDIA does not document how these instructions round. A public simulator, MMA-Sim [5], models them, but our measurements found cases in which it disagrees with silicon (§4).
2.5FPGAs
A field-programmable gate array (FPGA) is a chip whose circuit is defined after manufacture, by loading a configuration file called a bitstream. Our design is written in SystemVerilog, a hardware description language, and the vendor tool Vivado translates it into a bitstream. The chip provides four kinds of resources (Table 1). Look-up tables (LUTs) implement any logic function of up to six inputs. Flip-flops (FFs) store single bits. Block RAMs store data, 36 Kbit each. DSP slices are fixed multiplier-adder circuits. Our Artix-7 xc7a100t has 63,400 LUTs, 126,800 flip-flops, 135 block RAMs and 240 DSP slices [10]. These numbers are the budget of the whole design.
The circuit runs from a clock at 50 MHz. At each clock edge, every register (a group of flip-flops) takes a new value, and the logic between registers must settle within one period of 20 ns. The tool reports the worst negative slack (WNS): the margin of the slowest path. A positive WNS means that the design meets the clock. To keep paths short, a long computation is split into stages with registers between them. This is a pipeline: like an assembly line, it starts a new operation every cycle while earlier operations move through the later stages. Its latency is the number of cycles from input to result, and its throughput is the number of operations it starts per cycle.
2.6Memory-mapped devices
The units of our design communicate by reads and writes to addresses, as a processor talks to its peripherals. Each unit, called a device, owns a range of addresses. Some addresses are memory: a write stores data and a read returns it. Others are registers with an effect: a write to a control register starts an operation, and a read of a status register shows whether the operation is done. This method is memory-mapped I/O (MMIO). A bus carries the reads and writes. Our bus follows TileLink-UL [8]: a request (Get to read, PutFullData to write) travels to a device, and the device sends back one response. The data that the bus moves at one time is a beat. The host reaches the bus through a serial link that carries the Tethered Serial Interface (TSI) protocol [6], which packs reads and writes into bytes.
| Term | Meaning |
|---|---|
| MAC | multiply-accumulate: c ← c + a b |
| FP32 | IEEE 754 binary32: 1 sign, 8 exponent, 23 fraction bits |
| E2M1, UE4M3, E8M0 | 4-bit element; unsigned 8-bit scale with 4 exponent and 3 mantissa bits; 8-bit power-of-two scale |
| RNE, RZ | round to nearest, ties to even; round toward zero (truncate) |
| ULP | unit in the last place: the gap between neighboring floating-point numbers |
| Bit-exact | the same output bits as the reference for every input |
| M, N, K | rows of A and C; columns of B and C; the length of each dot product |
| LUT, FF | 6-input logic function; 1-bit storage element |
| Block RAM | on-chip memory block: RAMB36 (36 Kbit), or one half of it, RAMB18 |
| DSP slice | DSP48E1: a 25 × 18-bit multiplier with a pre-adder and a 48-bit adder |
| Pipeline, latency | a computation split into clocked stages; cycles from input to output |
| WNS | worst negative slack: timing margin of the slowest path; positive means the clock is met |
| MMIO | memory-mapped I/O: devices controlled by reads and writes to addresses |
| TSI, TL-UL | serial protocol of the host link; the bus protocol |
| Beat | the data a bus moves at once: 32 bytes (eight 32-bit words) on our device bus |
3System organization
A host computer talks to five devices over one bus. The tensor core multiplies matrices, the vector unit does the other arithmetic, the kernel engine moves data and starts the units, and the scratch memory holds the working data.
The device runs on a test board with an AMD Artix-7 FPGA (xc7a100tfgg484-1) at 50 MHz. A host PC drives it with PyUARTSI [6] through the board's USB–UART bridge at 921,600 Bd (Figure 2). The uart_tsi target decodes each TSI command into one TileLink-UL [8] request per 32-bit word. The device bus is wider: it moves 32-byte beats, eight words at a time. tl_widen places each host word in its lane of a beat, at the position given by its address.
An arbiter merges the host's requests with those of a second bus master, the kernel engine (§7.1). When both request, the master that did not go last wins. A crossbar routes each request to one of five devices by its address (Appendix Table A1). The bus has one transaction in flight, and a master keeps the bus until its response is accepted. The crossbar denies an address that no device owns: it drops a write and returns zero for a read.
The devices take beats in two ways. The scratch memory and the tile memory of the tensor core accept any words of a beat in one request, so a copy between them moves eight words per bus transaction. The register devices (the system registers, the vector unit and the kernel engine) take the words of a beat one at a time, through tl_narrow, at about two cycles per word. The vector unit has a second, private port to the scratch memory. Through it, the vector unit reads its operands and writes its results at one beat per cycle, and this traffic does not use the bus.
A host session. To multiply two matrices with the tensor core alone, the host writes A, B and their scales into the tile memory, writes the dimensions and a start bit, polls a status register, and reads C. The serial link is the slow part: loading a full 64 × 64 × 256 tile and reading the result takes about 0.6 s, against 51.2 µs of computation. For this reason, the complete transformer layer of §7 runs on the device. The host uploads the inputs, the weights and one program, and then reads back only the results.
tl_narrow. The vector unit reads and writes the scratch memory through its own port (green). Highlighted: the tensor core.4Target arithmetic
This section states exactly which 32 bits the tensor core must return for each input. We took this contract from GPU silicon, because NVIDIA does not publish it.
Formats. An NVFP4 tensor stores elements in E2M1, one UE4M3 scale for each block of 16 consecutive elements along K, and one FP32 scale for the whole tensor (§2.3). MXFP4 [2] instead uses one E8M0 power-of-two scale per 32 elements. Blackwell tensor cores also accept E8M0 per 16 elements. The core supports these three formats and unscaled FP4 (Table 2).
mma.sync…m16n8k64 shape on sm_120a [1].| Mode | Format | Block scale | Block | Silicon reference |
|---|---|---|---|---|
| 0 | NVFP4 | UE4M3 | 16 | kind::mxf4nvf4, scale_vec::4X, ue4m3 |
| 1 | MXFP4 | E8M0 | 32 | kind::mxf4nvf4, scale_vec::2X, ue8m0 |
| 2 | FP4 | none | – | mode 3 with every scale equal to 20 |
| 3 | MXFP4-16 | E8M0 | 16 | kind::mxf4nvf4, scale_vec::4X, ue8m0 |
Unit contract. One processing element (PE) computes d = c + Σk<64 ak bk sA(k) sB(k). The sum runs over 64 elements in four 16-element blocks, sA(k) and sB(k) are the block scales of element k, and the accumulator c is FP32. The contract below is rule rtx5090 of our calibrated model (tcgen05/nvfp4_tcgen05_check.py). The model started from MMA-Sim [5], and we corrected it wherever an RTX 5090 (mma.sync, sm_120a) disagreed. A Jetson AGX Thor (tcgen05.mma, sm_110a) and the RTX 5090 returned the same bits on all 920,079 of our test vectors, so one contract covers both GPUs. Each block sum is exact:
Products of E2M1 values are multiples of 1/4 and |σg| ≤ 576, so σg fits a short fixed-point word. We normalize each scale code to s = (S/8)·2e with a 4-bit integer S. For a UE4M3 code with exponent field E and mantissa m, or an E8M0 code x:
UE4M3 code 0x7F and E8M0 code 0xFF are NaN, and bit 7 of a UE4M3 code is ignored. Block g contributes γg = σg sA,g sB,g at exponent Xg = eA,g + eB,g. The accumulator c has exponent Xc = max(Ec − 127, −126), where Ec is its biased exponent. With emax = max(Xc, X0, …, X3), the result is
where RZ32 truncates a real number to binary32. On overflow it returns ±∞ rather than the largest finite value, as the silicon does. In words: the hardware lines up the five terms (the four block sums and c) at the exponent of the largest one, cuts every term off 35 bits below that exponent, adds the five exactly, and cuts the sum to FP32.
Departures from exact arithmetic. Three properties of Eq. (3) separate it from a correctly rounded dot product, and a bit-exact implementation must keep all three. First, every term, c included, is truncated to 35 fractional bits below emax before the sum, so a small c can vanish. Second, a block takes its exponent Xg from its scales even when σg = 0. A zero block with a large scale therefore still moves the truncation point. Third, the final conversion truncates instead of rounding to nearest.
Special cases. These override Eq. (3) in the order given. A NaN in a used scale, or a NaN c, gives 0x7FFF_FFFF. An infinite c passes through. If all 64 products are zero, d = c, with −0 replaced by +0. MMA-Sim lacks this last rule, and 816 vectors of our first GPU run depended on it.
Model accuracy. The contract still differs from silicon on 49 of 600,054 random vectors (0.008%). In 15 of them, a zero block with a large scale sets the alignment point by a rule we have not yet identified. The other 34 are 28 subnormal and 6 normal outputs that differ by one unit in the last place. The hardware implements the contract, so it inherits these differences.
Tensor scales. The FP32 per-tensor scales are not part of the MMA. NVIDIA GEMMs apply them after the product as the epilogue factor α. Likewise, our kernel multiplies C by sAsB on the vector unit (§7.2).
5Tensor core
The tensor core is a grid of eight processing elements. Each one computes a 64-element dot product by the contract of §4, and the grid starts eight of them every cycle: 512 multiply-accumulates.
The tensor core, nvfp4_tc, owns 64 KiB at 0x1000_0000. This space holds its registers and the block RAMs for the operand tiles A and B and the accumulator tile C (Appendix Table A2). A tile is up to 64 × 64 × 256 (M × N × K). This section describes the processing element (§5.1), the grid and its memory (§5.2), the mapping of the products onto DSP slices (§5.3), and the schedule (§5.4).
5.1Processing element
The PE, fp4_fedp, evaluates Eq. (3) in a five-stage pipeline. It accepts one operation per cycle, and each result is ready five cycles after its operands (Figure 3). The block sums reuse the exact datapath of nvfp4-dotprod-formal-dv [4]: mul_lane_nvfp4, align_nvfp4 and exact_acc_tree, which upstream verified with formal and UVM testbenches. On our board, that datapath alone matched its exact golden model on 1.1 M vectors and the RTX 5090 on 100,008. We designed the fused accumulation that follows the block sums.
Stage 1 forms the 16 products of each block and sums them exactly. It also decodes the eight scale bytes by Eq. (2), forms SA,gSB,g and Xg, and evaluates the special-case conditions. Stage 2 multiplies each block sum by SA,gSB,g in a DSP slice. The result is an integer Tg = 4σg SA,gSB,g with |Tg| ≤ 2304 · 225 < 219, and γg = Tg · 2Xg − 8. In the same stage, the five exponents reduce to emax. Stage 3 expresses each magnitude in units of 2emax − 35 and shifts it right by emax − X. The shift implements the floor of Eq. (3) (Figure 4). The aligned block terms are 48 bits wide and the aligned c is 37 bits. Stage 4 adds the five signed terms exactly in 51 bits. Stage 5 finds the leading one, truncates to binary32, handles overflow and subnormal results, and applies the special cases.
Integer arithmetic makes the PE exact by construction: no step between the inputs and the final cut rounds, except the deliberate truncation of stage 3. Out of context, one PE uses 4,084 LUTs, 548 flip-flops and 4 DSP slices, and it meets 50 MHz with 7.8 ns of slack. Its 64 products take 1,280 of these LUTs; §5.3 moves them into DSP slices.
5.2Grid and on-chip memory
Eight PEs form a 2 × 4 grid (Figure 5). Each cycle, the grid receives one 64-element K chunk of two rows of A and four columns of B. Every row of A feeds four PEs and every column of B feeds two, so the grid updates a 2 × 4 block of C with 512 MACs from 6 operand reads. In our microbenchmark, one RTX 5090 streaming multiprocessor sustains 2,048 NVFP4 MACs per cycle with four tensor cores, so each GPU tensor core has the same 512-MAC rate. In the default build, the eight PEs compute their products together in DSP slices (§5.3), and each PE keeps its own stages 2–5.
The PE width equals the K of the m16n8k64 instruction. With this width, the roundings of a K chain fall where the GPU puts them: an output with K = 256 is rounded four times on both. A 2 × 8 grid of 32-element units has the same MAC rate, but it rounds at twice as many points, so it cannot reproduce the GPU.
Memory. All tile storage is simple dual-port block RAM with one write port and one read port, in one RAMB18 each. The RAMs are banked so that one read of each delivers a full chunk to the grid (Table 3). Row i of A is in bank i mod 2 and column j of B in bank j mod 4. C[i][j] is in lane (i mod 2, j mod 4) at entry (⌊i/2⌋, ⌊j/4⌋). Each bank splits a 64-element chunk across eight 32-bit word lanes and keeps the chunk's four scale bytes in one more lane. The eight word lanes match the eight words of a bus beat, so one bus request reads or writes a whole chunk of a row in one cycle. The host and the sequencer share the RAM ports. The bus uses them while the core is idle. While the core runs, it serves only register reads, and other accesses wait.
| Memory | Organization | RAMs | Entries | Location |
|---|---|---|---|---|
| A elements | 2 banks × 8 word lanes | 16 | 128 | row i: bank i mod 2, entry (⌊i/2⌋, kc) |
| A scales | 2 banks × 1 lane | 2 | 128 | as the elements |
| B elements | 4 banks × 8 word lanes | 32 | 64 | column j: bank j mod 4, entry (⌊j/4⌋, kc) |
| B scales | 4 banks × 1 lane | 4 | 64 | as the elements |
| C | 8 lanes | 8 | 512 | C[i][j]: lane (i mod 2, j mod 4), entry (⌊i/2⌋, ⌊j/4⌋) |
5.3Products in DSP slices
Out of context, the 64 E2M1 products of one PE take 1,280 LUTs, and its four adder trees take 452. A signed product depends on all eight bits of its two codes, more than one 6-input LUT takes, so each product costs about 20 LUTs. In the 2 × 4 grid, the products alone take about 10,000 LUTs, a third of the tensor core. The Artix-7 has 240 DSP48E1 slices, and the rest of the design uses 36 of them, for the nine FP32 multipliers of the vector unit. A slice has a 25-bit pre-adder, a 25 × 18-bit signed multiplier and a 48-bit post-adder [10]. With packed operands, one multiply gives four products.
Packing. Let x̂ = 2x denote an E2M1 value as an integer, x̂ ∈ {0, ±1, ±2, ±3, ±4, ±6, ±8, ±12}, so that |â b̂| ≤ 144. Let â0 and â1 be element k of rows 0 and 1 of A, and b̂0 and b̂1 element k of columns 2p and 2p + 1 of B. One slice computes
the 2 × 2 block of products of element k, in four 10-bit fields (Figure 6). This is the long multiplication of school arithmetic: the two factors are short numbers placed far apart in one wide word, so the partial products do not overlap. The pre-adder forms the first factor from ports D and A. LUTs form the second factor from the two rows of A; it enters port B, and both column pairs share it. Two slices add elements 2i and 2i + 1 and a bias β:
A sum of two products lies in [−288, 288], so each field of Pi holds a pair sum plus 512, in [224, 800]. No field is negative, so no field borrows from the one above it, and Pi is four unsigned 10-bit fields side by side. For one output and one block, eight fields add to 4σg + 4096, which lies in [0, 8192). Inverting bit 12 of this sum gives 4σg in two's complement. The tree of unsigned fields costs 55 LUTs per block sum; a tree of signed fields, with a carry-in to correct each borrow, costs 74.
Slice pair. Figure 7 shows a slice pair as Vivado maps it. The first slice multiplies element 2i + 1, and the fabric routes its product to the C port of the second slice. The second slice multiplies element 2i and adds the two products. A carry chain in the fabric adds β, and 40 flip-flops hold the result. Without β, Vivado places this adder and register in the second slice; with the constant β, it keeps both in the fabric. No slice register is used, so the products stay in stage 1 and the PE latency stays five cycles. The block-sum trees move to the start of stage 2, before the multiply by SASB.
Grid. The grid has two column pairs and 32 element pairs per chunk, so 2 × 32 × 2 = 128 slices compute its 512 products per cycle (Figure 8). Each output needs 16 slices for its products and 4 for its block terms (Table 4). A power-of-two grid larger than 2 × 4 therefore does not fit in DSP slices; the parameter DSP = 0 of nvfp4_tc restores the LUT products for such grids. Both builds give the same outputs. In two builds with the same bus, the DSP products cut the tensor core from 31,496 to 21,312 LUTs (32%).
fp4_fedp_dsp). The packed A operand is formed once and feeds both column pairs. The grey bar is the stage-1 register of Figure 3. Stages 2–5 are those of Figure 3, one copy per output, with the tree replacing the stage-1 block sum. Not drawn: the all-zero check per output, which reads the element codes directly.xc7a100t.| Function | Operands | Per output | Slices |
|---|---|---|---|
| E2M1 products, Eqs. (4)–(5) | 25 × 18 b, pre-adder | 16 | 128 |
| Block terms Tg = 4σg·SASB | 13 × 9 b | 4 | 32 |
| Vector unit: nine FP32 ALUs, one 32 × 32-bit multiplier each | 32 × 32 b | – | 36 |
| Total | 196 (82%) |
5.4Dataflow and scheduling
The sequencer runs the weight-stationary loop nest of Algorithm 1. "Weight-stationary" means that the operand B, which holds the weights of a neural-network layer, stays in place while the rows of A stream past it. For each block of four columns of B and each K chunk, the sequencer reads that chunk of B once and holds it in the RAM output registers. It then issues one block of two rows of A per cycle against the held weights. An issue reads A and C at cycle t. The PEs receive the operands at t + 1, and the sequencer writes the result to C at t + 6 (Figure 9, top). A 16-entry write-back FIFO carries the C address of each operation in flight.
- input: dimensions (M, N, K), mode, OVERWRITE
- for jb ← 0 to N/4 − 1 do ▷ column block of B and C
- for kc ← 0 to ⌈K/64⌉ − 1 do ▷ K chunk
- LOAD B[jb, kc] into the B RAM output registers ▷ 1
- mask ← (K mod 64 = 32) ∧ (kc = ⌈K/64⌉ − 1) ▷ K tail
- for ib ← 0 to M/2 − 1 do ▷ 1 each
- ISSUE: read A[ib, kc] and C[ib, jb]; push (ib, jb) to the write-back FIFO
- c ← 0 if OVERWRITE ∧ kc = 0 else C[ib, jb]
- C[ib, jb] ← PE(A[ib, kc], B[jb, kc], c, mask) on all 2 × 4 PEs ▷ written at issue + 6
- DRAIN until no operation is in flight ▷ 7
Hazards. The next K chunk reads the C entries that the current chunk writes. The sequencer does not forward results. Instead, it drains the pipeline before it advances K. The drain costs seven cycles per group and keeps the core correct for every M, including M = 2, where the same C entry is read and written in consecutive groups. A run takes
A full 64 × 64 × 256 tile takes 2,560 cycles (51.2 µs), of which 2,048 are issue cycles (Figure 9, bottom). Small tiles pay the load and drain cost per group: a run with M = 2 issues in one cycle of every nine.
K tails. The memory layout fixes the chunk at 64 elements, but K may be any multiple of 32. When K = 64n + 32, the sequencer marks the last chunk (line 5 of Algorithm 1). The grid then zeroes the elements of A past K and the scales of A and B past K. In MXFP4 with 32-element blocks, only scale byte 0 is kept. The zero elements make the padding products zero. The zero scales give the padding blocks exponent −252. This is below Xc ≥ −126, so the padding cannot move emax in Eq. (3). The result equals an m16n8k64 MMA on operands zero-padded with zero scales. The transformer layer depends on this case, because its products have K = 32.
6Vector unit
The vector unit does every operation of the transformer layer that is not a matrix product: additions and scaling, the softmax of attention, normalization, activation functions, and the conversion of FP32 data to NVFP4.
6.1FP32 lanes
The vector unit, flash_vector at 0x1001_0000, has eight lanes (Figure 10). Each lane has its own FP32 arithmetic unit (ALU), fp32_alu, which adds, subtracts, multiplies, takes the maximum, and computes 2x (EXP2) and 1/x (RECIP). The ALU works on one operation at a time over several cycles, and it registers every intermediate step, so its paths stay short. One 32 × 32-bit integer multiplier, four DSP slices, serves multiplication, EXP2 and RECIP. All arithmetic rounds to nearest even. Subnormal inputs and results become zero with their sign kept, as with the .ftz instructions of a GPU, and every NaN result is 0x7FFF_FFFF.
A GPU computes 2x and 1/x approximately, in special function units. The PTX specification bounds their error at 2 and 1 ULP [1], but it does not publish the method. Our ALU uses its own approximations. EXP2 looks up 2f in a 64-entry table and corrects the remainder with a cubic polynomial. RECIP starts from a 128-entry table and refines the estimate with two Newton steps. Against the RTX 5090's ex2.approx.ftz and rcp.approx.ftz, the results are within 2 and 1 ULP. The lanes build further operations from these steps (Table 5). AXPY multiplies and then adds, with two roundings. RSQRT brings the mantissa into [1, 4), runs four Newton steps and applies the exponent. SILU computes x · 1/(1 + 2−x log2 e).
A ninth ALU runs the steps that combine lanes, in lane order 0 to 7: the MAX and SUM reductions, the row maximum, α and the probability sum of SOFTMAX, and the reciprocal of NORMALIZE. Because these steps always run in lane order, every result equals a serial evaluation in lane order. The unit is deterministic, and a model of it does not depend on the number of lanes.
| Op | Name | Result |
|---|---|---|
| 0–2 | ADD, SUB, MUL | x + y, x − y, x · y |
| 3 | SCALE | x · σ |
| 4 | AXPY | RNE(RNE(x · σ) + y) |
| 5, 6 | MAX, SUM | x; the reduction over the masked lanes goes to a register |
| 7, 8 | EXP2, RECIP | 2x, 1/x, approximate |
| 9 | SOFTMAX | pj of Eq. (7); m, l and α go to registers |
| 10 | NORMALIZE | x · (1/σ), or 0 if σ = 0 |
| 11–13 | RSQRT, SILU, ABS | 1/√x, x / (1 + e−x), |x| |
| 14 | QUANT | rows of NVFP4 blocks, Eq. (8) (§6.4) |
6.2Streaming commands
One command processes a whole vector. The host or the kernel engine writes the command as one 32-byte beat to offsets 0x20–0x3C: the scratch addresses X, Y and D, the number of 8-element groups and a lane mask, the scalar, the running softmax state, and the opcode. The last word starts the command (Appendix Table A3). The unit then streams: group g reads its operands from X + 32g (and Y + 32g), and its eight results go to D + 32g. While the lanes work on one group, the port fetches the next one. For MAX and SUM, the combining ALU folds the group reductions left to right into the REDUCTION register. The unit rejects a command with a misaligned or out-of-range address, zero groups, or SOFTMAX on more than one group, and sets a status bit. A 1,024-element SiLU, for example, is one command of 128 groups.
6.3Online softmax
Attention gives each query a weighted average of the value vectors Vj. The weights are the softmax of the scores sj: pj = exp(sj − m) / Σk exp(sk − m), where subtracting the maximum score m keeps the exponentials from overflowing. FlashAttention [9] computes this one block of keys at a time, so the full matrix of scores never exists in memory. It keeps three running values per query row: the maximum m, the sum l and the unnormalized output O. When a later block raises the maximum, a factor α corrects the earlier sum and output [14]. With λ = log2(e)/√d for heads of width d, one key block updates a row as
and the output is O/l after the last block. Masked keys, used for causal attention, get pj = 0; α = 0 while lold = 0. A SOFTMAX command computes mnew, α, pj and lnew for one row of eight scores, and the tensor core computes ΣpjVj. AXPY then updates O, and NORMALIZE divides by l at the end. The state stays in FP32 between blocks. Against an ordered CUDA reference on the RTX 5090, tiled attention on the vector unit differs by at most 2.4 × 10−7.
6.4NVFP4 quantization
Before each matrix product, the activations, which the vector unit holds in FP32, must become NVFP4. QUANT does this on the device. For each block of 16 elements xi and the inverse tensor scale v, it computes the block scale s and the element codes qi as
where RNEE2M1 saturates at ±6. Dividing by 6 maps the largest element of a block to the largest E2M1 value. Algorithm 2 gives the steps. The lanes compute every scaled element RNE(xi · v) in two passes of eight. Meanwhile, a scan finds the element of largest magnitude. Rounding is symmetric and never reverses an order, so the scaled value of that element already equals RNE(max |xi| · v), and the scale needs no extra multiply. The codes of a row go to D + 128r + 8b, and its scale bytes to Y + 16r. These are the row layouts of the tensor core's tile memory (Appendix Table A2), so one COPY moves the result into the tensor core. A block takes about 38 cycles. QUANT rejects a block with a NaN or infinite element, or one whose scaled maximum overflows.
- input: x0 … x15 from X; the inverse tensor scale v = SCALAR
- for i ← 0 to 15 do pi ← RNE(xi · v) ▷ 8 lanes, 2 passes
- k ← index of the largest |xi|; subnormal xi count as 0 ▷ 16-cycle scan, during line 2
- if some xi is not finite, or pk = ±∞ then reject ▷ status bit
- s ← RNEUE4M3(RNE(|pk| · RNE(1/6))) ▷ 1 lane pass, scale encoder
- t0 … t6 ← s × the midpoints between E2M1 magnitudes ▷ exact, 1 cycle
- for i ← 0 to 15 do qi ← code of |pi| against t, ties to even, with the sign of pi ▷ 8 per cycle
- write q to D + 128r + 8b and s to byte b of Y + 16r ▷ vector port
7Kernel engine and transformer layer
The kernel engine is a small processor that sequences the other devices. With it, a whole transformer layer runs on the FPGA from one uploaded program, and the host only loads the inputs and reads the results.
7.1Kernel engine
The kernel engine, kernel_engine at 0x1002_0000, executes a program of up to 8,192 64-bit instructions with 16 integer registers (Appendix Table A4). It fetches and executes an instruction in two cycles, plus the bus time of the instruction. Most instructions are ordinary integer arithmetic and branches. Four of them use the bus, on which the engine is a second master next to the host. LOAD and STORE move one word. COPY moves n words: each step reads up to eight words in one beat and writes them in one beat, and it rotates the words when the source and destination have different offsets within a beat. WAIT reads a status word until its busy bits clear, and it stops the program with a fault if an error bit is set.
A program starts a vector command with one COPY of the command beat from scratch memory to the vector unit, and then WAITs for it. The compiler prepares every command beat in scratch memory in advance. When a word of the command depends on an earlier result, such as the normalization factor of RMSNorm or the running softmax state, a one-word COPY patches that word first. A program starts the tensor core in the same way: COPYs move the operand rows into the tile memory, register writes set the format and the dimensions and start it, a WAIT polls its status, and a loop of COPYs moves C out.
7.2The transformer layer
The layer is a pre-norm transformer block [15]: h = x + Attention(RMSNorm(x)) and y = h + FFN(RMSNorm(h)). RMSNorm [12] divides each row by the root of its mean square and multiplies it by a learned γ. The feed-forward network is SwiGLU [13]: FFN(n) = Wdown(SiLU(Wgaten) ⊙ Wupn). The shape is fixed: 16 tokens, width 32, one attention head of width 32, and a feed-forward width of 64. Attention is causal or dense. Figure 11 shows the dataflow.
The host quantizes the weights to NVFP4 once. The device quantizes every activation with QUANT before it enters a matrix product. Activations and weights use the tensor scale 1/64, and softmax probabilities use 1/2688. These are fixed calibration constants, not values measured at run time. After each product, a SCALE command multiplies C by the product of the two tensor scales. Attention processes the queries in pairs, the 2 rows of the grid, and the keys in tiles of 8. For each pair and tile, the tensor core computes the scores S = Q KT (2 × 8 × 32), SOFTMAX updates the state of both rows, QUANT converts the probabilities, and the tensor core computes P V with K = 32. V is transposed and padded so that its 8 keys form the first 8 elements of each column.
The compiler, host/transformer.py, unrolls all loops over rows and query pairs, so every address and every causal mask is a constant. The program has 4,071 instructions and uses 108,896 bytes of scratch memory for inputs, weights, intermediate results and 371 command beats. It runs 39 matrix products and 371 vector commands, of which 24 are QUANT. An independent model in Python, host/transformer_model.py, computes the same layer with the same quantization and the same FP32 operation order.
7.3Results and where the time goes
The layer runs on the board with the outputs that the reference predicts (Table 6). The final outputs equal the reference bit for bit on both inputs. The intermediate RMSNorm results differ from the reference by at most 4.8 × 10−7, and those of attention and SwiGLU by at most 6.0 × 10−8, because the reference rounds 2x, 1/√x and SiLU to nearest, while the device approximates them. The final quantization absorbs these small differences on both inputs. This is an observation, not a guarantee for every input.
| Input | Attention | Cycles | Time | Final max. error |
|---|---|---|---|---|
| seed 3 | causal | 139,244 | 2.785 ms | 0 |
| seed 11 | dense | 140,924 | 2.818 ms | 0 |
The tensor core computes for only 2,592 of these cycles (Figure 12). The layer is small: its 39 matrix products are short, and most of them have M = 2 or K = 32, which pay the load and drain cost of Eq. (6) for few issue cycles. The time goes to the vector unit (45%), to the copies of operands and results between scratch memory and the tile memory (23%), to instruction issue (9%), and to other bus transfers and waits (23%). The kernel engine waits for each command before it issues the next, so the units do not overlap. §10 discusses this.
8Verification methodology
Every level of the design, from the numerical model to the programmed board, is compared with GPU silicon or with a model that silicon has confirmed.
Reference chain. Silicon is the reference, and two models stand in for it where silicon cannot be run. The silicon harness places each 64-element test vector in every row of A and every column of B of one block-scaled mma.sync…m16n8k64 on the RTX 5090, and all 128 outputs must agree. The fragment layout follows CUTLASS 4.6.1 [7] (MMA_Traits<SM120_16x8x64_TN_VS>), and 4,228 probes confirmed it before any test vector ran. For K > 64, we compare an output with a chain of MMAs, each of which takes the previous GPU result as c. The two models are rule rtx5090 of §4, written in floating-point Python, and nvfp4_model, an independent integer model of Eqs. (1)–(3) that the grid and system tests use.
Stimuli. PE vectors include uniform codes, runs of ±6 that cancel, zero and constant vectors, and every finite scale code. The scale codes include subnormals and 0x79–0x7E, which are finite on silicon but NaN in one public reference model. They also include NaN scales. The accumulator c is drawn from zeros of both signs, uniform values, exponents from 2−30 to 230, and special values. System runs mix full and partial tiles, all formats, overwrite, accumulation, and continuation from the previous C. The DSP grid is tested as a 2 × 2 block whose rows are (a, b) and columns (b, a) of each vector, so its four fields carry a·b, a·a, b·b and b·a. Vectors with all elements +6 against all −6 drive the fields to both ends of [224, 800].
Vector unit and layer. A CUDA program runs the same FP32 operations on the RTX 5090 with the .ftz PTX instructions and with fused multiply-add disabled. Exact operations must agree bit for bit, and approximate ones within fixed ULP bounds. QUANT is compared with the GPU's native conversions to E4M3 and E2M1, and with the Python quantizer for whole rows. The kernel engine has directed tests for every instruction, for COPY between all word offsets, and for each fault. The layer runs on the cycle-accurate simulation of the SoC and on the board, and is compared with the independent reference of §7.2.
Levels. Table 7 lists the levels from the arithmetic model to the board. Three of the 420,025 PE vectors differ from silicon, and all three are instances of the model gaps of §4. For comparison, the open-source Allegro unit [5] differed from the RTX 5090 on 651 of 100,009 NVFP4 vectors (0.65%). Most of those differences came from all-zero products and a small c.
nvfp4_model unless stated otherwise. A count is the number of outputs that agree bit for bit; NaNs compare equal regardless of payload.| Level | Device under test | Reference | Agree / total |
|---|---|---|---|
| Model | rule rtx5090 | RTX 5090 and Jetson Thor, random vectors | 600,005 / 600,054 |
| Model | nvfp4_model | rule rtx5090 | 420,025 / 420,025 |
| PE | fp4_fedp, Verilator | rule rtx5090 | 420,025 / 420,025 |
| PE | fp4_fedp, Verilator | RTX 5090: NVFP4; MXFP4-16; MXFP4 vectors | 300,025 / 300,025; 13,359 / 13,359; 6,640 / 6,641 |
| PE | fp4_fedp, Verilator | RTX 5090, new random vectors, 4 modes | 99,998 / 100,000 |
| PE | fp4_fedp_dsp 2 × 2, Verilator | rule rtx5090, 4 outputs per vector | 1,680,136 / 1,680,136 |
| PE | fp4_fedp_dsp 2 × 2, Verilator | RTX 5090, output a·b, stored and random vectors | 420,022 / 420,025 |
| Grid | nvfp4_tc, direct MMIO, 18 runs | model | 6,016 / 6,016 |
| System | SoC through PyUARTSI, Verilator | model | 18,824 / 18,824 |
| System | SoC through PyUARTSI, Verilator | RTX 5090 MMA chains | 14,880 / 14,880 |
| Vector | FP32 ALU primitives | RTX 5090 PTX, 20,416 records | ADD, MUL, MAX exact; EXP2 ≤ 2, RECIP ≤ 1 ULP |
| Vector | RSQRT, SILU commands | RTX 5090 PTX | ≤ 2 ULP, ≤ 3 ULP |
| Vector | tiled attention, dense and causal | ordered CUDA reference | max. error 2.4 × 10−7 |
| Vector | QUANT | RTX 5090 E4M3 and E2M1 conversion | 205 / 205 blocks |
| Board | FPGA, 30 runs, 12.6 M MACs | model and RTX 5090 MMA chains | 60,416 / 60,416 |
| Board | transformer layer, 2 inputs | quantized reference, §7.2 | final error 0 |
9Implementation
We implement the design with Vivado 2024.2 at 50 MHz (Table 8). The SoC uses 88% of the LUTs, 60% of the block RAM and 82% of the DSP slices, and it meets timing with 1.390 ns of slack. The vector unit is the largest block: its nine FP32 ALUs, the QUANT encoders and the staging registers take 25,803 LUTs. The tensor core takes 21,909 LUTs and 160 DSP slices. Most of its logic is in stages 2–5 of the PEs, about 2,400 LUTs per output: alignment takes about 1,100 of them and the cut to FP32 about 700. The field registers of §5.3 add 2,560 flip-flops.
The critical path, 18.5 ns over 11 logic levels, runs from a B RAM output through the operand decode and a slice pair to the field register (Figure 7). QUANT's path from a lane result through the scale encoder has 1.46 ns of slack. With the products in LUTs, the tensor core used 31,496 LUTs, and its worst path, through the products and the adder tree, had 0.3 ns of slack. The serial link dominates end-to-end time: loading A and B and reading C for a full tile takes about 0.6 s, against 51.2 µs of compute.
xc7a100t at 50 MHz. The first group is out of context. The second is the release build, by unit. The last row is the tensor core with LUT products (DSP = 0), from a build with a 32-bit bus.| Component | LUT | FF | Block RAM | DSP | WNS (ns) |
|---|---|---|---|---|---|
One PE, LUT products (fp4_fedp) | 4,084 | 548 | 0 | 4 | +7.846 |
2 × 4 PEs, DSP products (fp4_fedp_dsp) | 21,625 | 6,917 | 0 | 160 | +7.846 |
Tensor core (nvfp4_tc) | 21,909 | 7,692 | 62 RAMB18 | 160 | – |
Vector unit (flash_vector) | 25,803 | 9,260 | 1 RAMB36 + 9 RAMB18 | 36 | – |
| Kernel engine | 5,514 | 1,156 | 13 RAMB36 | 0 | – |
| Scratch memory | 4 | 3 | 32 RAMB36 | 0 | – |
| Bus, UART TSI, system registers, clock | 2,494 | 2,214 | 0 | 0 | – |
| SoC, all units | 55,724 (88%) | 20,325 (16%) | 46 RAMB36 + 71 RAMB18 (60%) | 196 (82%) | +1.390 |
| Tensor core, LUT products | 31,496 | 4,610 | 62 RAMB18 | 32 | – |
10Limitations
Scope. The transformer layer has a fixed shape, one attention head, and tensor scales that are fixed constants rather than measured at run time. It has no positional encoding, no key-value cache and no backward pass. The compiler can add these without a change to the hardware or to the upload protocol.
Arithmetic. Only the matrix products are bit-exact with the GPU. The vector unit's EXP2, RECIP, RSQRT and SILU are within a few ULP of the GPU's instructions, but not bit-equal to them, and production attention kernels may also use fused multiply-add and other reduction orders. The contract of §4 still misses 49 of 600,054 random vectors, and the hardware inherits these differences. We compared the contract with an RTX 5090 and a Jetson AGX Thor; B200 and B300 silicon is untested.
Speed. The kernel engine waits for each command to finish before it issues the next one, so the tensor core, the vector unit and the copies never overlap. Because the vector unit has its own scratch port, a compiler could run vector commands during the tensor-core copies, which together take 68% of the layer. The host link runs at 921,600 Bd and limits every transfer between the host and the board. The FPGA is 88% full, so a larger tensor core needs a larger device.
References
- NVIDIA. Parallel Thread Execution ISA: warp-level
mmawith block scaling;ex2.approxandrcp.approx. docs.nvidia.com/cuda/parallel-thread-execution - Open Compute Project. OCP Microscaling Formats (MX) Specification, version 1.0, 2023. opencompute.org
- NVIDIA. Transformer Engine documentation: NVFP4. docs.nvidia.com/deeplearning/transformer-engine
- sashakatne. nvfp4-dotprod-formal-dv, commit 125db59. github.com/sashakatne/nvfp4-dotprod-formal-dv
- roundandr. Allegro, commit ac5b2a4, with its MMA-Sim reference model. github.com/roundandr/Allegro
- UC Berkeley Architecture Research. PyUARTSI and the UART TSI specification. github.com/ucb-bar/pyuartsi
- NVIDIA. CUTLASS 4.6.1,
MMA_Traits<SM120_16x8x64_TN_VS>. github.com/NVIDIA/cutlass - SiFive. TileLink Specification, TL-UL conformance level.
- T. Dao. FlashAttention-2: faster attention with better parallelism and work partitioning. 2023. arXiv:2307.08691
- AMD. 7 Series DSP48E1 Slice User Guide (UG479) and 7 Series FPGAs Data Sheet: Overview (DS180).
- IEEE. IEEE Standard for Floating-Point Arithmetic, IEEE 754-2019.
- B. Zhang and R. Sennrich. Root mean square layer normalization. NeurIPS 2019. arXiv:1910.07467
- N. Shazeer. GLU variants improve Transformer. 2020. arXiv:2002.05202
- M. Milakov and N. Gimelshein. Online normalizer calculation for softmax. 2018. arXiv:1805.02867
- A. Vaswani et al. Attention is all you need. NeurIPS 2017. arXiv:1706.03762
ARegister and memory maps
All devices take whole 32-bit words and deny a partial write. Addresses of words are multiples of 4.
| Base | Size | Device | Bus port |
|---|---|---|---|
0x0000_0000 | 4 KiB | sys_regs: link identification and status | words |
0x1000_0000 | 64 KiB | nvfp4_tc: tensor core and its tile memory (Table A2) | beats |
0x1001_0000 | 64 KiB | flash_vector: vector unit (Table A3) | words, and its own scratch port |
0x1002_0000 | 128 KiB | kernel_engine: kernel engine (Table A4) | words; also a bus master |
0x2000_0000 | 128 KiB | scratch_memory | beats |
In the tensor core, offsets are relative to 0x1000_0000. In A and B, element k of a row or column is nibble k, low nibble first.
nvfp4_tc.| Offset | Name | Access | Contents |
|---|---|---|---|
0x0000 | ID | RO | 0x4E56_5443 ("NVTC") |
0x0004 | TILE | RO | maximum tile {M[31:24], N[23:16], K[15:0]} = 0x4040_0100 |
0x0008 | ARRAY | RO | {PM, PN} = 0x0204 |
0x000C | CTRL | WO | bit 0 START: C = A × B + C; with bit 1 OVERWRITE: C = A × B |
0x0010 | STATUS | RO | bit 0 busy; bit 1 the last START was rejected |
0x0014 | MODE | RW | Table 2 |
0x0018 | DIMS | RW | {M, N, K} of the next START: M a multiple of 2, N of 4, K of 32 |
0x001C | OPS | RO | completed STARTs |
0x0020 | CYCLES | RO | cycles of the last START, Eq. (6) |
0x0024 | PK | RO | elements per PE, 64 |
0x2000 | A | RW | 64 rows × 128 B |
0x4000 | SFA | RW | 64 rows × 16 B; byte g scales elements 16g to 16g + 15 |
0x6000 | B | RW | 64 columns × 128 B |
0x8000 | SFB | RW | 64 columns × 16 B |
0xC000 | C | RW | 64 × 64 FP32, row-major; C[i][j] at 0xC000 + 256i + 4j |
flash_vector, relative to 0x1001_0000. Offsets 0x20–0x3C are one 32-byte command beat; the write of CTRL with bit 0 set starts the command. Writes wait while a command runs; reads do not.| Offset | Name | Access | Contents |
|---|---|---|---|
0x00 | ID | RO | 0x4656_4543 ("FVEC") |
0x04 | LANES | RO | 8 |
0x08 | STATUS | RO | bit 0 busy; bit 1 the last command was rejected |
0x10–0x1C | REDUCTION, MAX, SUM, ALPHA | RO | reduction over all groups; m, l and α of the last group |
0x20–0x28 | X, Y, D | RW | scratch addresses, 32-byte aligned |
0x2C | GROUPS | RW | groups [15:0], MASK [23:16]; QUANT: rows, blocks per row |
0x30 | SCALAR | RW | FP32 σ; QUANT: inverse tensor scale v |
0x34, 0x38 | OLD_MAX, OLD_SUM | RW | softmax state mold, lold |
0x3C | CTRL | RW | bit 0 start; opcode [7:4] (Table 5) |
0x1002_0000. An instruction is opcode [63:56], rd [55:52], rs1 [51:48], rs2 [47:44] and a 32-bit immediate [31:0]. Register and program writes are denied while a program runs.| Offset or opcode | Name | Contents or operation |
|---|---|---|
0x00, 0x04 | ID, CAPACITY | 0x4B45_524E ("KERN"); 8,192 instructions |
0x08 | STATUS | bit 0 busy, bit 1 fault, bit 2 halted |
0x0C, 0x10, 0x14 | START, ENTRY, LENGTH | bit 0 starts the program; first instruction; program length |
0x18, 0x1C, 0x20 | CYCLES, PC, FAULT | cycles of the last run; program counter; fault code: 1 unknown opcode, 2 PC outside the program, 3 denied access, 4 WAIT error |
0x100, 0x1000 | REGS, PROGRAM | 16 integer registers; 8,192 64-bit instructions, write only |
| 0, 1, 2, 3 | HALT, MOVI, ADDI, ADD | stop; rd ← imm; rd ← rs1 + imm; rd ← rs1 + rs2 |
| 4, 5 | LOAD, STORE | rd ← word at rs1 + imm; word at rs1 + imm ← rs2 |
| 6, 7 | JMP, JNZ | pc ← imm; pc ← imm if rs1 ≠ 0 |
| 8, 9 | COPY, FILL | copy imm words from rs1 to rs2; write imm words of value rs2 from rs1. Up to 8 words per step |
| 10 | WAIT | read the word at rs1 until (word & imm[15:0]) = 0; fault if (word & imm[31:16]) ≠ 0 |
| 11, 12, 13 | SHL, SHR, AND | rd ← rs1 << imm[4:0]; rd ← rs1 >> imm[4:0]; rd ← rs1 & imm |
| 14, 15 | SHL_REG, SLTU | rd ← rs1 << rs2[4:0]; rd ← 1 if rs1 < rs2 (unsigned), else 0 |