How a CPU Works
Watch a processor add 7 and 1. Change either number and follow a single RISC-V instruction down to the transistors that help produce the answer.
Watch a keystroke
Scroll or pinch on the model to move closer.
Read the steps
- Run one instruction
Your budget needs one small addition. This is an RV32I teaching core. We follow that one instruction from the desktop into a deliberately simple 32-bit teaching processor.
- Enter the processor
The package connects the silicon die to the motherboard. We select one core, not the whole chip at once.
- Fetch four bytes
The program counter points to address 0x1000. Four bytes B3 81 20 00 arrive from the instruction memory. Little-endian means the least significant byte comes first.
- Decode the instruction
The same bits mean add x3, x1, x2. The decoder selects x1 and x2 as sources, addition as the operation, and x3 as the destination.
- Read two registers
The register file presents both 32-bit values to the arithmetic unit. A bit is a low or high voltage interpreted as 0 or 1.
- Enter the 32-bit adder
Each column adds two bits and the carry from its neighbour. The low four columns are enlarged; all 32 columns still take part.
- Start at bit 0
The least significant column runs first in this illustrative ripple-carry circuit. A carry means one unit in the next column.
- Follow the carry to bit 1
A carry can make another carry. These transitions take time in a physical circuit. Here we isolate each column so you can follow it.
- Reach bit 2
The carry now reaches the selected full-adder stage. Its propagate signal P is A XOR B. Its sum is P XOR carry-in.
- Open the carry gate
N = NAND(P, carry-in). A second NAND combines N with NAND(A,B) to form carry-out. This is an actual gate in our chosen full-adder implementation.
- Follow the output node
Two series nMOS transistors can connect node N to ground. Two parallel pMOS transistors connect it to the supply if either input is low. Voltage and conduction are shown together.
- Return to bit 3
Follow the selected gate’s outgoing carry into the next column. In the default 7 + 1 example, the carry into bit 3 makes 0111 + 0001 become 1000.
- Write back the answer
The completed 32-bit sum is written into x3. The next sequential instruction begins at 0x1004. Overflow beyond 32 bits is discarded by RV32I ADD.