The CPU and Von Neumann Architecture
Hey, we're looking at the CPU in this video, just a real introduction to it on quite a basic level.
So the CPU, if you don't know, it sits on the motherboard. This is the motherboard here.
This rectangle object with loads of ports on it. This is a heatsink and this is what's sitting on
top of the CPU. The CPU looks a bit like this, just a pin that plugs into your motherboard
and because it's so powerful, because it produces so much heat, it needs its own dedicated fan
called the heatsink to cool it down sufficiently. So this is where you'd find it actually as the
hardware device on a computer, but we'll be looking at it from a more theoretical point of view in this video.
So it stands for Central Processing Unit and it's for hardware that controls the manipulation of
data, that processes data, that's what it does. And it's worth pointing out that in a computer
there are potentially several processors. Not only can you have multi-core CPUs where you have
kind of like several CPUs within a CPU, if that makes sense, we'll look at that a bit later,
but you can also have processors and things like graphics cards and sound cards.
So processor is kind of like a general term, but it is used interchangeably with CPU,
just bear that in mind. But to start off, let's just break it down into three components. The ALU,
the control unit, the CU and the register unit. So firstly, the CPU isn't obviously this simplified,
but firstly the ALU is actually what does the processing that actually carries out the
instructions. This is the arithmetic logic unit, it's written with a forward slash for some reason,
I can't say I know why, but it is. So ALU, arithmetic logic unit, and this actually
performs operations, so it performs arithmetic operations like addition, multiplication,
division and so on. And the logic ones like, I mean, basically evaluating something to false or
true, the two boolean values. So this is what actually does kind of the hard work, but it's
overseen by the control unit, which actually coordinates the CPU. And because the CPU is kind
of what is controlling the whole computer, it's what's doing all the computer's processing apart
from these potential graphics card, sound card processor, which is doing a very specific task,
but generally it's controlling the whole computer. You wouldn't be watching this video if the CPU
wasn't working in your device. And the control unit actually kind of warms up the circuitry,
it decodes the instructions, actually deals with the data transfers and so on. And the registers
are small quick sorts of data, you might have say, I don't know, 32 on your CPU. And some of them are
used for programmers, some are used for the fetch execute cycle, which we'll cover later.
They're very quick, very small, but actually on the chip. And they're mostly there for efficiency,
because it's very slow comparatively to have to keep going back and forth between memory.
They're used kind of like a temporary storage on the CPU, and they're used in this operation as
well. So I wanted to talk about the Von Neumann architecture briefly. And this is a term for
essentially what we've just looked at, it falls under this category. And all the hardware we're
looking at, all the modern computers fall under this category of Von Neumann architecture.
And this is often a point of confusion, because it's not really taught, because it's so ubiquitous,
because everything essentially is based on this architecture, it means the teachers don't really
explicitly say it's a Von Neumann architecture, people often get confused, because they see this
term, and they're like, I've never heard of this before. And actually, it's what we've learned all
along. So you know, you don't really have to know about the other architecture, the other models
available, this is going back to 1945. But essentially, it says that we can break our
systems down into four components for main memory or just memory, which is where the registers in
this kind of model would fit in. And we'll talk about memory a lot more in the hardware videos.
But also we've got ALU, we've got a control unit, this is the processing unit of this
theoretical system. And we've also got input output devices. And again, this is going back
to 1945. So if you can imagine the processes, and the computers as a whole back then,
this is very simplistic. But this does also mean a second major characteristic of this is that
the instructions are executed, the instructions that are executed are stored alongside the data
in memory. So everything is stored in memory alongside each other, in binary, as we would
have talked about another point in the course. And this concept, the fact that the data and the
instructions are stored together is the stored program concept. And again, this is often attributed
to von Neumann, perhaps unfairly to the people who actually did it, because I think he was just,
anyway, he was very famous. But this contrasts with another model, which isn't really used in
modern computers. And this is, this would be the hard Harvard model. And in the Harvard model,
there's basically two different memories, one for the instructions and one for the data,
but we don't use that. So we're not going to worry about that too much.
In the von Neumann model architecture, instructions are executed sequentially,
and this is how it works in our computers. So one instruction at a time is fetched from memory,
and passed to the CPU. And this means that even if your CPU is absolutely rapid, and it's very,
very fast, if the connection between memory and the CPU in this bus in this wire,
if it's very slow, you get a bottleneck, which is called a von Neumann bottleneck.
And that's just an interesting feature of this architecture. I mean, I say interesting. Anyway,
we have to talk about the clock briefly in this topic, it's actually very important for the whole
computer, but especially for the CPU's operation. So computers have a system clock, which is
actually there to provide just general timing signals, it's not specific to anything, it's just
there to, in the background, provide timing signals. And it's used by the circuits, any
circuit in the computer, to synchronise itself. And it's not like a clock, like we're used to,
it's like a metronome in music, which kind of just produces a steady rhythm, a steady pulse
of voltage, this is representing two different voltage levels, it could be on and off, it could
be 5 volts and 10 volts. But the fact remains that it's a very steady kind of pulse, pulse, pulse.
And first of all, you can use it to synchronise your circuits. So for example, you might only
transfer data on a rising edge of the clock, or you might only do it on a falling edge of the
clock, you might only write data when the clock is high, asserted high, or if it's asserted low,
essentially, the devices can use the clock as they wish. And the clock, the system clock actually
sits on a motherboard. And like I said, it's used by any devices, but the CPU uses it. And
CPUs are designed and manufactured to operate at a specific frequency. The CPU is much faster than
all the other components. So it needs to essentially have a clock that oscillates
faster, that has a higher frequency. And so the CPU takes the system clock and
changes it so it's a lot faster. And this is the clock speed. And the clock speed is very important
because the CPU needs a certain amount of clock cycles, or ticks, essentially, an arbitrary amount
of these, we could just say one, for example, per instruction. So it uses a cycle and this cycle
is the fetch execute cycle. So all this does is this is just the process of the CPU
executing a single instruction. So if we just go back a second, it might execute instruction
whenever the clock is high. So instruction here, instruction here, instruction here, and so on.
And the faster this is done, the faster the CPU will operate because it's got a higher clock speed.
Anyway, so the fetch execute cycle, first of all, as we've talked about this, the memory is
external to the CPU and the instructions are stored in the memory. So they need to be retrieved by
the CPU from the memory. And this is just the fetch stage of this cycle. So first of all,
instructions go to the CPU. When they're there, they go into the control unit and the instructions
broken down into its kind of constituent parts. And an instruction is split up into its operator
and its operand. The operator is telling you what it's doing, like add in this example.
Actually, the addition here is an operator. And operand is another word for data. And so we have
two operands here, these are two registers. So this instruction assembly code is saying,
we want to add the contents of R5, register five to the contents of register one. And so in this
stage, it works out what the instruction is, depending on what the operator is, it will
essentially, it's relevant for the execute stage where the data is actually executed. Here,
the CPU will use the information it's got from the decoding stage to activate the necessary
circuitry in the ALU. Or if it needs more data, or if it needs to transfer to or from registers,
like it does in this case, it will do it in the execute stage. And this is all done by the control
unit. The actual execution of the instructions, the following of the instructions is done by
the ALU. And the output of this is stored in a register, or maybe stored in a register. And also
any other data may be read or written to registers or main memory. So in this case,
it's got to read from R5, it's got to read the contents of R5, and it's got to store this as R1.
So it's got to do a bit of reading and writing in the execute stage. So this is a cycle. And as I
say, it needs a certain amount of clock ticks per instruction. And so the faster the clock speed is,
the more cycles it will do, because it's just going to inherently follow the cycle. And so
the faster the clock speed is, the higher the frequency, the faster the CPU is.

