📘 CodingMarble Learn

Computer Architecture

Computer architecture is the design of how a computer's parts work together. Most computers follow the von Neumann model: a CPU and one main memory that stores both the program and its data, joined by the address, data and control buses. The CPU repeats the fetch-decode-execute cycle using special registers (PC, MAR, MDR, CIR, ACC), a control unit and an ALU. Speed depends on clock speed, number of cores and cache size. Instructions are machine code (binary); assembly gives them short names. Designs vary: Harvard (separate memories), RISC vs CISC, and small embedded systems.

🎬 Step-by-step story

  1. This is a von Neumann machine: a CPU on the left and one memory on the right. The memory holds the program AND the data. Buses (groups of wires) join them.
  2. Fetch: the Program Counter (PC) says 0. That address goes to MAR and travels on the address bus. The instruction in cell 0 comes back on the data bus into MDR. PC goes up to 1.
  3. Decode: the Control Unit reads "LOAD 5" and works out what to do: bring the value in cell 5 into the accumulator (ACC).
  4. Execute: 12 travels from cell 5 into ACC. The next cycle runs ADD 6, and the ALU adds 12 + 30 = 42.
  5. Speed: a clock ticks billions of times a second. More GHz, more cores (copies of the processor) and a cache next to the CPU make a computer faster.
  6. Your turn: press "Next cycle" again and again. Watch LOAD, ADD, STORE, HALT. Change cell 5 or 6 and see the answer land in cell 7.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why keep the program in the same memory as the data?

Then a new program can be loaded just by writing new numbers into memory: no rewiring. That is what made computers general purpose.

Why does the CPU need MAR and MDR? Why not read memory directly?

Memory is outside the CPU. MAR holds the address on the address bus and MDR holds the value on the data bus while the slow transfer happens, as the moving dot shows.

How does the CPU know what "LOAD 5" means?

The CU splits it into an opcode (LOAD) and an operand (5) and switches on the right paths. Each CPU has a fixed instruction set.

Where does the answer of a sum go?

The ALU puts it in the accumulator (ACC). A STORE instruction later copies it to memory.

Is 4 GHz always faster than 3 GHz?

Not always. Cores, cache size and how much work is done per cycle also matter. Move the clock and cores sliders and compare.

How does the program end?

A HALT instruction stops the cycle. Press Next cycle until the label says Stopped.

What is computer architecture?

Computer architecture is the plan of a computer: which parts it has and how they talk to each other. We can split (decompose) a computer into layers:

Each layer hides the details of the layer below it. This is called abstraction. In this lesson we look inside the hardware layer.

The von Neumann model

In 1945 John von Neumann described a design that almost every computer still uses. Its big idea is the stored program: the program's instructions and the data are both kept as binary numbers in the same main memory.

Main parts

Buses

Because instructions and data share one bus, the CPU can fetch only one at a time. This slowdown is called the von Neumann bottleneck.

Inside the CPU: CU, ALU and registers

RegisterJob
PC (Program Counter)address of the next instruction
MAR (Memory Address Register)address about to be used in memory
MDR (Memory Data Register)data or instruction just read from, or about to be written to, memory
CIR (Current Instruction Register)the instruction being decoded
ACC (Accumulator)result of the ALU's latest calculation

The fetch-decode-execute cycle

  1. Fetch: copy PC into MAR. Send the address on the address bus with a "read" signal. The instruction comes back on the data bus into MDR, then is copied to CIR. Add 1 to PC.
  2. Decode: the CU splits the instruction into an opcode (what to do, e.g. ADD) and an operand (what to use, e.g. address 6).
  3. Execute: do it. Load a value, let the ALU calculate, store a result, or jump to a new address by changing PC.

Then the cycle starts again, until a HALT instruction.

Worked trace

Memory: 0: LOAD 5, 1: ADD 6, 2: STORE 7, 3: HALT, 5: 12, 6: 30. After cycle 1, ACC = 12. After cycle 2, ACC = 42. After cycle 3, cell 7 = 42. Cycle 4 stops the program.

What makes a CPU faster?

Machine language and different designs

Machine code and assembly

The CPU only understands machine code: binary instructions such as 0001 0101 (opcode 0001 = LOAD, operand 0101 = 5). Assembly language writes the same instruction as LOAD 5, and an assembler turns it into binary. Each CPU family has its own instruction set.

Variation in architecture

Embedded systems

An embedded system is a small computer built into a larger device to do one job: a washing machine, microwave, car brakes, a fitness band. They are cheap, small, use little power and are hard to reprogram.

Try it

Play "human CPU" with a friend. Write 8 numbered cards: 0: LOAD 5, 1: ADD 6, 2: STORE 7, 3: HALT, 5: 7, 6: 9, 7: empty. One person is the PC and points to a card; the other fetches it, reads it out (decode) and does it with a calculator (execute). What ends up on card 7? Then check in the 3D by setting cell 5 = 7 and cell 6 = 9.

Key formulas and definitions

Worked examples

1. Trace the program 0: LOAD 5, 1: ADD 6, 2: STORE 7, 3: HALT with cell 5 = 12 and cell 6 = 30. Give PC and ACC after each cycle.

Cycle 1: PC = 1, ACC = 12. Cycle 2: PC = 2, ACC = 42. Cycle 3: PC = 3, ACC = 42 and cell 7 = 42. Cycle 4: PC = 4, HALT, the program stops.

2. A CPU runs at 2.5 GHz. How many clock cycles does it make in one second?

2.5 × 10⁹ = 2,500,000,000 cycles per second.

3. A 4 GHz CPU needs 2 cycles per instruction on average. Roughly how many instructions per second can one core run?

4 × 10⁹ ÷ 2 = 2 × 10⁹ instructions per second.

4. Why might a quad-core 2 GHz CPU not be twice as fast as a dual-core 2 GHz CPU for a game?

The extra cores only help if the game's work can be split into parallel tasks. If most of the work must happen one step after another, two cores sit idle.

5. An instruction is 8 bits: the first 4 bits are the opcode, the last 4 the operand. How many different opcodes and how many addresses are possible?

4 bits give 2⁴ = 16 opcodes and 2⁴ = 16 addresses (0 to 15).

6. Explain why a cache speeds up a loop that runs 1,000 times.

After the first pass, the loop's instructions and data are kept in the cache. The next 999 passes read them from the fast cache instead of slow RAM, so each fetch takes far less time.

Common mistakes

Practice quiz

1. In the von Neumann model, the program and data are stored:
2. Which register holds the address of the next instruction?
3. Which part of the CPU does calculations and comparisons?
4. Which bus carries the address from the CPU to memory?
5. Which is NOT a factor in CPU performance?

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is von Neumann architecture in simple words?

A computer design where one memory stores both the program and the data, and the CPU fetches and runs instructions one by one over shared buses.

What happens in the fetch-decode-execute cycle?

The CPU fetches the next instruction from memory using the PC, decodes it in the control unit, executes it (often using the ALU), and repeats.

What three things affect CPU performance most?

Clock speed, number of cores and the size of the cache.

Where this is taught

NetherlandsHAVO 5 (eindexamenjaar)Architecture
NetherlandsHAVO 5 (eindexamenjaar)Elective theme: Computer architecture
NetherlandsVWO 6 (eindexamenjaar)Architecture
NetherlandsVWO 6 (eindexamenjaar)Elective theme: Computer architecture
Spain4º ESODigital devices, operating systems and communication
England (GCSE, A level)Year 113.4 Computer systems
FrancePremièreHardware and operating systems

Learn first

Learn next

Related lessons

All Computer Science lessons