Overview
Almost every computer you have used, from a laptop to a games console, follows the same basic design. It was described by John von Neumann in 1945 and is called the Von Neumann architecture. This worksheet introduces its parts, shows how they are connected, and explains the one big idea that makes it work: the program is stored in memory, in exactly the same way as the data it works on. You will also meet the design's main weakness, and the Harvard architecture, which avoids it. Work through the tasks in order. Most tasks have an interactive diagram and self-checking questions, so try each question before checking.
Learning Objectives
By the end of this lab you will be able to:
- Explain the stored-program concept
- Identify the CPU, control unit, ALU, registers, main memory, buses and I/O devices, and describe the job of each
- Explain why the same bit pattern in memory can be an instruction or a piece of data
- Explain the Von Neumann bottleneck
- Compare the Von Neumann and Harvard architectures
Concept
A computer needs somewhere to keep the program it is running and the data that program uses. Early machines kept them apart. The program was set with switches and cables, or read from a strip of punched tape, and changing the program meant physically rewiring or reloading the machine.
The Von Neumann design puts the program into main memory, alongside the data. Each instruction is just a pattern of bits in a numbered memory location. The CPU reads instructions from memory one at a time and carries them out. Loading a different program is then no harder than loading different data. This is called the stored-program concept.
Everything in the machine is connected by a shared set of wires called the system bus. The CPU uses it to fetch instructions, to read and write data, and to talk to input and output devices.
Tasks
Task 1 - Programs live in memory
The diagram below shows the first eight locations of a computer's memory. Each location has an address (its number) and holds 8 bits. The program in this memory adds two numbers together. It uses an instruction set with only a handful of instructions, such as LOAD 5 (copy the value at address 5 into the CPU) and ADD 6 (add the value at address 6 to it). Each instruction is stored as 8 bits: the first 4 bits say what to do and the last 4 bits say which address to use.
Use the three buttons to read the same memory in three different ways. Then click individual rows to see the bits behind them.
Address 1 holds 0011 0110. Read as a number, this is . Read as an instruction, it is ADD .
Address 5 holds 0000 0011. Read as a number, this is .
Storing the program in the same memory as its data is called the concept.
How does a memory location "know" whether it holds an instruction or a piece of data?
What is the main advantage of the stored-program concept?
Task 2 - The parts of a Von Neumann computer
A Von Neumann computer has four main parts: the CPU, main memory, input and output devices, and the bus that joins them. The CPU itself is made of three smaller parts.
| Part | What it does |
|---|---|
| Control unit (CU) | Fetches each instruction, decodes it, and sends signals telling the other parts what to do |
| Arithmetic logic unit (ALU) | Does calculations (add, subtract) and logic operations (AND, OR, NOT, compare) |
| Registers | Very small, very fast storage locations inside the CPU, each holding one value the CPU is using right now |
| Main memory | Holds the program and its data, in numbered locations |
| System bus | The shared wires connecting the CPU, memory and I/O devices |
| Input and output devices | Get data into the computer (keyboard, mouse) and out of it (screen, speakers) |
Click each part of the diagram to read more about it. Leave the diagram on Von Neumann for now.
Which part of the CPU decides what happens next by decoding each instruction?
A program needs to work out whether one number is bigger than another. Which part does the comparison?
Where is the program kept while it runs?
Why does the CPU have registers when it already has main memory?
Task 3 - One bus for everything
Look again at the system bus in the Task 2 diagram. It is drawn as three lines because it is really three groups of wires.
- The address bus carries the address of the memory location the CPU wants.
- The data bus carries the value being read or written.
- The control bus carries signals that say what should happen, such as "read" or "write".
Every instruction the CPU fetches travels along the data bus, and so does every piece of data the CPU reads or writes. Input and output devices share the same bus.
The bus carries the number of the memory location the CPU wants to use.
The bus carries the value being read from or written to memory.
The bus carries signals such as "memory read" and "memory write".
In a Von Neumann machine, instructions and data travel along the bus.
Task 4 - The Von Neumann bottleneck
Sharing one bus between instructions and data is simple, but it has a cost. Most instructions need two separate trips along the bus: one to fetch the instruction itself, and one to read or write the data it uses. A bus can only carry one thing at a time, so the trips have to queue.
The diagram below races two machines running the same four instructions. The top machine has one shared bus. The bottom machine has separate buses for instructions and data. Before you press Run, predict how many clock ticks each machine will need.
The Von Neumann machine needed ticks to run the four instructions.
The machine with separate buses needed ticks.
In your own words, what is the Von Neumann bottleneck?
Look at the timeline for the machine with separate buses. At tick 2, what is happening on each bus, and why can the two transfers happen together?
Task 5 - The Harvard architecture
The machine with separate buses in Task 4 follows the Harvard architecture. Go back to the diagram in Task 2 and press Harvard. Memory is split in two: an instruction memory that only holds the program, and a data memory that only holds data. Each has its own bus.
| Von Neumann | Harvard | |
|---|---|---|
| Memory | One memory for instructions and data | Separate instruction memory and data memory |
| Buses to memory | One shared bus | Separate instruction and data buses |
| Fetch and data access at the same time? | No, they take turns | Yes |
| Design | Simpler and cheaper | More wiring and more complex |
| Flexibility | Memory can be split between program and data however a program needs | Each memory has a fixed size, so space left over in one cannot be used by the other |
| Typical use | General-purpose computers | Microcontrollers (such as the chip on an Arduino) and digital signal processors |
Modern desktop CPUs use a mix of both. Main memory is shared, Von Neumann style. Inside the CPU, though, the fastest level of cache memory is split into an instruction cache and a data cache, so the CPU can fetch and move data at the same time. This mix is often called a modified Harvard architecture.
What is the key difference between the Harvard and Von Neumann architectures?
Which of these is a disadvantage of the Harvard architecture?
A washing machine is controlled by a small microcontroller whose program never changes. Suggest why a Harvard design suits it.
Task 6 - Check your understanding
Which list contains only parts of the CPU?
Memory location 9 holds 0010 0111. Which statement is true?
Why does adding a faster CPU not always make a Von Neumann computer much faster?