Overview
An arithmetic logic unit (ALU) is a hardware block within a processor that performs arithmetic and logical operations. In a conventional processor pipeline, the ALU is the execute-stage functional block that combines register values, immediate data from the instruction, and numeric constants to produce a result that is then consumed by the memory and write-back stages. Specialized implementations reported in the literature include reversible ALUs for quantum arithmetic and superconductor-based ALUs. Empirical fuzzing of processor RTL has additionally shown that incorrect ALU flag-generation logic is a non-trivial source of security-relevant defects. [ALU overview]
Role in a conventional processor (Y86-64)
In the Y86-64 reference designs documented in CMU-CS-18-122, the ALU is the data-path block in the execute stage of the SEQ sequential implementation. The execute stage has inputs labeled ALU A and ALU B, an ALU fun. control input, a condition-code output (CC), and an ALU result output valE. The condition codes are also used for branch-condition evaluation in the execute stage. [ALU role in SEQ]
Inputs
The ALU operates on some combination of:
- values read from the register file,
- immediate data carried in the instruction, and
- numeric constants (for example, those used to compute the next sequential PC or a branch target). [ALU operands]
Operations
The ALU can perform either addition or the operation called for by an arithmetic or logical instruction. [ALU operations]
Place in the per-cycle flow
Within a SEQ clock cycle, the overall flow proceeds as follows: ten bytes are fetched from instruction memory (not all are used), the address of the next sequential instruction is computed by incrementing the PC, up to two values are read from the register file, the ALU is executed, a value can optionally be written to or read from data memory, some combination of the memory result and the ALU result is written back to the registers, and finally the PC is set to the address of the next instruction (the incremented old PC, a branch target, or a return address read from memory). The ALU sits between the register-read stage and memory access/write-back. [ALU position in flow]
Pipelined variant
PIPE is a five-stage pipelined implementation of the Y86-64 instruction set. Both SEQ and PIPE partition the computation into similar stages and use the same set of functional blocks, including the ALU. PIPE adds pipeline registers so that up to five instructions can be in the pipeline simultaneously, each in a different stage, and adds data connections and control logic to resolve data- and control-hazards. [PIPE / Y86-64 implementation context]
ALU flag-generation logic and correctness
In addition to producing the arithmetic/logical result, ALUs compute condition flags such as the carry and overflow flags. Empirical fuzzing of processor RTL against a golden reference model, as reported in TheHuzz (USENIX Security '22), found several flag-generation defects in OpenRISC ALUs:
- Bug B5 (mor1kx): incorrect implementation of the carry-flag logic for subtract operations. Mutating subtract-instruction data bits triggered a mismatch between the RTL and the golden reference model, which can cause incorrect computations including those used in cryptographic functions. Detected with 20 inputs; classified as a core-and-compute issue (CWE-1201). [Bug B5 carry flag]
- Bug B9 (mor1kx): incomplete update logic for the overflow bit on multiply-and-subtract (MSB) and multiply-and-accumulate (MAC) instructions, so software relying on overflow detection fails to detect overflow events. Detected with 3.35 × 10³ inputs (CWE-1201). [Bug B9 overflow MSB/MAC]
- Bug B10 (mor1kx): incorrect implementation of the overflow-flag logic for subtract instructions, which can compromise security mechanisms that rely on the overflow flag. Detected with 2.21 × 10⁴ inputs (CWE-1201). [Bug B10 overflow subtract]
These results indicate that ALU flag logic is a non-trivial source of defects with security-relevant consequences.
Specialized ALU implementations
Reversible ALU for quantum arithmetic
Reversible logic has been used to construct a reversible arithmetic logic unit for quantum arithmetic (arXiv:1107.3924). The proposed reversible ALU provides explicit constructions that effect basic arithmetic operations. With the corresponding control unit, the reversible ALU can combine classical arithmetic and logic operations in a reversible integrated system. The work is cited as actual evidence of the realizability of a reversible programmable logic device (RPLD). [Reversible ALU for quantum arithmetic]
Superconductor ALU
A 4-bit ALU has been implemented in superconductor technology using a bit-parallel architecture designed for minimal fan-in/fan-out and optimal latency (arXiv:2312.09386). Reported characteristics include:
- a clock frequency exceeding 30 GHz;
- power consumption of 4.75 mW, including applied reverse current and encompassing static and dynamic components;
- more than 9000 Josephson junctions, of which approximately 7000 are used for wiring, delay lines, and path balancing;
- a bias margin above 18%;
- operation inside a 4 K pulse-tube cryocooler;
- a co-processor design that interfaces with external CMOS memory and processors via interface circuits.
The ALU was fabricated using a standard commercial process. Digital and analog simulations were used to validate the design, and experimental verification confirmed successful operation of both the arithmetic and logic units. [Superconductor ALU]