Lesson video

In progress...

Loading...

Hello, my name is Mrs. Jones and I'm really pleased that you've decided to learn with me today.

In this lesson, we're going to look at the different stages of the fetch-execute cycle.

So let's get started.

Welcome to today's lesson.

Today's lesson is called the fetch-execute cycle from the unit computer systems. And by the end of this lesson, you'll be able to describe the steps and functions of components in the fetch-execute cycle.

There are four key words to today's lesson.

Bus.

A bus is used to carry instructions from one component to another.

Binary representation.

Binary representation is a sequence of zeros and ones, the machine code of a computer.

Accumulator.

The accumulator is a register in the CPU that stores the results of calculations.

Simulator.

A simulator is a programme or system that imitates the behaviour of a real-world process.

There are two sections to today's lesson.

The first is describe the steps of the fetch-execute cycle.

And the second is explain how the LMC simulates the FE cycle.

So let's start with describe the steps of the fetch-execute cycle.

The CPU is the core of the von Neumann architecture and each component has a key function.

The clock keeps track of how many cycles have been completed.

Each cycle follows specific steps.

Fetch, decode and execute.

Instructions are loaded into main memory, RAM, before the processor starts running the programme.

Each instruction is then fetched from main memory in order and put into the appropriate registers.

The control unit can then access the instruction for the next stages.

So let's look at the fetch stage.

The programme counter, the PC, holds the memory address of the next instruction the CPU needs to fetch.

This address is then copied to the main address register, the MAR.

You can see this in the diagram, where we have that now have 0 in PC and 0 in MAR.

The address is sent along the address bus to main memory.

Memory finds the instruction at address 0.

The instruction, LOAD 2, is sent back to the CPU on the data bus.

The instruction, LOAD 2, is temporarily stored in the Memory Data Register, the MDR.

The instruction in memory location 0 was LOAD 2.

You can see that that is now stored in MDR, and that PC and MAR still have 0 in there at the moment.

It is then copied to the current instruction register, the CIR.

This is done if it is an instruction, not data loaded from memory.

So because LOAD 2 was an instruction, you can see it is now being copied to the current instruction register.

The control unit sends an instruction to the programme counter on the control bus to increase by one.

Let's have a quick check.

The address has been copied to the memory address register, MAR.

Which bus does it travel along to get to main memory? Is it A, the address bus? B, the control bus? or C, the data bus? Pause the video, go back through the slides and consider your answer and then we'll check it.

Let's check your answer.

The answer was A, the address bus.

Well done if you got that correct.

Let's have another check.

Once the instruction is collected from memory, it travels along the data bus to which register? Is it A, the current instruction register, CIR? B, the memory address register, MAR? C, the programme counter, PC? Or D, memory data register, MDR? Pause the video, go back through the slides, and consider your answer and then we'll check it.

Let's check your answer.

The answer was D, memory data register, the MDR.

Well done if you got that correct.

Let's have a look at the decode stage.

The binary representation of an instruction needs to be decoded before it can be run.

The control unit can only run instructions that have been fetched and decoded.

This is the process the control unit uses to work out what the other components need to do.

Each processor will have slightly different encodings for instructions.

So let's look at the decode stage on our diagram.

The control unit takes the instruction from the current instruction register, the CIR, along the control bus.

So you can see that now in the control unit.

The control unit decodes this instruction from the binary representation.

Decoded here means to load the data stored in memory address 2.

Once the instruction is decoded, the instruction will be executed.

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

So let's look at the execute stage on our diagram.

The control unit updates the memory address register, MAR, to 2 using the control bus.

The memory address register, MAR, sends the address along the address bus to main memory.

Memory finds the data at address 2.

The data is sent back to the CPU on the data bus.

The data received through the data bus is sent to update the MDR and stored in the accumulator.

It is stored in the accumulator as it is data and not an instruction.

That is one cycle of the fetch-execute cycle.

A computer can complete billions of these cycles per second.

The clock keeps count of the cycles completed.

For example, 2.

5 GHz, G-H-Z, means 2.

5 billion cycles per second.

Let's do an activity, and you'll need your worksheet for this.

In this first part, fill in the blanks to describe the fetch stage.

In the first bit, the CPU starts by looking at the.

Something.

This register holds the blank of the next instruction needed.

This address is then copied from the PC to the blank.

The MAR sends this address along the blank to the main memory.

Pause the video, go back through the slides, and use your worksheet and then we'll check your answers.

Let's check your answers.

The CPU starts by looking at the programme counter.

This register holds the address of the next instruction needed.

This address is then copied from the PC to the memory address register, MAR.

The MAR sends this address along the address bus to the main memory.

Well done if you got that correct.

Let's look at another activity.

Fill in the blanks to describe the fetch stage.

So we're continuing now.

The main memory finds the instruction at that address and sends it back to the CPU along the blank.

This instruction is temporarily held in the blank before being moved to the blank.

Finally, the programme counter, the PC, is automatically blank, so it points to the next instruction in sequence.

Pause the video, go back through your slides, use your worksheet and then we'll check your answer.

Let's check your answer.

The main memory finds the instruction at that address and sends it back to the CPU along the data bus.

This instruction is temporarily held in the memory data register, MDR, before being moved to the current instruction register, CIR.

Finally, the programme counter PC is automatically increased by one, so it points to the next instruction in sequence.

Well done if you got that correct.

Let's look at another activity.

This time, can you describe what happens next in the decode and execute stages? Pause the video, go back through the slides, use your worksheet and then we'll check your answers.

Let's check your answer.

The control unit takes the instruction from the current instruction register, CIR, along the control bus.

The control unit decodes the instruction and the control unit updates the memory address register, MAR, from the instruction decoded using the control bus.

The memory address register, MAR, sends the address to main memory using the address bus.

Memory finds the instruction or data stored in next address location and if data is located it is sent back to the CPU using the data bus.

The data is sent to update what is stored in the memory data register, MDR and accumulator.

The cycle repeats.

Well done if you got that correct.

Let's look at the next part of this lesson to explain how the LMC simulates the FE cycle.

A simulator can be a useful tool to imitate the behaviour of a real-world process.

The Little Man Computer, the LMC, is a way to simulate what is happening in the fetch-execute cycle.

CPUs showing the registers PC, MDR, MAR, CIR and accumulator can be seen following the arrow into the middle there.

We have the output at the top and input at the bottom.

The programme showing the sequence of instructions to be carried out can be seen on the left.

And on the right, we have the main memory, the RAM, showing storage locations for instructions and data.

In the Little Man Computer simulator you can load a preset example or type it in the first section and click load.

can see at the bottom here where it says add, you can click the drop-down and select add to be able to see the programme, the assembly language code loaded to add two numbers together.

Simulator for the fetch-execute cycle.

This is the example list of instructions for the add of two numbers, the sum of two numbers.

If we If we click Run Programme to start the instructions, we can see and view the simulation running.

The instructions that are visible on the left hand side are abbreviations.

The instruction INP, the function is it reads a number from the input tray and stores it in the accumulator.

OUT, writes the number in the accumulator to the output tray.

ADD, adds the contents of the specified memory location to the accumulator.

HLT stops programme execution.

STA stores the contents of the accumulator into the specified memory location.

Let's have a quick check.

What is the purpose of the STA instruction in the Little Man Computer simulator? Is it A, stops programme execution? B, stores the contents of the accumulator into the specified memory location? C, writes the number in the accumulator to the output tray or D, reads a number from the input tray and stores it in the accumulator? Pause the video, go back through the slides and consider your answer and then we'll check it.

Let's check your answer.

The answer was B, stores the contents of the accumulator into the specified memory location.

Well done if you got that correct.

Lucas is asking, "How does the Little Man Computer help understand the FE cycle?" It's a really good question.

The Little Man Computer simulator allows you to see the steps taken inside the CPU when it is fetching an instruction, decoding and executing it.

You can see the different registers change and through the simulation understand how this process works inside your computer.

This programme shows that it took six fetch-execute cycles and this is shown on the programme counter.

There are two inputs, they are added together and the output is displayed.

You can see there, six cycles have been completed.

To create a programme that adds three numbers together, the instructions would be INP for input, STA num1, so store that num1.

Input again INP, ADD num1.

STA num1, so storing again.

INP, input another number.

ADD it to num1, and then OUTPUT it, and HLT, H-L-T, to end it.

And when you run that programme, You can see that the programme counter has nine cycles completed.

Let's do an activity.

You're going to open the link that has been given to you for the Little Man Computer simulator and create the programme to add four numbers together.

Add your code to your worksheet.

So pause your video, go back and look at the slides, open that link and see if you can create the programme to add four numbers together and then we'll check your answer.

Let's check your answer.

So this time, we have INP, so input.

STA num1, INP, ADD num1, STA num1, INP, ADD num1, STA num1, INP, ADD num1, OUT, HLT.

Well done if you got that correct.

Let's look at another activity.

In this activity, describe how the Little Man Computer shows the fetch-execute cycle.

Pause the video, go back through the slides, use your worksheet and then we'll check your answer.

Let's check your answer.

The Little Man Computer is a way to simulate what is happening in the fetch-execute cycle.

The little man computer simulator allows you to see the steps taken inside the CPU when it is fetching an instruction, decoding and executing it.

You can see the different registers change and through the simulation understand how this process works inside your computer.

Well done if you got that correct.

In summary, the fetch-execute cycle works between the CPU and the main memory using the different types of buses to transport data or instructions.

An instruction is fetched from memory, decoded from the binary representation and executed before the cycle starts again.

There are different registers inside the CPU with different functions including MDR, MAR, CIR, PC and accumulator.

The Little Man Computer Simulator enables you to run a simulation that imitates the process of the fetch-execute cycle.

Well done for completing this lesson on the fetch-execute cycle.