- [Craig] In this video, we take a look at the classic von Neumann architecture.
(uplifting piano jingle)
The earliest computing machines had fixed programs.
For example, a desktop calculator is an example of a fixed-program computer.
It can do mathematics, but it cannot be used for any other purpose.
Changing a program of a fixed-program machine requires rewiring or redesigning the machine.
A stored-program computer is one that has changeable programs.
In 1945, the mathematician and physicist John von Neumann
described the first design for modern computers that had stored programs.
This way of designing computers became known as the von Neumann architecture.
A von Neumann architecture has key characteristics.
It has a central processing unit, a CPU with a single control unit.
Inside, it has an arithmetic logic unit, an ALU,
onboard cache, which is small amounts of high-speed memory
that helps the control of instructions and data around the CPU,
and also an internal clock, which provides a pulse at a constant rate to synchronise components.
This architecture computer fetches, decodes and executes instructions.
This isn't the most efficient design for processing,
but it was indeed simple.
Programs are made up of a sequence of instructions stored in the main memory outside of the CPU.
They are fetched one by one to the registers for processing.
As we noted in our other video on the common CPU components,
we stated that you do not need to actually know about
the names of all the individual registers inside the CPU for your exam.
But in order to make the most out of this video
and get a good understanding and overall appreciation of how a CPU works,
we will be covering the four registers shown on the screen here.
Let's have a closer look at the memory.
You will notice that each instruction is stored in a location in the memory,
and each location has an address.
Therefore, the processor can fetch an instruction stored in memory address one, for example,
and bring it back into the processor.
Now, computers are complex machines
capable of fetching and executing instructions billions of times a second,
using a very methodical sequence of events inside the CPU.
In order to do this, they make use of special purpose registers which we introduced in the last video.
Let's take a look at each one and see what it's used for.
The program counter always holds the memory address of the next instruction to be executed.
Once we fetch this address from the program counter,
we increment its contents by one so it points to the next instruction to be executed.
The memory address register holds the address of where data is to be fetched from or stored into.
The memory data register holds any data which has been fetched from memory or is about to be written to memory.
The accumulator holds the results of calculations which have been performed by the arithmetic logic unit.
Let's look at a typical fetch-execute cycle in a little more detail.
So we start with the fetch stage.
The program counter is checked, as it holds the address of the next instruction to be executed.
This address is used by the memory address register
in order to fetch the instruction needed from main memory
and bring it back into the memory data register.
The address in the program counter is incremented to point to the next instruction.
Now the instruction is in the CPU, the control unit decodes the instruction to see what has to be done.
Now we know what to do, we can execute the instruction.
What we actually do depends on what the instruction actually is.
We could be asked to head back to main memory and fetch some data and add it to the accumulator.
We could be asked to jump to another instruction.
We could be asked to write data held in the accumulator back into RAM.
Let's just quickly recap what we've gone over.
The von Neumann architecture consists of a control unit,
an arithmetic and logic unit, memory unit, and inputs and outputs.
It's based on the concept of the stored-program concept.
Both instructions data and program data are stored in the same memory in binary form.
There is no way to know if the pure binary held in memory
is representing instructions or data simply by looking at it.
The von Neumann architecture also contains a number of registers,
which are tiny, super-fast pieces of onboard memory inside the CPU,
each with a very specific purpose.
Now, the rest of this video definitely goes well beyond the GCSE specification,
but it is definitely worth watching.
There is no need to take notes,
but if you watch it, it will give you a really solid understanding
into all the concepts we've been talking about in the last few videos.
And we'll show you how data and instructions move around the CPU
and down the various buses during the course of a fetch-execute cycle.
So in the final section of this video,
we're going to follow through the various stages of the fetch-execute cycle to see exactly how
the program instructions stored in memory locations one through four are carried out in the CPU.
So we start with the fetch cycle.
The program counter is checked as it holds the address of the next instruction to be executed.
The address is copied into the memory address register.
The address goes down the address bus,
and the contents held in address one are sent along the data bus and end up in the memory data register.
So that was the contents load address five,
and you can see that's come back and it's now inside the MDR.
The contents of the program counter are incremented to two to point at the address of the next instruction.
And we've now ended fetch.
Now we're on decode.
Well, the first thing we do is take a copy of what's just been loaded into the CPU and place it into the cache.
This means if we need this instruction again soon afterwards,
we don't need to go back to main memory to get it.
The control unit now decodes the instruction, that's load five.
It discovers it needs to load the contents which are stored in memory address five.
So we update the memory address register with address five.
We're now done decoding the instruction.
We now execute the instruction and so pass address five down the address bus.
We then return the contents of address five, which is the value 23,
down the data bus and place it into the memory data register.
We copy the value from the memory data register into the accumulator.
A copy of the value 23 is again placed in the cache in case it's needed again.
Note that although the contents of the registers are being overridden,
the cache is normally larger and so can hold multiple items.
We have now finished our first fetch-execute cycle,
so we're on to the next.
And of course, we start with fetch.
The program counter is checked, as it holds the address of the next instruction to be executed.
The address is copied into the memory address register.
The address goes down the address bus.
The contents held in address two are sent along the data bus and end up in the memory data register.
So this time, it's the contents add address six that's ended up back in the MDR.
The contents of the program counter are incremented from two to three
to point to the address of the next instruction to be executed.
We've now ended the fetch part.
Again, a copy of what's just been loaded into the CPU is placed into the cache.
The control unit now decodes this instruction, add six.
It discovers it needs to add the contents which are stored in memory address six
to the value we currently have in the accumulator, which is 23.
So we update the memory address register with address six.
We're now done decoding the instruction.
We now execute the instruction and so pass address six down the address bus.
We then return the contents of address six, which is the value 12,
down the data bus and place it into the memory data register.
We store a copy of the value 12 in the cache in case we might need it again soon.
We now add the value in the memory data register, that's 12,
to the value held in the accumulator, which is 23,
and we override the contents with the result, 35.
This calculation is performed by the arithmetic logic unit.
We've now finished the second fetch-execute cycle,
and it's time to start the third.
The program counter is checked, as it holds the address of the next instruction to be executed.
The address is copied into the memory address register.
The address goes down the address bus.
The contents held in address three are sent along the data bus
and end up in the memory data register.
The contents of the program counter are again incremented to four this time
to point to the address of the next instruction to be executed.
Again, we've now ended the fetch part.
A copy of what's just been loaded into the CPU is again placed in the cache.
The control unit now decodes the instruction.
We discover we need to store the contents of the accumulator into memory address six.
So we update the memory address register with the address six
and we copy the value in the accumulator, 35, into the MDR.
We're now done decoding the instruction.
We now execute the instruction and so pass the address six down the address bus.
We pass the value 35 down the data bus.
This value ends up in address six and overwrites the contents which were there, which were 12.
As usual, we take a copy of the result of the calculation, 35,
and place it in the cache in case we need it again in the future.
We've now finished the third fetch-execute cycle.
We're on our final fetch-execute cycle now,
and again, the program counter is checked as it holds the address of the next instruction to be executed.
The address is copied into the memory address register.
The address goes down the address bus.
The contents held in address four are sent along the data bus and end up in the memory data register.
The program counter is incremented to five to point to the address of the next instruction to be executed.
Again, we've ended the fetch part.
A copy of what's just been loaded into the CPU is placed into the cache.
Now at some point, you might be thinking to yourself the cache is going to fill up,
and of course, it will.
And the CPU will need to decide what to get rid of.
The control unit now decodes this instruction,
and we discover the instruction fetched from memory is to end the program.
So we're now done with decoding.
We execute the instruction and end the program.
This program is now complete.
This program did the sum 12 plus 23,
and we stored the result, 35, back into main memory.
(uplifting piano jingle)