0% found this document useful (0 votes)
2 views38 pages

Fetch Decode Execute

The document outlines the Fetch-Decode-Execute (FDE) cycle, which is the process by which a CPU processes instructions. It details the steps involved in fetching an instruction from RAM, decoding it, and executing it, emphasizing the role of various registers and the importance of the program counter. The document also includes learning objectives and questions to reinforce understanding of the FDE cycle.

Uploaded by

Nabil Saheb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views38 pages

Fetch Decode Execute

The document outlines the Fetch-Decode-Execute (FDE) cycle, which is the process by which a CPU processes instructions. It details the steps involved in fetching an instruction from RAM, decoding it, and executing it, emphasizing the role of various registers and the importance of the program counter. The document also includes learning objectives and questions to reinforce understanding of the FDE cycle.

Uploaded by

Nabil Saheb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

1.

1 – Systems Architecture

Nabil Saheb
September 2022
Fetch-Decode-Execute
• Inside the CPU is a clock. Every time the clock
‘ticks’, a single instruction can be processed.

• Now this may not sound like a lot but the CPU
can process billions of instructions per second.
accumulator
CCPPUU
M
M
t D
e
RRAAMxecu DRR
M
e
r o l e c u t
CCont l
o n t r o e xe
ra m
m
i
uunnitt o gr a r i nnssttrruction
ro g
Pr ntte er i u ct i on
P un
o u
cco M addr
MAARR es s
u t e o n t r o l
c C
exe ffeettcchh
unit
Learning Objectives
• By the end of this lesson you will:

• Understand the purpose of the fetch-


decode-execute cycle
• Understand the role of the main registers
in the F-D-E
• Be able to describe the process of the F-
D-E
• Write down as many terms as you can
remember

• Extension task
• Write a definition for one of the terms
• To process an instruction, the CPU will go
through the ‘fetch-decode-execute cycle’ –
every single time!
• Software (programs) provide the CPU with
instructions, telling it what to do next.
• The software is loaded, by the operating
system, into main memory (RAM)
Fetch

• The first instruction in the program is loaded


from main memory into the CPU (it is fetched)
Decode-Execute

• The instruction is then decoded and finally


executed. Both these actions take place with
the CPU.
• Once the first fetch cycle is complete, the CPU
will fetch the next instruction.
Registers
• A number of different registers inside the CPU
are involved with the FDE cycle:
Fetch
• We are going to look at the fetch-decode-execute
cycle in more detail.

• It is important to realise that there can be more


than one program running in main memory at any
given time (they take turns executing their
instructions in the CPU).

• Also, programs do not necessarily start at location


zero in main memory.
Fetch
• In the table below are a list of the registers
involved in the FDE (you do need to know
about these for your exam)
Fetch
The program is loaded into RAM by the
operating system.

The operating system notifies the CPU where it


can find the first instruction in RAM.

This location is loaded into the program counter


and the fetch cycle begins
Fetch

So let’s assume that our program’s first


instruction is stored in RAM at location 305.
The program counter is updated with this
location
Fetch

• As this is the first instruction to be fetched,


nothing has happened so far and so the
accumulator register is set to 0.
• If the program had been running for a while then
the accumulator would probably contain a
different value
Fetch
• The address location in the program counter is
copied into the memory address register
(MAR)
Fetch

• Next the control unit loads the address from


the MAR onto the address bus
Fetch

• RAM then reads the contents of the address


bus and then looks up the content stored at
that location
Fetch

• The content, (in this case an instruction saying


‘add #5’) is then loaded onto the data bus.
Fetch

The instruction (add #5) is passed across the data bus


and copied into the memory data register (MDR).
Fetch

• Next, the instruction in the MDR is copied into


the instruction register
Fetch
• The program counter is now incremented by
one location – i.e. it changes from 305 to 306.
Fetch

This is the end of the fetch cycle.

The CPU is now ready to begin the next fetch


cycle.
Decode

• While the next fetch cycle begins, the CPU is


simultaneously decoding the first instruction
(from location 305)
Decode

• The control unit reads the contents of the


instruction register – in this case ADD #5
Decode
• It checks that this is a valid instruction i.e. it is
part of its instruction set.
• Each type of CPU has its own instruction set that
the control unit understands. For example, this
CPU knows what the instruction ‘ADD’ means.
Decode

• If for some reason the instruction wasn’t part


of the CPU’s instruction set, e.g. SPGH#123
then it would not recognise it.
• If this were to happen then the program has
probably been corrupted and it will crash.
Execute
Execute

Once the instruction has been decoded and


accepted as valid then the final part of the cycle,
execute, can begin.
Execute
• The ALU is responsible for all calculations, including ADD.

• The ALU will read the original value of the accumulator. Then it
will process the instruction i.e. ADD #5.

• It will then store the result of the calculation in the accumulator.


1) Which part of the Fetch-Decode-Execute
cycle gets the instruction from the RAM?
2) Instructions are fetched from main memory
3) The fetch decode execute cycle runs even when
the computer is off
4) In the Fetch- Decode - Execute cycle, it doesn't
matter which order things take place
5) What happens in the 'fetch' part of the Fetch
Decode Execute Cycle
6) During the Fetch-Decode-Execute cycle, the
software to be run is located in the CPU
7) When the fetch-decode-execute cycle finishes the
CPU gets ready to start the cycle again.
Questions
• Where is the software stored while it is running?
• The …………………. is where the address of the
next instruction is kept and updated.
• Where is the program counter value is copied to
when the next instruction is being located?
• which part of the cycle is where instructions are
carried out?
• Which part of the cycle that reads the
instruction and determines if it can be carried
out.
Any questions?

You might also like