Computer Architecture and the Fetch-Execute Cycle

Slides:



Advertisements
Similar presentations
The CPU The Central Presentation Unit What is the CPU?
Advertisements

The Fetch – Execute Cycle
Computer Architecture and the Fetch-Execute Cycle
Central Processing Unit
The CPU. Parts of the CPU Control Unit Arithmetic & Logic Unit Registers.
Computer Systems. Computer System Components Computer Networks.
Execution of an instruction
Elements of the Computer (How a processor works)
1 Sec (2.3) Program Execution. 2 In the CPU we have CU and ALU, in CU there are two special purpose registers: 1. Instruction Register 2. Program Counter.
A-Level Computing#BristolMet Session Objectives#4 MUST describe the differences between the main types of primary memory SHOULD describe the function and.
The Computer Processor
Lecture 13 - Introduction to the Central Processing Unit (CPU)
CPU Fetch/Execute Cycle
A-Level Computing#BristolMet Session Objectives#5 MUST identify different buses and registers used in a CPU SHOULD describe the use of buses to send information.
Computer Architecture and the Fetch-Execute Cycle
Computer Architecture and the Fetch-Execute Cycle
The CPU Central Processing Unit. 2 Reminder - how it fits together processor (CPU) memory I/O devices bus.
Von Neumann Machine Objectives: Explain Von Neumann architecture:  Memory –Organization –Decoding memory addresses, MAR & MDR  ALU and Control Unit –Executing.
Chapter 8: The Very Simple Computer
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
The structure COMPUTER ARCHITECTURE – The elementary educational computer.
DH2T 34 – HNC Computer Architecture 1 Lecture 14 The Fetch-Decode-Execute Cycle [1]. © C Nyssen/Aberdeen College 2003 All images © C Nyssen/Aberdeen College.
Fetch-execute cycle.
Computer Systems - Registers. Starter… Discuss in pairs the definition of the following Control Unit Arithmetic and Logic Unit Registers Internal clock.
D75P 34 – HNC Computer Architecture
Computer Structure & Architecture 7b - CPU & Buses.
Computer Studies/ICT SS2
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Machine Instructions.
September 26, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 2: Implementation of a Simplified Computer Jeremy R. Johnson Wednesday,
COMPILERS CLASS 22/7,23/7. Introduction Compiler: A Compiler is a program that can read a program in one language (Source) and translate it into an equivalent.
Fetch-Execute Cycle Fetch the next instruction Decode Execute It.
Computer Systems Organization
Dale & Lewis Chapter 5 Computing components
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Structure and Role of a Processor
Jeremy R. Johnson William M. Mongan
CPUz 4 n00bz.
Chapter 20 Computer Operations Computer Studies Today Chapter 20.
Lec 4-2 Five operations of the machine cycle Fetch- fetch the next program instruction from memory. (PC+1); instruction to IR Decode- decode the instruction.
3.1.4 Hardware a. describe the function and purpose of the control unit, memory unit and ALU (arithmetic logic unit) as individual parts of a computer;
Stored Program Concept Learning Objectives Learn the meaning of the stored program concept The processor and its components The fetch-decode-execute and.
CPU Lesson 2.
OCR GCSE Computer Science Teaching and Learning Resources
Systems Architecture Keywords Fetch Execute Cycle
Chapter 10: Computer systems (1)
The Stored Program Computer
Lecture 13 - Introduction to the Central Processing Unit (CPU)
William Stallings Computer Organization and Architecture 8th Edition
Lesson Objectives A note about notes: Aims
Teaching Computing to GCSE
System Architecture 1 Chapter 2.
The Processor and Machine Language
Basic Computer Organization
Systems Architecture I (CS ) Lecture 2: A Simplified Computer
Computer Architecture and the Fetch-Execute Cycle
The Little Man Computer
THE FETCH-EXECUTE CYCLE.
1-2 – Central Processing Unit
GCSE OCR 1 The CPU Computer Science J276 Unit 1
THE FETCH-EXECUTE CYCLE.
A Top-Level View Of Computer Function And Interconnection
Information Representation: Machine Instructions
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
Instruction execution and ALU
Computer Architecture
COMPUTER ARCHITECTURE
Presentation transcript:

Computer Architecture and the Fetch-Execute Cycle The Fetch-Decode-Execute-Reset Cycle

Learning Objectives Describe in simple terms the fetch / decode / execute / reset cycle and the effects of the stages of the cycle on specific registers.

The Fetch-Decode-Execute-Reset Cycle The following is an algorithm in diagrammatic form that shows the steps in the cycle. It is the control unit which controls and synchronises this cycle. Loads / copies / places / passes, decodes and executes. At the end the cycle is reset and the algorithm repeated.

Key for following slides: PC / SQR Program Counter / Sequence Control Register MAR Memory Address Register MDR / MBR Memory Data Register / Memory Buffer Register CIR Current Instruction Register ACC Accumulator

Idle Registers Note that during the Fetch - Decode – Execute - Reset cycle demonstrated on the following slides, some registers are idle (not being used). This will be discussed and resolved in the next lesson.

CPU Memory PC MAR CIR MDR ACC Fetch PC incremented by 1 Copy of instruction in memory address held in MAR PC Copy of address of next instruction MAR CIR Instruction MDR Control Unit ACC ALU

CPU PC MAR CIR MDR ACC Decode Split instruction into operation code & address if present. Then decode operation code. CIR MDR Control Unit ACC ALU

CPU PC MAR Execute instruction (What is involved in this depends on the instruction being executed - demonstrated on the following slides). CIR MDR Control Unit ACC ALU

Click an instruction or move on to see each instruction in turn. Jump Input / Load (number directly) Input / Load (from memory) Add (a number directly) Add (a number from memory) Store Output (directly from accumulator) Output (from memory)

Jump instruction Execute Diagram

Copy of address part instruction Execute CPU Jump PC MAR Copy of address part instruction (address to jump to). CIR MDR Control Unit ACC ALU

Copy of address part instruction Execute CPU Jump Copy of address part instruction (address to jump to). PC MAR CIR MDR Control Unit ACC ALU Back to list of instructions

Input / Load (number directly) into accumulator instruction Execute Diagram

CPU PC MAR CIR MDR ACC Execute Input / Load (number directly) into accumulator CPU PC MAR Number inputted / to be loaded. CIR MDR Control Unit Copy of number in MDR. ACC ALU Back to list of instructions

Reason for the CIR & MDR As you can see the MDR is used to store the number inputted / to be loaded during the execution of this Input / Load instruction. Therefore, if there was no CIR to hold the Input / Load instruction and, as no register can hold more than one “thing” at a time, the control unit would “lose” the Input / Load instruction. i.e. It would no longer “know” what it was supposed to do. You will find that the contents of the MDR may be modified for similar reasons during other later instructions. Back to list of instructions

Load (from memory) instruction Execute Diagram

CPU Memory MAR PC CIR MDR ACC Execute Load (from memory) Copy of data in address held in MAR MAR PC Address part of instruction (of data to be loaded). CIR MDR Control Unit Copy of data in MDR ACC ALU Back to list of instructions

Reason for the PC & MAR As you can see the MAR is now used to store the address part of instruction during the execution of this Load (from memory) instruction. Therefore if there was no MAR the PC would be used to hold this address so the control unit would no longer know the correct address of the next instruction. You will find that the contents of the MAR may be modified for similar reasons during other later instructions. Back to list of instructions

Add (a number directly) instruction Execute Diagram Assume a number has already been inputted or loaded (directly or from memory) into the accumulator.

CPU PC MAR CIR MDR ACC Execute Add (a number directly) Number to be added. MDR Control Unit Add number in MDR to number already in accumulator. ACC ALU NB. The ALU now does the arithmetic. Accumulator value is now the result of the addition. i.e. Accumulator = Accumulator + contents of MDR Back to list of instructions

Add (a number from memory) instruction Execute Diagram (Assume a number has already been inputted or loaded into the accumulator.)

CPU Memory PC MAR CIR MDR ACC Execute Add (from memory) Control Unit Control Unit Copy of number in memory address held in MAR PC MAR CIR Address part of instruction (of number to add). MDR Add number in MDR to number already in accumulator. ACC ALU NB. The ALU now does the arithmetic. Accumulator value is now the result of the addition. i.e. Accumulator = Accumulator + contents of MDR Back to list of instructions

Store instruction Execute Diagram Assume data has either been inputted, loaded (directly or from memory) or a calculation has been performed. Any of the above will mean there is data in the accumulator and it is this data that will be stored.

CPU Memory PC MAR CIR MDR ACC Execute Store Control Unit Copy of data in MDR stored in memory address held in MAR PC MAR CIR Address part of instruction (to store in). MDR Copy of data in accumulator ACC ALU Back to list of instructions

Output (directly from accumulator) instruction Execute Diagram

Output data in accumulator Execute Output (directly from accumulator) CPU PC MAR CIR Output data in accumulator MDR Control Unit ACC ALU Back to list of instructions

Output (from memory) instruction Execute Diagram

CPU Memory MAR PC CIR MDR ACC Execute Output (from memory) Control Unit Copy of data in memory address held in MAR MAR PC Address part of instruction (of data to output). CIR MDR Output data in accumulator Copy of data in memory address held in MAR ACC ALU Back to list of instructions

Cycle is reset (restarted) by passing control back to the PC. CPU PC Cycle is reset (restarted) by passing control back to the PC.

The CIR changes: When an instruction is loaded into it from the MDR. When the address in the instruction in the CIR is modified by the addition of the contents of an Index register (IR): A previously unmentioned register which is covered in more detail in the next Special Registers and Memory Addressing Techniques Presentation.

Idle Registers Note that during the Fetch - Decode – Execute - Reset cycle demonstrated on the previous slides, some registers were idle (not being used). This will be discussed and resolved in the next lesson.

Fetch – Decode - Execute – Reset Cycle in writing The following slides describe the cycle in writing.

Load the address of next instruction in the PC into the MAR. So that the control unit can fetch the instruction from the right part of the memory. Increment the PC by 1. So that it contains the address of the next instruction, assuming that the instructions are in consecutive locations. Copy the instruction/data that is in the memory address given by the MAR into the MDR. MDR is used whenever anything is to go from the CPU to main memory, or vice versa. Load the instruction/data that is now in the MDR into the CIR. Thus the next instruction is copied from memory -> MDR -> CIR. Contents of CIR split into operation code and address if present e.g. store, add or jump instructions. Decode the instruction that is in the CIR. Fetch Decode

If the instruction is a jump instruction then Execute the instruction but what is involved in this depends on the instruction being executed (there are several different instructions you need to know about). If the instruction is a jump instruction then Load the address part of the instruction in the CIR into the PC. If the instruction is an input / load (directly) instruction then take data input and place in accumulator. If the instruction is a load (from memory) instruction. Copy address part of the instruction (to load from) in the CIR into MAR. Copy data from memory address held in MAR to MDR. Copy data in MDR into accumulator. Execute

If the instruction is a store instruction then: Copy address part of the instruction (to store in) in the CIR into MAR. Copy data in accumulator to MDR. Copy data in MDR into memory address held in MAR. If the instruction is an add instruction then: Copy address part of the instruction (of number to add) in the CIR into MAR. Copy number from memory address held in MAR into MDR. Add number in MDR to number in accumulator (accumulator will now hold the result). If the instruction is an output (directly from accumulator) then output number in accumulator. Execute

If the instruction is an output (from memory) instruction then: Copy address part of part of the instruction (of data to output) in CIR into MAR. Output contents of MDR. Cycle is reset (restarted) by passing control back to the PC (step 1). Execute Reset

Plenary Describe the fetch / decode part of the fetch / decode / execute / reset cycle, explaining the purpose of any special registers that you have mentioned.

Plenary Contents of PC loaded into MAR PC is incremented Contents of address stored in MAR loaded into MDR Contents of MDR loaded into CIR Instruction in CIR is decoded. PC (program counter) stores the address of the next instruction to be executed. MAR (memory address register) holds the address in memory that is currently being used MDR (memory data register) holds the data (or instruction) that is being stored in the address accessed by the MAR. CIR (current instruction register) holds the instruction which is currently being executed.