Home / Learn Chip Programming / CPU Architecture: ALU, Registers, Control Unit and Buses
CPU Architecture: ALU, Registers, Control Unit and Buses
Open the CPU and see its parts. Every processor, from an 8 bit AVR to a phone chip, has the same core blocks.
Theory in plain words
What it is
The CPU (central processing unit) executes instructions. It has an ALU, registers, a program counter, an instruction register and a control unit, connected to memory by buses.
Why we use it
Understanding the blocks explains why some code is fast, why memory access is slow and what the manual means by words like "flag", "bus" or "pipeline".
How it works
The program counter holds the address of the next instruction. The control unit fetches it from memory, decodes it and tells the ALU and registers what to do. The result goes back to a register or to memory.
Where it is used
- Every microcontroller and processor
- Soft cores inside FPGAs (RISC-V, MicroBlaze)
- Performance tuning and low level debugging
The blocks
| Block | Job |
|---|---|
| ALU | arithmetic and logic operations |
| General registers | fast storage for values being used |
| PC (program counter) | address of the next instruction |
| IR (instruction register) | holds the instruction being executed |
| SP (stack pointer) | top of the stack in memory |
| Status / flags register | Zero, Carry, Negative, Overflow bits |
| Control unit | the conductor: generates all control signals |
| Address bus | carries the address the CPU wants (one direction) |
| Data bus | carries the data (two directions) |
Von Neumann vs Harvard
Bus width and address space
With n address lines the CPU can reach 2^n bytes. 16 lines reach 64 KB, 20 lines 1 MB, 32 lines 4 GB. The data bus width (8, 16, 32, 64 bits) decides how much moves at once.
An Arduino Uno (ATmega328P) has 14 bit program addresses of 16 bit words: 32 KB of Flash. A 32 bit ARM can address 4 GB.
Pipeline in one picture
A pipeline works like a car factory line. While one instruction is being executed, the next is being decoded and the one after is being fetched. A 3 stage pipeline can finish one instruction per clock even though each takes 3 clocks.
Quick quiz
1. What does the program counter hold?
PC points to the next instruction to fetch.
2. How much can 16 address lines reach?
2^16 = 65,536 bytes.
Common questions
What does the program counter hold?
The address of the next instruction. PC points to the next instruction to fetch.
How much can 16 address lines reach?
64 KB. 2^16 = 65,536 bytes.