Learn
3.1.2 | COMPONENTS OF THE CPU
01 | A STORED-PROGRAM COMPUTER
In Von Neumann architecture, program instructions and data are stored in the same main memory. The CPU obtains instructions from memory and carries them out.
Think of memory as numbered locations. An address identifies a location; its contents are the value held there. Address 20 and the value 42 stored at address 20 are different things.
The readable instructions in this diagram are teaching labels. Real instructions are stored as binary machine code. The CPU interprets a value according to how the program uses it.
02 | THE CONTROL UNIT AND ALU
| Unit | Job | Example |
|---|---|---|
| Control unit (CU) | Decodes instructions and coordinates their execution; sends control signals | Requests a memory read and directs the required transfers |
| Arithmetic logic unit (ALU) | Carries out arithmetic and logical operations | Adds two values or performs a comparison |
The control unit is not where all program data is stored. The ALU is not a permanent file store. Separate doing a job from holding a value.
03 | FIVE REGISTERS, FIVE DISTINCT JOBS
| Register | Full name | What it holds | Memory aid |
|---|---|---|---|
| PC | Program counter | Address of the next instruction to fetch | NEXT instruction |
| MAR | Memory address register | Address of the location being accessed | WHERE in memory |
| MDR | Memory data register | Instruction or data being transferred to/from memory | WHAT is moving |
| CIR | Current instruction register | Instruction currently being decoded/executed | CURRENT instruction |
| ACC | Accumulator | Working values and results in this simplified CPU | WORKING result |
The PC is an address, not the instruction itself. The MAR is also an address, but it can select an instruction or a data location. The MDR can contain either an instruction or operand data.
Copying a value does not automatically erase the source register. If PC 100 is copied into MAR, the MAR now contains 100 and the PC still contains 100 until another step updates it.
04 | THE THREE BUSES
| Bus | What travels | Direction in this model |
|---|---|---|
| Address bus | Address selecting a memory or input/output location | From CPU towards the addressed component |
| Data bus | Instructions and data values | Both ways between CPU and memory / input-output |
| Control bus | Signals such as read, write and status | Signals can travel in different directions |
For a read, the CPU places the MAR address on the address bus and sends a read signal. Memory returns the selected contents on the data bus into MDR.
For a write, the address still selects the location, but the value travels from the CPU towards memory. Control signals tell the components which operation to perform.
05 | SEE THE COMPLETE CYCLE
Fetch: obtain an instruction. Decode: the CU determines the operation and any operand information. Execute: carry out that operation, which may require another memory access.
The PC advances for the next instruction during this teaching fetch sequence. A jump or branch can later replace it with a different address. Here we use one memory location per instruction, so advancing means adding 1.
06 | WALK THROUGH LOAD 20
Start with PC = 100. At memory address 100 is the instruction LOAD 20, meaning “copy the value at address 20 into ACC”. At address 20 the value is 42.
Prediction: the final accumulator should hold 42, not 20 and not 100. Use Next step to watch which register changes.
START | BEFORE FETCH
PC identifies the next instruction at address 100. Press Next step.
No transfer yet.
Step 0 of 9
This model uses symbolic instructions and an illustrative sequential order, not clock-accurate hardware. Registers marked “Not set” have no relevant value supplied for this example. Previous step replays the model, rather than reversing a real CPU.
07 | TRACE THE REGISTER CHANGES
| Stage | Transfer / operation | Why it happens |
|---|---|---|
| Fetch | MAR ← PC (100) | Select the next instruction location |
| Fetch | MDR ← memory[100] (LOAD 20) | Read the instruction into CPU |
| Fetch | CIR ← MDR (LOAD 20) | Keep the current instruction |
| Fetch | PC ← PC + 1 (101) | Prepare the sequential next instruction address |
| Decode | CU interprets LOAD 20 in CIR | Determine operation and operand address |
| Execute | MAR ← 20 | Select the data location named by the instruction |
| Execute | MDR ← memory[20] (42) | Read the operand value |
| Execute | ACC ← MDR (42) | Carry out the LOAD operation |
| End | Next cycle starts from PC 101 | Fetch the following instruction |
At the end, CIR still holds LOAD 20 while MDR holds 42. That is why the instruction needs its own register: the MDR can be reused for operand transfers.
08 | WHAT WOULD ADD 21 DO NEXT?
At address 101 is ADD 21. A new fetch puts 101 into MAR, reads ADD 21 into MDR and then CIR, and advances PC to 102.
During execution, the CPU reads address 21, whose contents are 8. The ALU adds that operand to the accumulator: 42 + 8 = 50. ACC holds the result.
LOAD copies a value; ADD performs arithmetic. Not every execute stage is an addition, and not every instruction needs to read a separate operand from memory.
09 | UNSTICK THE CONFUSING PARTS
- Address versus contents: MAR = 20 selects a location; MDR = 42 holds its returned contents.
- PC versus CIR: PC points to the next instruction; CIR holds the current one.
- MAR versus MDR: address selects; data moves.
- Fetch versus execute: first fetch the instruction, then perform its operation, possibly reading operand data.
- CU versus ALU: CU directs and decodes; ALU performs arithmetic and logic.
- Data bus: it carries instruction values too, despite its name.