Arithmetic Logic Unit (ALU)

The Computational Core of Computer Processors

What is an ALU?

The Arithmetic Logic Unit (ALU) is the computational core of the CPU.

It is a combinational digital circuit designed to perform arithmetic and logical operations on binary data.

ALU takes inputs (operands + control signals), processes them, and produces an output (result + status flags).

In simple words:

The ALU is the "brain inside the brain" — the part of the processor that actually does the math and logic.

ALU Conceptual Diagram

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

Context in COA

In Computer Organization and Architecture:

  • The Control Unit (CU) tells the ALU what operation to perform.
  • The Registers (like accumulator, general-purpose registers) hold the input operands.
  • The ALU computes results and may update flags in the status register (e.g., zero, carry, overflow).

So, ALU is one of the three main building blocks of a CPU:

Control Unit (CU)

Directs the operation

Registers

Store temporary data

ALU

Performs calculations and decisions

Functions of ALU

The ALU can be divided into two main categories:

1. Arithmetic Operations

Addition

Binary addition with carry handling

Example: 0101 + 0011 = 1000 (5 + 3 = 8)

Subtraction

Using 2's complement method

Example: 0101 - 0011 = 0010 (5 - 3 = 2)

Increment / Decrement

Adding or subtracting 1

Multiplication and Division

In more advanced ALUs

2. Logical Operations

AND

Bitwise AND (both bits must be 1)

Example: 0101 AND 0011 = 0001

OR

Bitwise OR (either bit is 1)

Example: 0101 OR 0011 = 0111

NOT (complement)

Bitwise inversion (flip 0 → 1, 1 → 0)

Example: NOT 0101 = 1010

XOR (Exclusive OR)

Result = 1 only if inputs differ

Example: 0101 XOR 0011 = 0110

Comparison

Equal, greater than, less than

Structure of ALU

A typical ALU has:

Inputs

  • Operand A and Operand B (from registers or memory)
  • Control signals (from CU to decide operation)

Combinational Circuit

  • Arithmetic circuit (adders, subtractors)
  • Logic circuit (AND, OR, XOR gates)

Outputs

  • Result of operation
  • Flags (status bits)

Status Flags

Zero (Z)

1 if result = 0

Carry (C)

1 if addition overflowed

Sign (S)

1 if result is negative

Overflow (V)

1 if signed overflow occurs

Example of ALU Operation

Suppose ALU has two inputs:

  • Operand A = 0101 (binary 5)
  • Operand B = 0011 (binary 3)
If control = 00 (ADD):

Result = 1000 (binary 8)

Flags → Z=0, C=0, S=0, V=0

If control = 01 (SUBTRACT):

Result = 0010 (binary 2)

Flags → Z=0, C=0, S=0, V=0

If control = 10 (AND):

Result = 0001

If control = 11 (XOR):

Result = 0110

This shows how CU changes the ALU's function dynamically.

ALU in CPU Architecture

In modern CPUs:

  • ALU is tightly integrated with registers and control unit.
  • Some CPUs have multiple ALUs to perform parallel operations (superscalar processors).

Specialized versions exist:

  • FPU (Floating Point Unit): handles real numbers
  • Vector/SIMD ALUs: handle multiple data at once (used in multimedia, AI, GPUs)

Applications of ALU in COA

Instruction Execution

Every arithmetic or logic instruction (ADD, SUB, AND, OR) is carried out by ALU

Decision Making

Comparisons (like if A > B) rely on ALU's condition checking

Address Calculation

ALU calculates effective memory addresses in load/store instructions

Program Control

Based on ALU's flags, control unit decides next instruction (e.g., branch if zero)

Detailed Information

What is ALU?

The Arithmetic Logic Unit (ALU) is the computational engine of the CPU.

It executes arithmetic operations (like add, subtract, multiply, divide) and logical operations (like AND, OR, NOT, XOR).

It is a combinational circuit, meaning it gives results immediately based on inputs (no memory of past states).

Without ALU, a CPU cannot perform even the simplest computation.

Think of ALU as the calculator inside your computer's processor.

Functions of ALU

1. Arithmetic Operations

Addition

e.g., 0101 + 0011 = 1000 (5 + 3 = 8)

Subtraction

e.g., 0101 - 0011 = 0010 (5 – 3 = 2)

Multiplication

e.g., 0011 × 0010 = 0110 (3 × 2 = 6)

Division

e.g., 0110 ÷ 0010 = 0011 (6 ÷ 2 = 3)

2. Logical Operations

AND

bitwise AND (both bits must be 1)

Example: 0101 AND 0011 = 0001

OR

bitwise OR (either bit is 1)

Example: 0101 OR 0011 = 0111

NOT

bitwise inversion (flip 0 → 1, 1 → 0)

Example: NOT 0101 = 1010

XOR (Exclusive OR)

result = 1 only if inputs differ

Example: 0101 XOR 0011 = 0110

How ALU Works in CPU

Inputs

  • Operands → from CPU registers or memory
  • Control signals → from Control Unit (CU) telling ALU what to do (e.g., ADD, SUB, AND)

Processing

ALU's internal adder, subtractor, logic gates execute the operation

Outputs

  • Result → stored back into a register/memory
  • Status Flags → stored in a special register (flags register) for decision-making

ALU Status Flags

Flags are 1-bit indicators set/reset by ALU to describe result properties:

Zero Flag (Z)

1 if result = 0

Carry Flag (C)

1 if there is a carry-out (in addition) or borrow (in subtraction)

Sign Flag (S)

1 if result is negative (MSB = 1)

Overflow Flag (V)

1 if signed overflow occurs

These help CPU branch (e.g., "if result = 0, jump to instruction X")

Importance of ALU in CPUs & Digital Systems

1. Core Processing Element

ALU = the heart of the CPU, handling all arithmetic and logical work

2. Performance & Efficiency

Faster ALU = faster CPU = faster system performance

High-performance CPUs may have multiple ALUs for parallel processing

3. Versatility

Handles basic arithmetic, comparisons, bit manipulation, address calculations, etc.

Extended to FPUs (Floating Point Units) for real numbers

Used in GPUs for graphics and parallel workloads

4. System Stability & Reliability

ALU must be accurate: even a single wrong calculation could crash a program

Errors here propagate through entire CPU

Summary

The ALU is the calculation powerhouse of the CPU.

Performs arithmetic, logic, and (sometimes) data transfer operations.

Works closely with registers and control unit.

Its speed, accuracy, and versatility directly impact CPU performance.

Extended into FPUs, GPUs, DSPs for specialized tasks.

In Conclusion

The ALU is the foundation of all computations in digital systems — everything from adding two numbers, comparing conditions, to running AI or graphics pipelines, ultimately depends on this unit.