How a CPU Works

The Central Processing Unit (CPU) is often called the brain of the computer. But unlike a biological brain, it doesn't "think" in vague terms. It executes precise, simple instructions one after another at blinding speeds.

In this article, we'll break down the fetch-decode-execute cycle that powers everything from your phone to supercomputers.

NAND Gate Simulation

Step 0 / 2

We start with a single NAND Gate.

The CPU acts as the central command center for all computer operations.

D Flip FLop

Computes need to compute, and therefore they need to store numbers. How can we store numbers? With a flip flop!

D Flip-Flop (Latch)

Step 0 / 2

We start with 5 NAND Gates arranged for a D-Latch.

A D Flip Flop is a simple flip flop that stores a single bit.

Register

8-bit Register

View: 8 D-FlipFlops

To store a Byte (8 bits), we need 8 D-FlipFlops working in parallel. Wiring inputs, outputs, enable, and power to 8 independent circuits acts as a "Parallel Interface".

A Register is a collection of flip flops that store a byte.

ALU (Arithmetic Logic Unit)

The ALU is the mathematical heart of the CPU. By combining many logic gates, it can perform addition, subtraction, and logical operations.

ALU (Arithmetic Logic Unit)

The ALU is the calculator of the CPU. It takes two numbers (A and B), performs a math operation, and outputs the result. Click the numbers to change them, and toggle the SUB switch to change from ADD to SUB.

The ALU takes two inputs and a selector to perform computation.