ALU Design - Components and Architecture

Building the Computational Heart of the CPU

ALU Design – Components of an ALU

The Arithmetic Logic Unit (ALU) is the computational heart of the CPU. It performs both arithmetic operations (like addition, subtraction) and logic operations (like AND, OR, NOT, XOR).

Designing an ALU means combining registers, adders, logic gates, multiplexers, and control logic into one functional unit.

ALU Conceptual Overview

Operand A
ALU
Arithmetic Logic Unit
Result
Operand B
Control Signals
Status Flags

ALU Components

1. Registers

Operand Registers (A and B)

Store the input data values on which operations are to be performed.

Example: To compute 5 + 3, A = 0101 and B = 0011.

Result Register (R)

Holds the output after the operation is completed.

Example: If 5 + 3 = 8, then R = 1000.

Without registers, the ALU cannot fetch and store intermediate values.

2. Arithmetic Unit

Adder

Performs binary addition.

Can be a half adder, full adder, or ripple carry adder for multi-bit addition.

Example: 0101 + 0011 = 1000.

Subtractor

Often implemented using an adder by taking the 2's complement of the second operand.

Example: 5 – 3 = 0101 + (1101) = 1000 (2).

In most ALUs, subtraction is not a separate circuit but derived from the adder.

3. Logic Unit

AND Gate

Output = 1 if both inputs = 1.

Example: 0101 AND 0011 = 0001.

OR Gate

Output = 1 if at least one input = 1.

Example: 0101 OR 0011 = 0111.

XOR Gate

Output = 1 if inputs are different.

Example: 0101 XOR 0011 = 0110.

NOT Gate

Inverts bits.

Example: NOT 0101 = 1010.

These operations are essential for comparisons, masking, and decision-making.

4. Multiplexers (MUX)

Selector Function

The ALU contains multiplexers to choose which output (from arithmetic unit or logic unit) should be passed to the result register (R).

Example:

  • If control signal = 00, choose adder result
  • If control signal = 01, choose subtractor result
  • If control signal = 10, choose AND gate result
  • If control signal = 11, choose OR gate result

MUX is like a "traffic controller" inside the ALU.

5. Control Unit

Control Lines

Encoded signals (operation codes / opcodes) that specify the operation.

Example:

  • 00 → Addition
  • 01 → Subtraction
  • 10 → AND
  • 11 → OR

Status Flags

The ALU sets flags after operations:

  • Zero Flag (Z): 1 if result = 0
  • Carry Flag (C): 1 if carry/borrow occurs
  • Overflow Flag (V): 1 if signed overflow occurs
  • Sign Flag (S): 1 if result is negative

These flags help the CPU make decisions (e.g., in branching instructions).

6. Timing and Control Circuits

Clock Signals

Synchronize ALU operations with CPU cycles.

Control Logic

Decodes instructions and generates signals for adders, gates, or shifters.

Ensures operations happen in the right order and timing.

7. Data Paths

Internal Data Paths

Allow binary data to flow between registers, arithmetic unit, logic unit, and MUX.

Think of data paths as "roads" inside the ALU connecting its parts.

Block Diagram of ALU

Conceptual ALU Architecture

Operand A
Operand Regs
Arithmetic Unit
MUX
Result Register
Operand B
Logic Unit
MUX
Status Flags
Control Signals
Control Unit

Summary

ALU = Registers + Arithmetic Unit + Logic Unit + MUX + Control + Flags + Data Paths

Operands come from registers, processed by adder/logic unit, selected by MUX, stored in result register

Flags are set for CPU decision-making

Control signals from CPU determine which operation is performed

In short:

The ALU is the "calculator + decision-maker" inside the CPU, designed from a combination of adders, logic gates, multiplexers, and control circuits

ALU Design Example

What is ALU Design?

Designing an Arithmetic Logic Unit (ALU) means creating the circuit architecture that can perform multiple arithmetic and logic operations, controlled by operation select signals.

Think of it as designing a Swiss army knife of digital circuits — one block that can do addition, subtraction, AND, OR, XOR, etc., depending on what the CPU asks.

Basic Components of ALU Design

Inputs

  • Operands (A & B): Binary inputs (from registers or memory)
  • Control/Opcode signals: From the Control Unit, tell ALU which operation to perform

Functional Units Inside ALU

  • Arithmetic Unit: Handles addition, subtraction, multiplication, division
  • Logic Unit: Handles AND, OR, NOT, XOR, etc.
  • Shifter: Handles left/right shifts or rotates

Multiplexer (MUX)

Used to select one output from many functional units based on control signals

Outputs

  • Result: The final computed value
  • Flags: Status signals (Zero, Carry, Sign, Overflow)

ALU Design Block Diagram

Operand A
Arithmetic Unit
MUX
Result
Operand B
Logic Unit
MUX
Flags
Control Signals
Control Unit

ALU Operations in Design

1. Arithmetic Unit

Built mainly using binary adders (full adders)

Subtraction → done by 2's complement addition

Multiplication/Division → usually handled by separate circuits or microprogrammed logic

2. Logic Unit

Built from logic gates (AND, OR, NOT, XOR)

Works bit-by-bit across input operands

3. Shifter Unit

Performs shift left, shift right, rotate left, rotate right

Useful in multiplication/division by 2 and bit manipulation

4. Control Logic

A decoder interprets the opcode (operation code) and sends signals to enable the right unit

Example:

  • Opcode 00 → Perform Addition
  • Opcode 01 → Perform Subtraction
  • Opcode 10 → Perform AND
  • Opcode 11 → Perform OR

Status Flags in ALU Design

Flags Generated by ALU

  • Zero Flag (Z): 1 if result = 0
  • Carry Flag (C): 1 if carry generated in addition
  • Sign Flag (S): 1 if result is negative (MSB = 1)
  • Overflow Flag (V): 1 if signed overflow occurs

These flags are stored in the Program Status Word (PSW) or Flags Register

Example: Simple 4-Bit ALU Design

Suppose we want an ALU that can do:

  • Addition, Subtraction, AND, OR

Steps:

  • Arithmetic Circuit → 4-bit Adder/Subtractor
  • Subtraction handled by feeding 2's complement of B into adder
  • Logic Circuit → 4-bit AND & OR gates
  • MUX → Selects output (Adder/Subtractor OR Logic unit)

Control Signals

  • 00 → Addition
  • 01 → Subtraction
  • 10 → AND
  • 11 → OR
Control (Opcode) Operation Result Flags Example
00 Addition 1101 (13) C=0, Z=0, S=0, V=0
01 Subtraction 0111 (7) C=1, Z=0, S=0, V=0
10 AND 0010 (2) Z=0
11 OR 1011 (11) Z=0

Advanced ALU Design

Modern CPU ALU Features

Pipelined ALUs

Allow multiple operations at once by breaking them into stages

Improves throughput and performance

Multiple ALUs per Core

Superscalar processors (e.g., Intel, AMD) have several ALUs working in parallel

Enables instruction-level parallelism

Integrated Floating-Point Unit (FPU)

Handles real-number math with high precision

Essential for scientific computing and graphics

SIMD ALUs

Single Instruction, Multiple Data

Process vectors/matrices (used in GPUs and AI)

Optimization Techniques in ALU Design

Carry-Lookahead Adders

Reduces carry propagation delay in multi-bit addition

Commonly used in high-performance ALUs

Wallace Tree Multipliers

Parallel multiplication circuits for faster computation

Used in advanced ALUs and FPUs

Barrel Shifters

Fast multi-bit shift operations using multiplexers

Essential for efficient bit manipulation

Summary of Modern ALU Design

  • ALU design = combining arithmetic, logic, and shifting circuits under control logic
  • Uses multiplexers to choose the correct result
  • Generates flags to support decision making in CPU
  • Modern ALUs are highly parallel, pipelined, and specialized for speed

In Simple Words:

An ALU is like a multi-tool, and ALU design is about wiring together adders, subtractors, logic gates, and shifters, controlled by opcodes, to perform all CPU operations