Csci 136 Computer Architecture II – Data Hazard, Forwarding, Stall

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

Pipeline Hazards CS365 Lecture 10. D. Barbara Pipeline Hazards CS465 2 Review  Pipelined CPU  Overlapped execution of multiple instructions  Each on.
ECE 445 – Computer Organization
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Pipelined Processor.
Part 2 - Data Hazards and Forwarding 3/24/04++
Review: MIPS Pipeline Data and Control Paths
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 18 - Pipelined.
Chapter Six Enhancing Performance with Pipelining
 The actual result $1 - $3 is computed in clock cycle 3, before it’s needed in cycles 4 and 5  We forward that value to later instructions, to prevent.
1 CSE SUNY New Paltz Chapter Six Enhancing Performance with Pipelining.
Computer Organization Lecture Set – 06 Chapter 6 Huei-Yung Lin.
Exp. 6 Solving Data Hazards. Where to find ALU Result Instruction memory Data memory 1010 PC ALU Registers Rd Rt 0101 IF/IDID/EXEX/MEMMEM/WB.
Lecture 28: Chapter 4 Today’s topic –Data Hazards –Forwarding 1.
Computer Architecture - A Pipelined Datapath A Pipelined Datapath  Resisters are used to save data between stages. 1/14.
1 Stalls and flushes  So far, we have discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
Pipeline Data Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
Pipelined Datapath and Control
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-2 Read Section 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State University.
Chapter 4 CSF 2009 The processor: Pipelining. Performance Issues Longest delay determines clock period – Critical path: load instruction – Instruction.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2012 Revised from original slides provided by MKP.
Basic Pipelining & MIPS Pipelining Chapter 6 [Computer Organization and Design, © 2007 Patterson (UCB) & Hennessy (Stanford), & Slides Adapted from: Mary.
Pipeline Data Hazards Warning, warning, warning! Read 4.8 Peer Instruction Lecture Materials for Computer Architecture by Dr. Leo Porter is licensed under.
CMPE 421 Parallel Computer Architecture Part 2: Hardware Solution: Forwarding.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
2/15/02CSE Data Hazzards Data Hazards in the Pipelined Implementation.
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
Computing Systems Pipelining: enhancing performance.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline.
CSIE30300 Computer Architecture Unit 05: Overcoming Data Hazards Hsin-Chou Chi [Adapted from material by and
Designing a Pipelined Processor
PROCESSOR PIPELINING YASSER MOHAMMAD. SINGLE DATAPATH DESIGN.
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-1 Read Sections 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State.
Csci 136 Computer Architecture II – Superscalar and Dynamic Pipelining Xiuzhen Cheng
LECTURE 9 Pipeline Hazards. PIPELINED DATAPATH AND CONTROL In the previous lecture, we finalized the pipelined datapath for instruction sequences which.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Lecture 9 Pipeline Hazards.
Stalling delays the entire pipeline
Note how everything goes left to right, except …
Morgan Kaufmann Publishers The Processor
Appendix C Pipeline implementation
ECS 154B Computer Architecture II Spring 2009
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
Data Hazards and Stalls
Data Hazards and Stalls
Forwarding Now, we’ll introduce some problems that data hazards can cause for our pipelined processor, and show how to handle them with forwarding.
Chapter 4 The Processor Part 3
Review: MIPS Pipeline Data and Control Paths
Morgan Kaufmann Publishers The Processor
Chapter 6 Enhancing Performance with Pipelining
Morgan Kaufmann Publishers The Processor
CSCI206 - Computer Organization & Programming
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
Computer Organization CS224
Data Hazards Data Hazard
Pipelined Control (Simplified)
The Processor Lecture 3.5: Data Hazards
CSC3050 – Computer Architecture
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Introduction to Computer Organization and Architecture
Pipelined Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Systems Architecture II
Stalls and flushes Last time, we discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
©2003 Craig Zilles (derived from slides by Howard Huang)
Need to stall for one cycle.
Presentation transcript:

Csci 136 Computer Architecture II – Data Hazard, Forwarding, Stall Xiuzhen Cheng cheng@gwu.edu

Note: you must pass final to pass this course! Announcement Homework assignment #10, Due time – Before class, April 12 Readings: Sections 6.4 – 6.5 Problems: 6.17-6.19, 6.21-6.22, 6.33-6.36, 6.39-6.40 (six of them will be graded. Your TA will give hints in the lab sections.) Project #3 is due on April 17, 2005 Final: Thursday, May 12, 12:40AM-2:40PM Note: you must pass final to pass this course!

The Big Picture: Where are We Now? The Five Classic Components of a Computer Current Topics: Datapath Control Data Hazard Hazard Detection, Data Forwarding, Stall Processor Input Control Memory Datapath Output So where are in in the overall scheme of things. Well, we just finished designing the processor’s datapath. Now I am going to show you how to design the control for the datapath. +1 = 7 min. (X:47)

Recap: The Complete Pipelined Datapath

Data Hazards The input of some instruction depends on the output of another instruction which is still in the pipeline An example: what if initially $2=-20, $1=10, $3=2?

Resolving Data Hazard Write reg in the first half of CC and read it in the second half of that CC. Insert NOP instructions, or independent instructions by compiler Detect the hazard, then forward the proper value The good way

Data Hazard Detection From the example, 1. sub $2, $1, $3 2. and $12, $2, $5 3. or $13, $6, $2 And and or needs the value of $2 at ALU stage For first two instructions, hazard happens when sub is in MEM stage, while and is in ALU stage For the first and third instructions, hazard happens when sub is in WB stage while or is in ALU stage Hazard detection conditions: EX hazard and MEM hazard 1a. EX/MEM.RegisterRd = ID/EX.RegisterRs 1b. EX/MEM.RegisterRd = ID/EX.RegisterRt 2a. MEM/WB.RegisterRd = ID/EX.RegisterRs 2b. MEM/WB.RegisterRd = ID/EX.RegisterRt

In-class Exercise Classify the dependencies in the following sequence: sub $2, $1, $3 and $12, $2, $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100($2)

Add Forwarding Paths

Refine the Hazard Detection Condition Conditions 1 and 2 are true, but the instruction in MEM stage and WB stage do not write No hazard Check RegWrite signal in the WB field of the EX/MEM and MEM/WB pipeline register Condition 1 and 2 are true, but RegisterRd is $0. For code sequence: add $1, S1, S2, add $1, $1, $3, add $1, $1, $4 The third instruction depends on the second, not the first Should forward the ALU result from the second instruction For MEM hazard, EX/MEM.RegisterRd != ID/EX.RegisterRs EX/MEM.RegisterRd != ID/EX.RegisterRt

New Hazard Detection Conditions EX hazard if ( EX/MEM.RegWrite and (EX/MEM.RegisterRd != 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs)) ForwardA = 10 if ( EX/MEM.RegWrite and (EX/MEM.RegisterRd != 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRt)) ForwardB = 10

New Hazard Detection Conditions MEM Hazard if ( MEM/WB.RegWrite and (MEM/wB.RegisterRd !=0) and (EX/MEM.RegisterRd != ID/EX.RegisterRs) and (MEM/wB.RegisterRd = ID/EX.RegisterRs)) ForwardA = 01 if ( MEM/WB.RegWrite and (MEM/wB.RegisterRd !=0) and (EX/MEM.RegisterRd != ID/EX.RegisterRt) and (MEM/wB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01

Complete Datapath with Forwarding Path

Example Show how forwarding works with the following instruction sequence sub $2, $1, $3 and $4, $2, $5 or $4, $4, $2 add $9, $4, $2

Clock 3

Clock 4

Clock 5

Clock 6

Adding ALUSrc Mux to the Datapath

Forwarding Can’t do Anything! When an instruction reading a register following by a load instruction that writes the same register, forwarding does not solve the data hazard Stall the pipeline

Stalling the pipeline – Bubble

Hazard Detection At ID stage, why? Detection logic if ( ID/EX.MemRead and ( (ID/EX.RegisterRt = IF/ID.RegisterRs) or (ID/EX.RegisterRt = IF/ID.RegisterRt) )) stall the pipeline How to stall the pipeline at ID stage? – add hazard detection unit Set all control signals to 0, inserting a bubble (NOP operation) Keep IF/ID unchanged – repeat the previous cycle Keep PC unchanged – refetch the same instruction Add PCWrite and IF/IDWrite control to to data hazard detection logic What is the difference between the hazard detection unit and data forwarding unit?

Pipelined Control with Hazard Detection and Data Forwarding Units

Example – Clock 2

Clock 3

Clock 4

Clock 5

Clock 6

Clock 7

Questions?