Mini ALU
What an ALU is, how a small opcode selects between arithmetic and logic results, and why an ALU is really a MUX of operations.
Updated 2026-07-08
An ALU — arithmetic logic unit — is a single block that can perform several different operations. Instead of building one circuit per operation, you build one block that does all of them and pick the one you want at run time with a small control signal called the opcode.
A tiny ALU might support three operations: add, bitwise AND, and bitwise OR. Two opcode bits are enough to name up to four operations, so you assign a code to each — for example 00 for add, 01 for AND, 10 for OR — and reserve the fourth code for later. A case statement on the opcode is the natural way to describe this.
The key idea is that an ALU is a MUX of operations. Every operation is computed on the inputs, and the opcode acts as the select line that decides which result actually reaches the output. The unselected results are still computed by the hardware; they simply do not drive the output. Keep the default-at-top habit here too, so the reserved opcode never leaves the output unassigned.