Arithmetic Logic Unit (ALU): Architecture and Working Explained

Share:
Digital Electronics
Arithmetic Logic Unit (ALU): Architecture and Working Explained

Every instruction a processor executes eventually lands on the same small block of combinational logic.

Understanding how that block adds, compares, and branches is the fastest way to understand how a CPU actually thinks.

Interactive ALU Simulator Gate-Level Breakdown Real CPU Examples

An Arithmetic Logic Unit (ALU) is the combinational digital circuit inside a processor that performs arithmetic operations like addition and subtraction, and logical operations like AND, OR, and XOR, selecting the correct result through a control signal and reporting status flags such as carry, zero, and overflow.

Every calculation a computer performs, whether it's adding two numbers in a spreadsheet or comparing two values in an if-statement, eventually passes through an ALU.

Arithmetic Logic Unit

It's easy to think of the CPU as one intelligent black box, but the actual "thinking" happens in a tiny, fixed piece of hardware that has no memory of its own and no concept of a program. It receives two binary inputs and a control code, and within a fraction of a nanosecond, it produces an output and a set of flags.

That simplicity is deliberate. An ALU built from a handful of logic gates can run at gigahertz speeds precisely because it does one narrow job extremely well, rather than trying to be clever.

Modern high-performance cores don't rely on a single ALU either. A processor like the ARM Cortex-X4 packs multiple integer execution units so several instructions can be evaluated in the same clock cycle, which is one of the main levers behind modern single-core performance gains.

This guide breaks down what's actually inside an ALU, how it decides which operation to run, how it reports its status through flags, and where this decades-old design shows up in the processors running today.

What an ALU Actually Does

Signal Flow Through the ALU
Input A
n-bit operand
ALU Core
Adder + Logic Unit
Output
n-bit result
Input B
n-bit operand
Select Code
chooses operation
Flags
Carry, Zero, Sign, Overflow

At its simplest, an ALU is a black box with two n-bit data inputs, a control input that selects the operation, and two outputs: the result and a set of status flags describing that result.

Internally it's built entirely from combinational logic, meaning it has no clock and no memory of previous operations. Feed it the same three inputs twice and it produces the exact same output both times, with no dependency on history.

This is what separates the ALU from the rest of the CPU. The control unit, registers, and program counter all involve sequential logic and state. The ALU is pure computation, wired once in silicon and reused for every arithmetic or logical instruction the processor ever executes.

Advertisement
Advertisement

Inside the ALU: The Two Functional Halves

Every general-purpose ALU is really two separate circuits sharing the same inputs, with a multiplexer picking which one's output actually reaches the pins.

Arithmetic unit: adders, subtractors, and increment/decrement logic built from full adders
Logic unit: bitwise AND, OR, XOR, NOT gates operating independently on each bit pair
Multiplexer: the select lines route only one unit's result to the final output bus

Both the arithmetic and logic paths compute their results in parallel on every cycle, whether or not their output gets used. The multiplexer doesn't save power by skipping work; it just decides which of the two already-computed answers gets passed downstream.

Why ALU design favors speed over energy efficiency at this stage

How the Adder Actually Adds

The arithmetic path is built from a chain of full adders, and this is where most of an ALU's internal complexity lives.

1
0
1
1
+
0
1
1
0
=
1
0
0
0
1

A single full adder takes two bits plus a carry-in and produces a sum bit and a carry-out. Chain four of these together and each carry-out feeds the next stage's carry-in, which is enough to add two 4-bit numbers.

The problem is that this "ripple carry" design is slow at wide bit widths, because the final bit can't settle until the carry has rippled through every stage before it. A 64-bit ripple carry adder would be far too slow for a modern clock speed.

Real processors instead use a carry-lookahead adder, which calculates all the carry bits in parallel using extra logic upfront, trading additional gates for a dramatic reduction in propagation delay. Subtraction reuses the same adder hardware by inverting the second operand and injecting a carry-in of 1, which is two's complement subtraction happening in real time.

Try It: ALU Operation Simulator

The calculator below mirrors what the ALU's select lines and multiplexer do internally. Pick two operands and an operation to see the binary result and which status flags it sets.

8-Bit ALU Operation Simulator
Select an operation to see the result and status flags
Result = A OP B Flags
A, B = 8-bit operands (0-255) OP = selected function Flags = C, Z, S, V
-
Advertisement
Advertisement

The Core Operations an ALU Supports

Instruction sets vary, but almost every ALU exposes some version of the same core operation set, selected by a binary opcode on its control lines.

+ADD
SUB
&AND
|OR
^XOR
¬NOT
SHL
SHR

Arithmetic operations (ADD, SUB, and often increment or decrement) run through the adder chain. Logic operations (AND, OR, XOR, NOT) run through a bank of parallel gates, one per bit. Shift operations reposition bits within the register, which is functionally equivalent to fast multiplication or division by powers of two.

The select code, usually 3 to 6 bits wide depending on how many operations the ALU supports, feeds a decoder that activates the correct multiplexer path, exactly as demonstrated in the simulator above.

Status Flags: The ALU's Report Card

An ALU doesn't just hand back a number. It also reports metadata about that result through a small set of flag bits, and those flags are what let a CPU make decisions.

Carry (C)

Set when an addition produces a carry-out of the most significant bit, or a subtraction requires a borrow.

Zero (Z)

Set when the result equals zero, the flag nearly every conditional branch instruction checks first.

Sign (S)

Mirrors the most significant bit of the result, indicating a negative value in two's complement form.

Overflow (V)

Set when a signed operation produces a result too large or too small to fit in the available bits.

These flags are usually stored in a dedicated status register, and the control unit reads them immediately after every arithmetic or logic instruction. A "jump if zero" instruction, for example, is really just a check on the Z flag left behind by whatever operation ran before it.

Where ALUs Actually Live in Modern CPUs

Textbook diagrams show one ALU per processor, but that stopped matching reality decades ago.

Processor GenerationInteger Execution UnitsDesign Implication
Classic single-issue CPUs1 ALUOne integer operation completes per cycle at most
Early superscalar cores2 to 3 ALUsMultiple simple instructions can issue in parallel
ARM Cortex-X4 (2023)Widened integer execution resourcesOne of the widest out-of-order ARM cores to date, per WikiChip's architecture analysis
High-end desktop and server cores4+ ALUs per coreMultiple independent integer pipelines feed from a shared instruction window

Having multiple ALUs per core is what allows a superscalar processor to execute several independent integer instructions in the same clock cycle, provided the instruction scheduler can find operations without data dependencies to run together. The ALU itself hasn't gotten conceptually more complex. There are simply more of them, wired to a smarter dispatcher.

A Short History: From the 74181 to the Modern Core

1970

Texas Instruments releases the 74181, the first complete ALU on a single TTL chip, supporting 32 arithmetic and logic functions on 4-bit operands.

1970s-1980s

Minicomputers and early microprocessors chain multiple 74181 chips together to build wider word sizes, a design documented extensively by hardware historians reverse-engineering the original die.

1990s-2000s

The ALU moves fully on-die as part of the integer execution unit, with carry-lookahead and carry-select adders replacing simple ripple carry for speed.

Today

Modern cores run several ALUs per core in parallel, feeding out-of-order execution engines that keep each unit busy across overlapping instructions.

The 74181 is strange by modern standards, its logic doesn't map cleanly onto simple Boolean identities, and reverse-engineering its die surprised even experienced hardware historians. But its basic contract, two operands and a select code in, a result and flags out, is identical to what runs inside a processor today.

Why the 74181 remains a foundational teaching reference

Where ALU Design Choices Matter Most

✓ Do

  • Use carry-lookahead or carry-select adders for wide bit widths where ripple carry delay becomes a bottleneck
  • Keep the logic unit's gates fully parallel so bitwise operations complete in a single gate delay
  • Route status flags to a dedicated register the control unit can read immediately after execution
  • Add multiple ALUs per core when the instruction scheduler can reliably find independent operations to pair

✗ Don't

  • Assume a ripple carry adder scales acceptably past small bit widths
  • Confuse the overflow flag with the carry flag, they track signed and unsigned edge cases differently
  • Treat the ALU as sequential logic, it has no internal state or memory of prior operations
  • Add extra ALUs without a scheduler capable of actually keeping them fed with independent work
Advertisement
Advertisement

Reference Materials on ALU Design

DOC
Inside the Vintage 74181 ALU Chip: How It Works and Why It's So Strange
Ken Shirriff: die-level reverse engineering of the first single-chip ALU
DOC
Lookahead Carry Unit
How carry-lookahead adders eliminate ripple-carry propagation delay

FAQs on Arithmetic Logic Unit (ALU)

What is the main function of an ALU?
It performs arithmetic operations like addition and subtraction and logical operations like AND, OR, XOR, and NOT on binary data, selected by a control code.
What is the difference between the arithmetic unit and the logic unit inside an ALU?
The arithmetic unit handles addition, subtraction, and related operations through adder circuits, while the logic unit performs bitwise Boolean operations through parallel gates. A multiplexer selects which one's output is used.
Why does subtraction use the same hardware as addition?
Subtraction is implemented by inverting the second operand and adding 1, which is two's complement math, so the same adder chain handles both operations without separate subtractor circuitry.
What do the Carry, Zero, Sign, and Overflow flags mean?
Carry indicates a carry-out or borrow occurred, Zero indicates the result is zero, Sign reflects the most significant bit, and Overflow indicates a signed result exceeded the representable range.
Why do modern CPUs have more than one ALU per core?
Superscalar processors execute multiple independent instructions per clock cycle, and each parallel integer operation needs its own ALU to avoid becoming a bottleneck.
What was the first ALU built as a single chip?
Texas Instruments' 74181, released in 1970, was the first complete 4-bit ALU on a single TTL integrated circuit and became a foundational building block for early computers.

External References

What we learn today

  • An ALU is a purely combinational circuit with no internal memory, producing a result and status flags from two operands and a control code.
  • Internally it splits into an arithmetic path built from adders and a logic path built from parallel Boolean gates, with a multiplexer selecting the active output.
  • Wide adders use carry-lookahead logic instead of ripple carry to avoid unacceptable propagation delay at gigahertz clock speeds.
  • The Carry, Zero, Sign, and Overflow flags are what let a CPU's control unit make branching decisions after every arithmetic or logic instruction.
  • Modern superscalar cores run multiple ALUs per core in parallel, tracing back to Texas Instruments' 74181, the first single-chip ALU from 1970.
"I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!"

Leave a Reply

Your email address will not be published. Required fields are marked *