Hardware and network technologies - CCEAFetch-execute cycle

Hardware is the physical components of a computer system. When we connect computers together to share data, software and hardware we create a network.

Part ofDigital Technology (CCEA)Digital technology (compulsory)

Fetch-execute cycle

The is the steps a CPU goes through in order to process an instruction.

At the start of the fetch-execute cycle, both the data and the instruction are loaded into the computer's main memory so they are ready to be processed.

What is an instruction?

An instruction is an action that a program wants the CPU to carry out. For example, this could be to move specific data from one memory location () to another. The table below shows three instructions. Each instruction is made up of an operator and two .

The CPU first fetches an instruction from the RAM. It then decodes this instruction to work out what operation it needs to do (the operator), and what the operands are (the data). Finally, the CPU will execute the instruction.

InstructionOperatorOperandExecution
move, #161, r0move#161Place value 161 into register 0
move, #16, r1move#16Place value 16 into register 1
add, r0, r1add-Add the values in registers 0 and 1
Instructionmove, #161, r0
Operatormove
Operand#161
ExecutionPlace value 161 into register 0
Instructionmove, #16, r1
Operatormove
Operand#16
ExecutionPlace value 16 into register 1
Instructionadd, r0, r1
Operatoradd
Operand-
ExecutionAdd the values in registers 0 and 1

In this example, the CPU places 161 into register 0, places 16 into register 1 and adds both numbers together. This would require three cycles of fetch-execute.

Fetching an instruction

The Program Counter (PC) copies the address of the next instruction it contains into the .

The MAR places the address to be used on to the .

The instruction on the is loaded into the Memory Data Register (MDR).

The MDR copies the instruction into the .

Executing an instruction

The instruction in the IR is carried out (executed) by the CPU. This will generally involve the ALU carrying out a calculation.

Now that the CPU is executing an instruction, the Program Counter can now be reset to point to the next instruction.

Summary of the fetch-execute cycle

  1. The processor checks the program counter to see which instruction to run next
  2. The Program Counter gives an address value in the memory of where the next instruction is
  3. The processor fetches the instruction value from this memory location
  4. Once the instruction has been fetched, it needs to be decoded and executed. For example, this could involve taking one value, putting it into the ALU, then taking a different value from a register and adding the two together
  5. Once this is complete, the processor goes back to the Program Counter to find the next instruction
  6. This cycle is repeated until the program ends
The Decode-Execute-Fetch cycle between the registers, control unit, ALU and RAM