Multicycle Approach Break up the instructions into steps

Slides:



Advertisements
Similar presentations
1 Datapath and Control (Multicycle datapath) CDA 3101 Discussion Section 11.
Advertisements

CIS 314 Fall 2005 MIPS Datapath (Single Cycle and Multi-Cycle)
Multicycle Datapath & Control Andreas Klappenecker CPSC321 Computer Architecture.
1  1998 Morgan Kaufmann Publishers We will be reusing functional units –ALU used to compute address and to increment PC –Memory used for instruction and.
Microprocessor Design Multi-cycle Datapath Nia S. Bradley Vijay.
1 Chapter Five The Processor: Datapath and Control.
CS-447– Computer Architecture Lecture 12 Multiple Cycle Datapath
The Processor Data Path & Control Chapter 5 Part 2 - Multi-Clock Cycle Design N. Guydosh 2/29/04.
CSE378 Multicycle impl,.1 Drawbacks of single cycle implementation All instructions take the same time although –some instructions are longer than others;
1 5.5 A Multicycle Implementation A single memory unit is used for both instructions and data. There is a single ALU, rather than an ALU and two adders.
Fall 2007 MIPS Datapath (Single Cycle and Multi-Cycle)
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
10/18/2005Comp 120 Fall October Questions? Instruction Execution.
331 W10.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 10 Building a Multi-Cycle Datapath [Adapted from Dave Patterson’s.
CPU Architecture Why not single cycle? Why not single cycle? Hardware complexity Hardware complexity Why not pipelined? Why not pipelined? Time constraints.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Multi-Cycle Processor.
The Multicycle Processor CPSC 321 Andreas Klappenecker.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
CMPE 421 Advanced Computer Architecture Supplementary material for Pipelining PART1.
Datapath and Control: MultiCycle Implementation. Performance of Single Cycle Machines °Assume following operation times: Memory units : 200 ps ALU and.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
1 CS/COE0447 Computer Organization & Assembly Language Multi-Cycle Execution.
C HAPTER 5 T HE PROCESSOR : D ATAPATH AND C ONTROL M ULTICYCLE D ESIGN.
1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.
LECTURE 6 Multi-Cycle Datapath and Control. SINGLE-CYCLE IMPLEMENTATION As we’ve seen, single-cycle implementation, although easy to implement, could.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Multicycle datapath.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 3.
Design a MIPS Processor (II)

Multi-Cycle Datapath and Control
Chapter 5: A Multi-Cycle CPU.
CS161 – Design and Architecture of Computer Systems
Control & Execution Finite State Machines for Control MIPS Execution.
IT 251 Computer Organization and Architecture
Systems Architecture I
Five Execution Steps Instruction Fetch
MIPS Instructions.
Single Cycle Processor
D.4 Finite State Diagram for the Multi-cycle processor
Multi-Cycle CPU.
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
Control & Execution Finite State Machines for Control MIPS Execution.
CS/COE0447 Computer Organization & Assembly Language
Chapter Five The Processor: Datapath and Control
The Multicycle Implementation
CS/COE0447 Computer Organization & Assembly Language
Chapter Five The Processor: Datapath and Control
Drawbacks of single cycle implementation
The Multicycle Implementation
Systems Architecture I
Vishwani D. Agrawal James J. Danaher Professor
Multicycle Approach We will be reusing functional units
Yu-Lun Kuo Computer Sciences and Information Engineering
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Processor: Multi-Cycle Datapath & Control
Multicycle Design.
Lecture 17: Multi Cycle MIPS Processor
CS/COE0447 Computer Organization & Assembly Language
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
5.5 A Multicycle Implementation
Processor Design Datapath and Design.
Drawbacks of single cycle implementation
Drawbacks of single cycle implementation
Systems Architecture I
CS161 – Design and Architecture of Computer Systems
Presentation transcript:

Multicycle Approach Break up the instructions into steps each step takes one clock cycle balance the amount of work to be done in each step/cycle so that they are about equal restrict each cycle to use at most once each major functional unit so that such units do not have to be replicated functional units can be shared between different cycles within one instruction Between steps/cycles At the end of one cycle store data to be used in later cycles of the same instruction need to introduce additional internal (programmer-invisible) registers for this purpose Data to be used in later instructions are stored in programmer-visible state elements: the register file, PC, memory

Multicycle Approach Note particularities of multicyle vs. single- diagrams single memory for data and instructions single ALU, no extra adders extra registers to hold data between clock cycles Single-cycle datapath Multicycle datapath (high-level view)

Multicycle Datapath Basic multicycle MIPS datapath handles R-type instructions and load/stores: new internal register in red ovals, new multiplexors in blue ovals

Breaking instructions into steps Our goal is to break up the instructions into steps so that each step takes one clock cycle the amount of work to be done in each step/cycle is about equal each cycle uses at most once each major functional unit so that such units do not have to be replicated functional units can be shared between different cycles within one instruction Data at end of one cycle to be used in next must be stored !!

Breaking instructions into steps We break instructions into the following potential execution steps – not all instructions require all the steps – each step takes one clock cycle Instruction fetch and PC increment (IF) Instruction decode and register fetch (ID) Execution, memory address computation, or branch completion (EX) Memory access or R-type instruction completion (MEM) Memory read completion (WB) Each MIPS instruction takes from 3 – 5 cycles (steps)

Step 1: Instruction Fetch & PC Increment (IF) Use PC to get instruction and put it in the instruction register. Increment the PC by 4 and put the result back in the PC. Can be described succinctly using RTL (Register-Transfer Language): IR = Memory[PC]; PC = PC + 4; IR = Instruction Register

Step 2: Instruction Decode and Register Fetch (ID) Read registers rs and rt in case we need them. Compute the branch address in case the instruction is a branch. RTL: A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC + (sign-extend(IR[15-0]) << 2);

Step 3: Execution, Address Computation or Branch Completion (EX) ALU performs one of four functions depending on instruction type memory reference: ALUOut = A + sign-extend(IR[15-0]); R-type: ALUOut = A op B; branch (instruction completes): if (A==B) PC = ALUOut; jump (instruction completes): PC = PC[31-28] || (IR(25-0) << 2)

Step 4: Memory access or R-type Instruction Completion (MEM) Again depending on instruction type: Loads and stores access memory load MDR = Memory[ALUOut]; store (instruction completes) Memory[ALUOut] = B; R-type (instructions completes) Reg[IR[15-11]] = ALUOut; MDR = Memory Data Register

Step 5: Memory Read Completion (WB) Again depending on instruction type: Load writes back (instruction completes) Reg[IR[20-16]]= MDR; Important: There is no reason from a datapath (or control) point of view that Step 5 cannot be eliminated by performing Reg[IR[20-16]]= Memory[ALUOut]; for loads in Step 4. This would eliminate the MDR as well. The reason this is not done is that, to keep steps balanced in length, the design restriction is to allow each step to contain at most one ALU operation, or one register access, or one memory access.

Summary of Instruction Execution Step 1: IF 2: ID 3: EX 4: MEM 5: WB

Multicycle Execution Step (1): Instruction Fetch IR = Memory[PC]; PC = PC + 4; IR = Instruction Register MDR = Memory Data Register 4 PC + 4 Must be MUX

Multicycle Execution Step (2): Instruction Decode & Register Fetch A = Reg[IR[25-21]]; (A = Reg[rs]) B = Reg[IR[20-15]]; (B = Reg[rt]) ALUOut = (PC + sign-extend(IR[15-0]) << 2) * PC + 4 Branch Target Address Reg[rs] Reg[rt] *

Multicycle Execution Step (3): Memory Reference Instructions ALUOut = A + sign-extend(IR[15-0]); Reg[rs] Reg[rt] PC + 4 Mem. Address

Multicycle Execution Step (3): ALU Instruction (R-Type) ALUOut = A op B Reg[rs] Reg[rt] PC + 4 R-Type Result

Multicycle Execution Step (3): Branch Instructions if (A == B) PC = ALUOut; Reg[rs] Reg[rt] Branch Target Address Branch Target Address

Multicycle Execution Step (3): Jump Instruction PC = PC[31-28] concat (IR[25-0] << 2) Reg[rs] Reg[rt] Branch Target Address Jump Address

Multicycle Execution Step (4): Memory Access - Read (lw) MDR = Memory[ALUOut]; PC + 4 Reg[rs] Reg[rt] Mem. Address Mem. Data

Multicycle Execution Step (4): Memory Access - Write (sw) Memory[ALUOut] = B; PC + 4 Reg[rs] Reg[rt]

Multicycle Execution Step (4): ALU Instruction (R-Type) Reg[IR[15:11]] = ALUOUT R-Type Result Reg[rs] Reg[rt] PC + 4

Multicycle Execution Step (5): Memory Read Completion (lw) Reg[IR[20-16]] = MDR; PC + 4 Reg[rs] Reg[rt] Mem. Data Address

Multicycle Datapath with Control I … with control lines and the ALU control block added – not all control lines are shown

Multicycle Datapath with Control II New gates For the jump address New multiplexor Complete multicycle MIPS datapath (with branch and jump capability) and showing the main control block and all control lines

Multicycle Control Step (1): Fetch IR = Memory[PC]; PC = PC + 4; 1 1 X 010 X 1 1

Multicycle Control Step (2): Instruction Decode & Register Fetch A = Reg[IR[25-21]]; (A = Reg[rs]) B = Reg[IR[20-15]]; (B = Reg[rt]) ALUOut = (PC + sign-extend(IR[15-0]) << 2); X X 010 X X 3

Multicycle Control Step (3): Memory Reference Instructions ALUOut = A + sign-extend(IR[15-0]); X 1 X 010 X X 2

Multicycle Control Step (3): ALU Instruction (R-Type) ALUOut = A op B; X 1 X ??? X X

Multicycle Control Step (3): Branch Instructions if (A == B) PC = ALUOut; 1 if Zero=1 X 1 X 011 1 X

Multicycle Execution Step (3): Jump Instruction PC = PC[21-28] concat (IR[25-0] << 2); 1 X X X XXX 2 X X

Multicycle Control Step (4): Memory Access - Read (lw) MDR = Memory[ALUOut]; 1 X X XXX X X 1 X

Multicycle Execution Steps (4) Memory Access - Write (sw) Memory[ALUOut] = B; 1 X 1 X XXX X X X

Multicycle Control Step (4): ALU Instruction (R-Type) Reg[IR[15:11]] = ALUOut; (Reg[Rd] = ALUOut) IRWrite I Instruction I jmpaddr 28 32 R <<2 CONCAT 5 I[25:0] PCWr* rs rt rd X 1 2 M U X MUX 1 X 32 RegDst IorD 5 5 1 XXX 5 ALUSrcA PC Operation M U X 1 MemWrite RN1 RN2 WN M U X 1 3 ADDR M M U X 1 Registers PCSource Memory D RD1 A Zero X RD R WD ALU ALU WD RD2 B M U X 1 2 3 OUT MemRead MemtoReg 4 1 RegWrite 1 E X T N D ALUSrcB immediate 16 32 <<2 X

Multicycle Execution Steps (5) Memory Read Completion (lw) Reg[IR[20-16]] = MDR; IRWrite I Instruction I 28 32 R jmpaddr 5 I[25:0] <<2 CONCAT PCWr* X rs rt rd X 1 2 M U X MUX 1 32 RegDst 5 5 XXX IorD 5 ALUSrcA PC Operation M U X 1 MemWrite RN1 RN2 WN M U X 1 3 ADDR M M U X 1 Registers PCSource Zero X Memory D RD1 A RD R WD ALU ALU OUT WD RD2 B M U X 1 2 3 MemRead MemtoReg 4 RegWrite 1 E X T N D ALUSrcB immediate 16 32 X <<2