CPU Fetch-decode-execute cycle

What is CPU? How does it work? What is the Fetch-Decode-Execute cycle?

When a teacher asks you to do something, you listen (fetch), work out what you are being asked to do (decode) and then do it (execute). A CPU works in a similar way. See the diagram below that explains the cycle:

A microprocessor contains several circuit groupings. With all the circuit groups of the microprocessor working together, the computer is able to do the tasks that the software instructs it to do. The microprocessor repeats three steps—fetch, decode, and execute—over and over again to complete whatever task the computer is required to do.

The circuitry of a computer is built to follow these steps rapidly and accurately. A desktop computer does these three steps hundreds of millions of times in a second as it completes any given task.

What is Little Man Computer:

The Little Man Computer (LMC) is a simulator which models the basic features of a modern computer. It is based on the Von Neumann architecture featuring a central processing unit consisting of an arithmetic logic unit and registers, a control unit containing an instruction register and program counter, input and output mechanisms and memory to store both data and instructions.

The LMC is based on the concept of a little man (shut in a small room or inside a computer) acting like the control unit of a CPU i.e. fetching instructions from memory, decoding and executing the instructions, and managing the input and output.

The LMC can be programmed using either "Machine Code" or "Assembly Language".

 

Starter:

This activity, courtesy of CS Unplugged, and it will provide you with a basic understanding of how computers work by having them act out a simple computer simulation.

How it works:

Each student takes on the role of a different part of a simplified computer (CPU, ALU and Display) and, working in groups of three, run a simple program. The end result of this program is to draw a picture on a simulated computer display.

You download the activity here: http://cse4k12.org/how_computers_work/index.html

 

Activity 1:
Load Little Man Computer (http://peterhigginson.co.uk/LMC/) and you will use this to learn about how the main function of the CPU is used to fetch and execute the instructions.

Load the following set of instructions, to add two numbers, into the simulator to demonstrate how the simulator works.


Click on 'Submit' to load the instructions followed by 'RUN' to execute the code.

 

Activity 2:

Using the LMC simulator, in groups of about 4 or 5, load the Little Man Computer simulator and execute a sample program.

Download Printed Instructions

Place the printed instructions in the correct order and record your answers on the task sheet, provided. Click here

After 5 mins, discuss with the class your findings.

After discussing the sample program read the LMC reference sheet and explain the different instructions. Click here

Challenge Task 1

Using the reference sheet and what you have learnt, write a program to add 3 numbers and execute it in the LMC simulator.

As an extension, write a program to add and subtract a number or to write a program of your own

Click here

Challenge Task 2

Convert the instructions from assembly language to machine code. Click here
LMC Machine Code Reference Sheet

Plenary: CPU Dingbats

Finish by playing a game of CPU dingbats. Click here: cpu_dingbats_plenary.pptx

 


Comments