University of Wales Trinity Saint David
ACCA4021 - Introduction to Computer Systems

The Von Neumann Architecture

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:

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?

Memory only ever holds bit patterns. A location becomes an instruction when the CPU fetches it as one, and data when an instruction uses it as data.

What is the main advantage of the stored-program concept?

Because a program is just bits in memory, changing what the computer does is as easy as loading different bits into memory.

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.

PartWhat 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)
RegistersVery small, very fast storage locations inside the CPU, each holding one value the CPU is using right now
Main memoryHolds the program and its data, in numbered locations
System busThe shared wires connecting the CPU, memory and I/O devices
Input and output devicesGet 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?

The control unit fetches and decodes instructions and sends control signals to the other parts.

A program needs to work out whether one number is bigger than another. Which part does the comparison?

Comparisons, like arithmetic, are done by the arithmetic logic unit.

Where is the program kept while it runs?

That is the stored-program concept. In a Von Neumann machine, one memory holds both instructions and data.

Why does the CPU have registers when it already has main memory?

Registers are tiny but extremely fast because they are built into the CPU itself. The CPU keeps the values it is working on right now in registers.

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?

Instructions and data share one bus between the CPU and memory, and the bus can only carry one thing at a time. The CPU often has to wait for the bus before it can fetch its next instruction or move its data, so the speed of the whole computer is limited by the speed of that shared path to memory.

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?

At tick 2 the instruction bus is fetching instruction 2 while the data bus is moving the data for instruction 1. They can happen at the same time because they use different buses to different memories, so neither has to wait for the other.

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 NeumannHarvard
MemoryOne memory for instructions and dataSeparate instruction memory and data memory
Buses to memoryOne shared busSeparate instruction and data buses
Fetch and data access at the same time?No, they take turnsYes
DesignSimpler and cheaperMore wiring and more complex
FlexibilityMemory can be split between program and data however a program needsEach memory has a fixed size, so space left over in one cannot be used by the other
Typical useGeneral-purpose computersMicrocontrollers (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?

Separating instruction memory from data memory, each with its own bus, is what defines the Harvard architecture.

Which of these is a disadvantage of the Harvard architecture?

Each memory has a fixed job, so a program with lots of data and a small amount of code cannot borrow the unused instruction memory.

A washing machine is controlled by a small microcontroller whose program never changes. Suggest why a Harvard design suits it.

The program is fixed, so it can live in its own instruction memory and never needs to be shared with data. Separate buses let the microcontroller fetch its next instruction while it reads sensors or writes data, so it can respond quickly with a cheap, slow-clocked chip.

Task 6 - Check your understanding

Which list contains only parts of the CPU?

The CPU contains the control unit, the ALU and the registers. Main memory, the buses and I/O devices are outside it.

Memory location 9 holds 0010 0111. Which statement is true?

The bits could be the number 39 or the instruction STORE 7. Memory does not record which. The program decides.

Why does adding a faster CPU not always make a Von Neumann computer much faster?

This is the Von Neumann bottleneck. If the bus to memory cannot keep up, a faster CPU spends more of its time waiting.