An ALU computes several operations at once and outputs one of them. The function select bits, the ALU's part of an instruction's opcode, choose which.
They do two jobs:
- Drive the result multiplexer. The select bits go to the MUX select lines, so the chosen unit's output reaches Y.
- Configure shared hardware. Some control signals are decoded from the select bits. In the course's ALU (F1F0:
00AND,01OR,10ADD,11SUB), ADD and SUB share one adder, and SUB = tells it to subtract.
How many bits? k select bits give 2ᵏ codes. 2 operations need 1 bit, 3 to 4 need 2 bits, 5 to 8 need 3, and 9 to 16 need 4. Unused codes are usually wired to a safe output such as 0.
When you widen the code, re-derive every control signal from the new table. After adding XOR as 100 to a 3-bit code F2F1F0, SUB must be 1 only for 011, so SUB = . The old would wrongly fire for 111 too.
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |