COMPUTER ARCHITECTURE
Chapter 2
Fetch Decode Execute Cycle
Objective
 Explain the Fetch Decode Execute Cycle:
Illustrate Data Flow in the CPU:
Identify the types of registers in the CPU
Explain the process of interrupt handling and its importance.
F e t c h - D e c o d e - E x e c u t e C y c l e
F e t c h - D e c o d e - E x e c u t e C y c l e
Stored Program Concept
Historically there have been 2 types of
Computers:
 Fixed Program Computers – Their
function is very specific and they
couldn’t be reprogrammed, e.g.
Calculators.
 Stored Program Computers – These
can be programmed to carry out many
different tasks, applications are stored
on them, hence the name.
 Program instructions and data
are both stored in Memory
 Instructions are fetched and
execture one after the other
F e t c h - D e c o d e - E x e c u t e C y c l e
Key Terms
F e t c h - D e c o d e - E x e c u t e C y c l e
Fetch Decode Execute Cycle:
• Fundamental process of any computer's CPU
• Three main parts: fetching the instruction, decoding it, and executing it
• Perpetual operation in the CPU
• Involves the Program Counter (PC), decoder, and Control Unit
F e t c h - D e c o d e - E x e c u t e C y c l e
Ba sic I nst ru c t io n C y c l e
F e t c h - D e c o d e - E x e c u t e C y c l e
F e t c h - D e c o d e - E x e c u t e C y c l e
Stages of the Fetch-Decode-Execute Cycle
 Fetch: an instruction is passed from memory to CPU
 Decode: the CPU works out the meaning of the instructions
 Execute: the CPU carries out the instruction
NB: The cycle then repeat…
F e t c h - D e c o d e - E x e c u t e C y c l e
Registers found in the CPU
 PC: contains the memory address of the next instruction to be fetch
 MAR: contains the address of the current instruction to be fetch
 MDR: contains the instruction/data after it is fetched from main memory
 CIR: contains the instruction/data to be decoded
 MBR: holds/stores data temporarily before using them
 ACC: stores the result of any calculation carried out in the ALU
F e t c h - D e c o d e - E x e c u t e C y c l e
System Buses
 Address bus: carries the address of the next item to be fetched, and it is one
directional (from CPU to main memory)
 Data bus: carries the actual data (or instruction) that has been/will be
processed. It is two direction – either way between CPU and main memory
 Control bus: carries control signals that direct the actions of the CPU. It can
be one or two directional
Simplify Schema Diagram of a Single Core CPU
F e t c h - D e c o d e - E x e c u t e C y c l e
Steps in the Fetch Decode Execute Cycle Content:
1. The PC holds the address of the next instruction to be fetched
2. The address in the PC is copied to the MAR via address bus
3. The PC is incremented so it contains the address of the next instruction
4. The instruction at the address held in the MAR is copied into the MDR
5. The instruction in the MDR is copied into the CIR
6. The instruction is now decoded and executed
F e t c h - D e c o d e - E x e c u t e C y c l e
F e t c h - D e c o d e - E x e c u t e C y c l e
F e t c h - D e c o d e - E x e c u t e C y c l e
Fetch Cycle
• CPU retrieves the instruction from memory
• Instruction stored at address specified by the PC
• PC incremented to point to the next instruction
• Steps:
• Address in PC moved to MAR
• Address placed on the address bus; control unit issues READ command
• Result appears on data bus, copied to MBR
• Program Counter incremented by one
• Content of MBR moved to CIR
F e t c h - D e c o d e - E x e c u t e C y c l e
Decode Cycle
• CPU interprets the instruction
• Determines what operation to perform
• Identifies opcode and operands
F e t c h - D e c o d e - E x e c u t e C y c l e
Execute Cycle
• CPU performs the operation specified by the instruction
• May involve:
• Reading/writing data from/to memory
• Performing arithmetic/logic operations
• Manipulating control flow of the program
• Example:
• ADD R, X (Adds content of location X to register R)
• Address portion of IR loaded into MAR
• Reference memory location read
• Contents of R and MBR added by the ALU
F e t c h - D e c o d e - E x e c u t e C y c l e
Additional Steps in the Instructional Cycle
• Fetch operands: Separate cycle for fetching operands before the
execute cycle
• Store results: Separate cycle for storing results after the execute cycle
• Interrupt handling: Can occur during any cycle, requires immediate
attention
F e t c h - D e c o d e - E x e c u t e C y c l e
Interrupt
• A signal sent from a device or from software to the processor.
This causes the processor to temporarily stop what it is doing
and service the interrupt
F e t c h - D e c o d e - E x e c u t e C y c l e
How to Handle Interrupt During the Fetch Execute Cycle
• At the end of the fetch execute cycle, the processor checks for interrupts. The
computer is checked for an interrupt flag.
• The processor identifies the source of interrupt and then checks for priority of
interrupt. If the interrupt priority is above the current task, the processor save the
contents of the current registers and calls the interrupt handler that services the
interrupts.
• When the service is complete the content of the registers are restored, and the
processor continues with fetch execute cycle
F e t c h - D e c o d e - E x e c u t e C y c l e
F e t c h - D e c o d e - E x e c u t e C y c l e
Instruction Cycle with Interrupt
F e t c h - D e c o d e - E x e c u t e C y c l e
Assignment
Describe the stages of the Fetch-
Decode-Execute Cycle (including the
use of registers and buses), in the
program execution in the table
(memory)
ADDRESS Instruction / Data
1 LOAD 5
2 ADD 6
3 STO 7
4
5 8
6 4
7
Assignment due date: 21-06-2024
F e t c h - D e c o d e - E x e c u t e C y c l e
Practice Question
Identify and explain the
various stages involved
in the program
execution in the diagram
Unit 1 Summary
• Review of Von Neumann Architecture
• Stored Program Concept
• Fetch-Decode-Execute-Cycle
• Registers
• Buses
• Interrupts
F e t c h - D e c o d e - E x e c u t e C y c l e
Trial Questions
1. What is a stored program concept?
2. Describe the stages of the Fetch Decode Execute Cycle.
3. Name and explain the purpose of at least six registers found in the CPU.
4. Name and explain the three (3) types of buses?
5. Describe the stages of the Fetch-Decode-Execute Cycle including the use of registers
and buses
F e t c h - D e c o d e - E x e c u t e C y c l e
Trial Questions
6. What is the primary role of the Program Counter (PC) in the Fetch Decode Execute Cycle?
7. Explain the three main stages of the Fetch Decode Execute Cycle.
8. Describe how the CPU handles an interrupt during the Fetch Decode Execute Cycle.
9. What are pipeline hazards and how do they affect the Fetch Decode Execute Cycle?
10. Illustrate with an example how indirect addressing works in the Fetch Decode Execute Cycle.
11. What is the significance of the control unit in the Decode stage of the Fetch Decode Execute Cycle?
F e t c h - D e c o d e - E x e c u t e C y c l e
Next :
• Introduction to assembly language programming.
• Instruction formats and addressing modes.
• Types of instruction sets: CISC and RISC.
• Relationship between ISA and hardware implementation
F e t c h - D e c o d e - E x e c u t e C y c l e

Computer architecture lecturer powerpint presentation

  • 1.
  • 2.
    Objective  Explain theFetch Decode Execute Cycle: Illustrate Data Flow in the CPU: Identify the types of registers in the CPU Explain the process of interrupt handling and its importance. F e t c h - D e c o d e - E x e c u t e C y c l e
  • 3.
    F e tc h - D e c o d e - E x e c u t e C y c l e Stored Program Concept Historically there have been 2 types of Computers:  Fixed Program Computers – Their function is very specific and they couldn’t be reprogrammed, e.g. Calculators.  Stored Program Computers – These can be programmed to carry out many different tasks, applications are stored on them, hence the name.
  • 4.
     Program instructionsand data are both stored in Memory  Instructions are fetched and execture one after the other F e t c h - D e c o d e - E x e c u t e C y c l e
  • 5.
    Key Terms F et c h - D e c o d e - E x e c u t e C y c l e
  • 6.
    Fetch Decode ExecuteCycle: • Fundamental process of any computer's CPU • Three main parts: fetching the instruction, decoding it, and executing it • Perpetual operation in the CPU • Involves the Program Counter (PC), decoder, and Control Unit F e t c h - D e c o d e - E x e c u t e C y c l e
  • 7.
    Ba sic Inst ru c t io n C y c l e F e t c h - D e c o d e - E x e c u t e C y c l e
  • 8.
    F e tc h - D e c o d e - E x e c u t e C y c l e Stages of the Fetch-Decode-Execute Cycle  Fetch: an instruction is passed from memory to CPU  Decode: the CPU works out the meaning of the instructions  Execute: the CPU carries out the instruction NB: The cycle then repeat…
  • 9.
    F e tc h - D e c o d e - E x e c u t e C y c l e Registers found in the CPU  PC: contains the memory address of the next instruction to be fetch  MAR: contains the address of the current instruction to be fetch  MDR: contains the instruction/data after it is fetched from main memory  CIR: contains the instruction/data to be decoded  MBR: holds/stores data temporarily before using them  ACC: stores the result of any calculation carried out in the ALU
  • 10.
    F e tc h - D e c o d e - E x e c u t e C y c l e System Buses  Address bus: carries the address of the next item to be fetched, and it is one directional (from CPU to main memory)  Data bus: carries the actual data (or instruction) that has been/will be processed. It is two direction – either way between CPU and main memory  Control bus: carries control signals that direct the actions of the CPU. It can be one or two directional
  • 11.
    Simplify Schema Diagramof a Single Core CPU F e t c h - D e c o d e - E x e c u t e C y c l e
  • 12.
    Steps in theFetch Decode Execute Cycle Content: 1. The PC holds the address of the next instruction to be fetched 2. The address in the PC is copied to the MAR via address bus 3. The PC is incremented so it contains the address of the next instruction 4. The instruction at the address held in the MAR is copied into the MDR 5. The instruction in the MDR is copied into the CIR 6. The instruction is now decoded and executed F e t c h - D e c o d e - E x e c u t e C y c l e
  • 13.
    F e tc h - D e c o d e - E x e c u t e C y c l e
  • 14.
    F e tc h - D e c o d e - E x e c u t e C y c l e
  • 15.
    Fetch Cycle • CPUretrieves the instruction from memory • Instruction stored at address specified by the PC • PC incremented to point to the next instruction • Steps: • Address in PC moved to MAR • Address placed on the address bus; control unit issues READ command • Result appears on data bus, copied to MBR • Program Counter incremented by one • Content of MBR moved to CIR F e t c h - D e c o d e - E x e c u t e C y c l e
  • 16.
    Decode Cycle • CPUinterprets the instruction • Determines what operation to perform • Identifies opcode and operands F e t c h - D e c o d e - E x e c u t e C y c l e
  • 17.
    Execute Cycle • CPUperforms the operation specified by the instruction • May involve: • Reading/writing data from/to memory • Performing arithmetic/logic operations • Manipulating control flow of the program • Example: • ADD R, X (Adds content of location X to register R) • Address portion of IR loaded into MAR • Reference memory location read • Contents of R and MBR added by the ALU F e t c h - D e c o d e - E x e c u t e C y c l e
  • 18.
    Additional Steps inthe Instructional Cycle • Fetch operands: Separate cycle for fetching operands before the execute cycle • Store results: Separate cycle for storing results after the execute cycle • Interrupt handling: Can occur during any cycle, requires immediate attention F e t c h - D e c o d e - E x e c u t e C y c l e
  • 19.
    Interrupt • A signalsent from a device or from software to the processor. This causes the processor to temporarily stop what it is doing and service the interrupt F e t c h - D e c o d e - E x e c u t e C y c l e
  • 20.
    How to HandleInterrupt During the Fetch Execute Cycle • At the end of the fetch execute cycle, the processor checks for interrupts. The computer is checked for an interrupt flag. • The processor identifies the source of interrupt and then checks for priority of interrupt. If the interrupt priority is above the current task, the processor save the contents of the current registers and calls the interrupt handler that services the interrupts. • When the service is complete the content of the registers are restored, and the processor continues with fetch execute cycle F e t c h - D e c o d e - E x e c u t e C y c l e
  • 21.
    F e tc h - D e c o d e - E x e c u t e C y c l e Instruction Cycle with Interrupt
  • 22.
    F e tc h - D e c o d e - E x e c u t e C y c l e Assignment Describe the stages of the Fetch- Decode-Execute Cycle (including the use of registers and buses), in the program execution in the table (memory) ADDRESS Instruction / Data 1 LOAD 5 2 ADD 6 3 STO 7 4 5 8 6 4 7 Assignment due date: 21-06-2024
  • 23.
    F e tc h - D e c o d e - E x e c u t e C y c l e Practice Question Identify and explain the various stages involved in the program execution in the diagram
  • 24.
    Unit 1 Summary •Review of Von Neumann Architecture • Stored Program Concept • Fetch-Decode-Execute-Cycle • Registers • Buses • Interrupts F e t c h - D e c o d e - E x e c u t e C y c l e
  • 25.
    Trial Questions 1. Whatis a stored program concept? 2. Describe the stages of the Fetch Decode Execute Cycle. 3. Name and explain the purpose of at least six registers found in the CPU. 4. Name and explain the three (3) types of buses? 5. Describe the stages of the Fetch-Decode-Execute Cycle including the use of registers and buses F e t c h - D e c o d e - E x e c u t e C y c l e
  • 26.
    Trial Questions 6. Whatis the primary role of the Program Counter (PC) in the Fetch Decode Execute Cycle? 7. Explain the three main stages of the Fetch Decode Execute Cycle. 8. Describe how the CPU handles an interrupt during the Fetch Decode Execute Cycle. 9. What are pipeline hazards and how do they affect the Fetch Decode Execute Cycle? 10. Illustrate with an example how indirect addressing works in the Fetch Decode Execute Cycle. 11. What is the significance of the control unit in the Decode stage of the Fetch Decode Execute Cycle? F e t c h - D e c o d e - E x e c u t e C y c l e
  • 27.
    Next : • Introductionto assembly language programming. • Instruction formats and addressing modes. • Types of instruction sets: CISC and RISC. • Relationship between ISA and hardware implementation F e t c h - D e c o d e - E x e c u t e C y c l e

Editor's Notes

  • #1 The design of computers including their instruction sets, hardware components and system organization
  • #2 Architecture: The art and science of designing A general term to describe buildings and other physical structures. Buildings have a certain layout or design. Similarly a computer has a design Your flat has several component with each serving a particular purpose. A computer also has several unit with each having a distinct function
  • #3 The stored program concept is the idea that instructions and data are stored together in memory (in binary form) The program is fetched from memory as an instruction at a time and decoded. The concept was developed by Von Neumann. Thus, programs, instructions and data are both stored in the main memory. Instructions are fetched and executed one after the other
  • #4 A memory module consists of a set of locations, defined by sequentially numbered addresses. Each location contains a binary number that can be interpreted as either an instruction or data. The stored program concept is the idea that instructions and data are stored together in memory (in binary form) The program is fetched from memory as an instruction at a time and decoded. The concept was developed by Von Neumann. Thus, programs, instructions and data are both stored in the main memory. Instructions are fetched and executed one after the other
  • #5 ALU, CU, RAM
  • #7 The basic function performed by a computer is execution of a program, which consists of a set of instructions stored in memory. The processor does the actual work by executing instructions specified in the program. This section provides an overview of the key elements of program execution. In its simplest form, instruction processing consists of two steps: The processor reads (fetches ) instructions from memory one at a time and executes each instruction. Program execution consists of repeating the process of instruction fetch and instruction execution. The instruction execution may involve several operations and depends on the nature of the instruction. The processing required for a single instruction is called an instruction cycle. Using the simplified two-step description given previously, the instruction cycle is depicted in the figure. The two steps are referred to as the fetch cycle and the execute cycle. Program execution halts only if the machine is turned off, some sort of unrecoverable error occurs, or a program instruction that halts the computer is encountered.
  • #8 The basic function performed by a computer is execution of a program, which consists of a set of instructions stored in memory. The processor does the actual work by executing instructions specified in the program. This section provides an overview of the key elements of program execution. In its simplest form, instruction processing consists of two steps: The processor reads (fetches ) instructions from memory one at a time and executes each instruction. Program execution consists of repeating the process of instruction fetch and instruction execution. The instruction execution may involve several operations and depends on the nature of the instruction. The processing required for a single instruction is called an instruction cycle. Using the simplified two-step description given previously, the instruction cycle is depicted in the figure. The two steps are referred to as the fetch cycle and the execute cycle. Program execution halts only if the machine is turned off, some sort of unrecoverable error occurs, or a program instruction that halts the computer is encountered.
  • #9 The basic function performed by a computer is execution of a program, which consists of a set of instructions stored in memory. The processor does the actual work by executing instructions specified in the program. This section provides an overview of the key elements of program execution. In its simplest form, instruction processing consists of two steps: The processor reads (fetches ) instructions from memory one at a time and executes each instruction. Program execution consists of repeating the process of instruction fetch and instruction execution. The instruction execution may involve several operations and depends on the nature of the instruction. The processing required for a single instruction is called an instruction cycle. Using the simplified two-step description given previously, the instruction cycle is depicted in the figure. The two steps are referred to as the fetch cycle and the execute cycle. Program execution halts only if the machine is turned off, some sort of unrecoverable error occurs, or a program instruction that halts the computer is encountered.
  • #10 Bus: set of wires from one component to another The control bus coordinates everything that goes on in the CPU: sending signals to components to get them to function at the right time, tell components whether they are loading or saving, etc.
  • #11 Step 1: The address in the program counter is moved to the memory address register (MAR), as this is the only register which is connected to address lines of the system bus. Step 2: The address in MAR is placed on the address bus, now the control unit issues a READ command on the control bus, and the result appears on the data bus and is then copied into the memory buffer register (MBR). Program counter is incremented by one, to get ready for the next instruction. (These two actions can be performed simultaneously to save time) Step 3: The content of the MBR is moved to the instruction register(IR).
  • #12 The PC holds the address of the next instruction to be fetched The address in the PC is copied to the MAR via address bus The PC is incremented so it contains the address of the next instruction The instruction at the address held in the MAR is copied into the MDR The instruction in the MDR is copied into the CIR The address part of the instruction in the CIR is placed in the MAR The instruction is now decoded and executed
  • #13 The figure illustrates these top-level components and suggests the interactions among them. A memory module consists of a set of locations, defined by sequentially numbered addresses. Each location contains a binary number that can be interpreted as either an instruction or data. An I/O module transfers data from external devices to CPU and memory, and vice versa. It contains internal buffers for temporarily holding these data until they can be sent on.
  • #14 The figure illustrates these top-level components and suggests the interactions among them. A memory module consists of a set of locations, defined by sequentially numbered addresses. Each location contains a binary number that can be interpreted as either an instruction or data. An I/O module transfers data from external devices to CPU and memory, and vice versa. It contains internal buffers for temporarily holding these data until they can be sent on.
  • #15 At the beginning of each instruction cycle, the processor fetches an instruction from memory. In a typical processor, a register called the PC holds the address of the instruction to be fetched next. Unless told otherwise, the processor always increments the PC after each instruction fetch so that it will fetch the next instruction in sequence (i.e., the instruction located at the next higher memory address). So, for example, consider a computer in which each instruction occupies one 16-bit word of memory. Assume that the PC is set to memory location 300, where the location address refers to a 16-bit word. The processor will next fetch the instruction at location 300. On succeeding instruction cycles, it will fetch instructions from locations 301, 302, 303, and so on. This sequence may be altered, as explained presently. The fetched instruction is loaded into a register in the processor known as the CIR. The instruction contains bits that specify the action the processor is to take. The processor interprets the instruction and performs the required action.
  • #16 the CPU interprets the instruction and determines what operation needs to be performed. This involves identifying the opcode and any operands that are needed to execute the instruction.
  • #17 Computer architecture is the set of principles that describe how hardware and software connect to make a computer function. The main components of a computer architecture are the CPU, memory, and peripherals. All these elements are linked by the system bus, which comprises an address bus, a data bus, and a control bus
  • #18 Computer architecture is the set of principles that describe how hardware and software connect to make a computer function. The main components of a computer architecture are the CPU, memory, and peripherals. All these elements are linked by the system bus, which comprises an address bus, a data bus, and a control bus
  • #19 Computer architecture is the set of principles that describe how hardware and software connect to make a computer function. The main components of a computer architecture are the CPU, memory, and peripherals. All these elements are linked by the system bus, which comprises an address bus, a data bus, and a control bus
  • #20 Computer architecture is the set of principles that describe how hardware and software connect to make a computer function. The main components of a computer architecture are the CPU, memory, and peripherals. All these elements are linked by the system bus, which comprises an address bus, a data bus, and a control bus
  • #21 An interrupt is a signal that the CPU receives from an external device or software that requires immediate attention. When an interrupt occurs, the CPU suspends the current instruction and executes an interrupt handler to service the interrupt.