The Processor: Datapath & Control

the ALU control

/ ALU = AY-el-yoo /

The main control unit decides the broad strokes — is this a load, a store, an arithmetic op? — but it deliberately does not figure out the exact ALU operation for every arithmetic instruction. That last, fine-grained decision is handed to a tiny helper called the ALU control: a small block of logic whose only job is to tell the ALU precisely which function to perform (add, subtract, AND, OR, set-on-less-than, and so on).

It works in two layers, which keeps the main control simple. The main control emits a short, coarse hint (often called ALUOp) that just classifies the instruction: '00' might mean 'this is a load or store, so just add for the address', '01' might mean 'this is a branch, so subtract to compare', and '10' might mean 'this is an R-type, look deeper'. When the hint is '10', the ALU control reads extra opcode bits (in MIPS the function field, in RISC-V the funct fields) to choose the exact operation. The output is the few-bit ALU-operation code that selects the ALU's function for this cycle.

Why split it out at all? Because the same ALU is reused for many purposes — adding for a load address, subtracting for a branch comparison, doing real arithmetic for an R-type — and the choice depends on different bits for different instruction classes. The two-level scheme (coarse ALUOp from main control, fine decode in the ALU control) is a clean way to map a big set of arithmetic instructions onto one shared ALU without bloating the main control table. It is a small but classic example of factoring a decision into a quick guess plus a detail lookup.

For a load, ALUOp = '00' tells the ALU control 'just add' (to form base + offset). For an R-type, ALUOp = '10' tells it to look at the function bits: if they encode subtraction, the ALU control outputs the subtract code; if they encode AND, it outputs the AND code.

A small two-level decoder: coarse ALUOp from main control plus opcode bits selects the exact ALU function.

The ALU control selects WHICH operation; it does not perform the arithmetic — that is the ALU's job, covered in the arithmetic field. Keeping these separate is exactly the point of the two-level scheme.

Also called
ALU control unitALU 控制單元