video

Lesson video

In progress...

Loading...

Hey there and welcome back to computer systems. I'm Mac your computing teacher.

And in this lesson, we're going to be talking about the fetch-decode-execute cycle or the FDE cycle.

As per usual, you'll need a notepad and a pen to take notes while you're learning.

I'd also like you to remove all distractions from around you, this includes your mobile phone.

As ever, I've got my bottle of water here, so make sure you get some refreshment if you need it as well.

If you'd like to pause the video now and get all the stuff that you need, I'll be here when you get back.

In this lesson, you're going to explain the fetch-decode-execute cycle.

We're going to describe each stage of the FDE cycle, and we're also going to explain the role of the CPU components in the FDE cycle.

So let's start with recalling some of the CPU components you're introduced to in lesson 2.

So we covered a lot of different components and I'd like you to practise recalling them and their jobs before we go on to learn about the FDE cycle.

If you want to head over to your worksheet, there's a table for you to fill out with descriptions of each of the CPU components.

I'd like you to write down which component is being described.

Okay, pause the video now, fill out your worksheet, and then come back and we'll go through the answers.

Cool, welcome back.

Hopefully you found that okay and you didn't have to look back at your notes too much.

If you did, that's okay.

Let's have a look at the answers to these descriptions.

So which component carries data around the CPU? Well, is the buses.

The clock regulates the cycles per second.

The control unit instructs the other components.

The ALU is in charge of carrying out mathematical operations and the fast access memory locations inside the CPU are called registers.

Let's go on to look at the fetch-decode-execute cycle.

This describes the basic operation of a computer.

We've spoken a lot over the last three lessons about computer systems, computer architecture and how we put components together to achieve computation.

This last section, the fetch-decode-execute cycle describes how a computer physically executes a programme, the steps it needs to take to turn your code into physical or digital actions.

Each of the CPU components has a vital role to play in the cycle.

Memory also plays an important role.

This is the final part of Von Neumann architecture and was described alongside the stored programme concept which you learnt about in lesson 2.

Let's go through each one of the stages to give you a brief overview of what happens.

In the fetch stage, instructions are loaded from memory, RAM, before the processor starts the programme.

You remember I said this was a key thing.

Instructions always have to be loaded into RAM first before they are executed.

Each instruction is then fetched in order from memory one by one, from those RAM locations and put into the appropriate registers.

Again, the registers that you learned about in lesson 2.

We then go into the decode stage.

This is where the binary representation of an instruction is decoded before it can be run.

The control unit handles this part of the cycle.

Each processor will have a slightly different encoding which means the way it is represented in binary for each instruction.

Once it has been decoded, we can execute the instruction.

The control unit will tell the other components what they need to do in order to execute the instruction.

Right, there's a brief overview of the steps, but to get you thinking about this and executing it practically, I'd like you to do an FDE jumble.

I've got the stages of the FDE cycle listed out for you, and I'd like you to put them in the right order.

This is on your worksheet and you can use your notes from the previous lesson to help.

If you'd like to pause the video here, have a go at putting those steps into the right order, and then when you're done, come back and we'll go through the answers.

Welcome back, I hope you found that okay.

Let's have a look through and you can correct it if you did get any wrong.

So these are the steps and these are the places for them to go.

You can see that I've put the last step in there for you because the cycle repeats is a clear and stop.

It's also what makes it a cycle, it doesn't just happen once, it goes over and over and over again.

So what is the first step? The instructions are loaded into RAM, I told you this was important and it happens every time.

Before any programme can be executed, it needs to first be in RAM so that the processor can access it.

The instructions are then put into RAM in numbered memory locations.

This is so we can reference them later.

This is what happens with the memory address register that we spoke about in lesson 2, the RAM locations are stored in that register inside the CPU so that the instructions can be fetched.

The CPU then sends a signal requesting an instruction from a specific location in RAM.

If it's the start of the programme, that position will be 0,0 or right at the beginning of the programme if it's not the only thing in RAM.

The instruction is then transferred back via the data bus to the CPU.

There are a couple important buses, one of them is the address bus which carries the addresses that would've done step three, and the data bus carries any data back from memory to the CPU.

Next, the CPU decodes the instruction.

It takes the binary representation that was just returned from RAM, and it figures out which instruction that represents.

Each CPU will have a list of these instructions that it can check against the binary representations.

I'll put the next three steps in that, so we don't have to step through it all one by one.

But step six is that the CPU may fetch some data held in memory if it's referenced in the instruction.

For example, if we need to add two things together, you might need to go grab another piece of data to add to the accumulator during this stage.

Step seven, is that the CPU actually executes the instruction that has all the pieces it needs, it just waits for a clock pulse and then bam, it does the instruction, all the components work simultaneously to create a symphony.

Eight, any results might be stored back in RAM if that is necessary, otherwise they might just go to the accumulator.

Then nine, like we said, the cycle repeats, right? It's a cycle, it goes one after another executing each instruction and going through these steps.

If you'd like to pause the video here, just to make sure that your steps are the same as mine, then when you're done, you can resume and we'll carry on.

Well done for having a go at that.

Cool, maybe you just watch me sell on my own for a minute if you've got them all right, but if not, I hope you've got them in the right order now.

So we've got another little task that I would like you to do.

Now this I said represents the fetch-decode-execute cycle and it is all part of one process, but there are those three defined steps fetch, decode and execute.

I'd like you to figure out which of these numbered steps represents the fetch stage, which represents the decode stage, and which represent the execute stage.

You don't have to include every single one of the steps in here, just point to the ones you think are part of that process.

You want to pause the video here, have a go at that, you can either use the numbers by writing them down or you can drag the boxes to the right place on the table.

Welcome back again.

And that one might have been a bit harder, but don't worry, we're going to go through it together and then hopefully you've got it right? So, which other fetch stage? Now, the first two instructions are part of any of the official fetch-decode-execute stages but they are important before anything can happen.

If there is another fetch-decode- execute cycle after this, we won't load the instructions into RAM again, they're just there to be loaded, but there's important steps to remember in the process.

So which ones are the fetch steps? So step three and four describe the fetch of the cycle.

The CPU sending an instruction to RAM to get the data from a particular address and the data coming back from memory and being placed in the appropriate registers.

How about the decode stage? The decode stage is steps five and six.

So the CPU physically decoding the instruction, and then also going to fetch any extra data that is necessary.

This is the last part of the decode process when it figures out how the instruction works and might need some extra data.

And then finally, the execute stage, and that is stage seven and eight.

So the CPU executing the instruction, but also any results being saved back to RAM if that is part of the instruction.

And then step nine again is not officially part of any of these stages, but it's an important part for you to remember so that you can see how the cycle works.

Next, we're going to have a little look at the fetch-decode-execute cycle in action.

To do this, we're going to use a simulator called the little man computer.

All this is, is a simulated CPU that allows you to run programmes but you can see under the hood, we can see what's going on in the registers, we can see the RAM here.

Now I'm going to give you a demo of how this works.

So I'll see you in a second.

Well, I've put myself down on the button this time just so you can see everything that's going on up here.

But this is the little man computer.

As I said, this is a simulator for a CPU that allows you to look under the hood and see what is happening and some of the key registers, and also in RAM.

Just going to give you a brief tour of the site before you you have a play with it for yourself.

So you can see over here, we've got our programme.

This is written in assembly language.

This is a low level language that knows directly how to talk to a CPU.

Each CPU will have its own version of assembly language.

The little man computer uses a specific set of assembly language commands that work on all versions of the simulator.

Down here, we've got a little select box where we can choose different programmes to run.

I'd like you to change to this top one, adding two inputs.

It's a bit of a simpler programme and it will be easier for you to follow.

Then you have to click the load programme afterwards, and tell if that's okay and then it will come up over here.

Next you can see over here, we've got some views into the key registers inside of the CPU.

So you've got the programme comes are up here, the MAR, which stands for memory address register here, and the MDR, the memory data register.

You can also see the current instruction register just here, and the accumulator.

This little slider at the bottom will increase or decrease the clock speed, which should make your programme run either faster or slower.

Have a play with that when you're running it.

You can see here that we've got some labels for input and output, and also some helpful cheat sheets about the LMC.

The important part I'd like you to have a look at, is this RAM here.

So we've got this grid of memory locations that are numbered, just like we said from zero all the way out to 99, and you can see that my programme is currently loaded into the first six of these RAM locations.

I could have a much longer programme that takes up more, but right now I just have these seven commands.

It starts at zero, so the sixth's actually the seventh place, right.

We then have the current FDE cycle up here and a log file.

This is the best way we're going to watch to see what's happening during each part of the process.

Now that you've had a little introduction here, I'm going to head back to my slides, and then you can have a few tasks to do with this simulator.

Hey, there, welcome back to the slides.

Sorry for changing position on you again.

But this way you can see all the tasks I've got down here for you.

So I'd like you to follow the instructions in your worksheet, you'll see this slide is replicated on your worksheet and open up the LMC simulator.

I'd like you to change that programme to be adding two inputs instead, and then run the programme using the red run programme button just above where your programme is written out.

I then like you to think about these two questions.

So what does num1 represent on lines two and four? And what is the instruction number for INP, which stands for input? If you'd like to, pause the video now, head over to your worksheet and follow those instructions.

When you're done you can resume the video and come back and we'll go through some of those answers and will give you some more tasks to do.

Welcome back, how did you find that? I really love the LMC, I think it's a great way to see what's happening inside the CPU.

Let's have a look at those two questions and get some answers for you.

So what does num1 represent on lines two and four? Num1 is a memory address.

We're using this just like we would use variables in a normal programme.

We're giving a memory address a name, so that we don't have to use a number.

Computers love numbers, in fact it's the only way we can give addresses to computers.

But humans find those much harder to understand and to label than using words.

So the LMC allows you to use words like num1 to represent a memory address.

In this case, the memory addresses representing is six.

The very last one in the programme, you can see that's just got a single zero in it which means it has been reserved for a named memory location.

And what is the instruction number for input? It's 901.

You can see there are two inputs in this programme.

And in the first memory location, and in the third memory location, there is 901 site.

That is the instruction number, that is what will be encoded in binary and then decoded by the control unit.

So, now what I'd like you to do, is step through the programme.

Instead of using the run programme button up the top here, oh, don't click on the slides back.

Instead of using the run programme at the top there, I'd like you to use the step through button here which is just in the top next to your registers.

It's the one that looks like a skip to the next button or skip to the next song button.

Using that, you can step through each one of these instructions, one by one.

And I'd like you to have a look at what's happening in the log file.

While doing this, I'd like you to make some notes on your notepad about what each component is doing during each stage of the fetch-decode-execute cycle.

So make a heading for each fetch-decode-execute and then make a note of what each component is doing.

Not all the components are visible, so you have to remember what they're doing.

For example, the ALU is not on this simulator.

However, you know that if any mathematical operations are happening, then the ALU will be responsible for that, okay? Let's have a go.

I'd like to pause the video here again, run through the programme step by step and make a note on each component for each stage of the fetch-decode-execute cycle.

Welcome back again, how was that? Did you find that you understood the cycle a bit more having seen it and walked through like that? Cool, let's have a look at what each component was doing.

So during the fetch stage, the control unit is sending the fetch instruction, it's sending it down that address register to get the instruction number from that location in memory.

The ALU adds one to the programme counter because the programme counter went up and that's a mathematical operation, and the buses are carrying the instruction to memory and carrying the data back.

So those are two different buses again, remember.

The memory address register is holding the address to fetch the instruction from RAM.

So in this case, on the first step, it would have been zero then one, then two, it counts up.

Memory data register received the instruction when it was fetched from RAM.

So when the input command was called, the memory data register would have held the number 901.

The current instruction register gets a copy of that instruction as soon as it is batched.

And the programme counter goes up by one or stores that increased value that's produced by the ALU.

Once the instruction is fetched, we move on to the decode part and the control unit decodes the instruction.

The buses carry the instruction to the control unit and the current instruction register provides the instruction to the control unit for decoding.

Once that has all done, we can go into the execute cycle.

So the control unit tells the other components what they need to do to execute the current instruction.

The ALU performs any calculations that are necessary like the add that you saw in this programme, and the buses carry any data required or received from the instruction.

Your accumulator is holding any data that is produced by the calculations in the instruction.

That's all from us today.

Well done, this is a really hard thing to wrap your head around, and you've all done amazingly well today.

I hope you enjoyed this lesson, and the last thing I'd like to ask you is to share your work with Oak National.

If you'd like to, of course, please ask your parent or carer to share your work on Instagram or Facebook or Twitter tagging @OakNational and #LearnwithOak.

We'd love to see what you've been up to.

That's all from me for today, I'll see you in lesson 4, have a great day.

Bye.