Skip to content
BetterDL

Function select

Also called: ALU function code, ALU select lines, ALU control lines

The control bits that tell an ALU which operation to perform. With k select bits an ALU can choose among up to 2ᵏ operations.

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:

  1. Drive the result multiplexer. The select bits go to the MUX select lines, so the chosen unit's output reaches Y.
  2. Configure shared hardware. Some control signals are decoded from the select bits. In the course's ALU (F1F0: 00 AND, 01 OR, 10 ADD, 11 SUB), 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.

000
010
100
111

Worked example

Example

Sizing the select code for 6 operations

Find the smallest k with 2ᵏ ≥ 6.

  1. 1.

    k = 2 gives 4 codes. Too few.

  2. 2.

    k = 3 gives 8 codes. Enough, with 2 spare.

  3. 3.

    Each slice now needs an 8-input MUX, with the 2 unused inputs tied to 0.

Common mistakes

  • Thinking k select bits choose among k operations. They choose among up to 2ᵏ.

  • Copying an old control equation after the opcode table changes.

  • Forgetting that unused codes still produce some output, so they should be tied to something safe.

Practice Function select

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Function select is taught in Adders and ALUs.