Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

Chapter 4 The Processor. Chapter 4 — The Processor — 2 The Main Control Unit Control signals derived from instruction 0rsrtrdshamtfunct 31:265:025:2120:1615:1110:6.
CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Pipelining and Control Hazards Oct
Lecture Objectives: 1)Define branch prediction. 2)Draw a state machine for a 2 bit branch prediction scheme 3)Explain the impact on the compiler of branch.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Lecture Objectives: 1)Define pipelining 2)Calculate the speedup achieved by pipelining for a given number of instructions. 3)Define how pipelining improves.
The Pipelined CPU Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Revised 9/22/2013.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University Revised from original.
Pipeline Hazards Pipeline hazards These are situations that inhibit that the next instruction can be processed in the next stage of the pipeline. This.
ECE 445 – Computer Organization
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Pipelined Processor.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania Computer Organization Pipelined Processor Design 1.
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
1 Stalling  The easiest solution is to stall the pipeline  We could delay the AND instruction by introducing a one-cycle delay into the pipeline, sometimes.
Goal: Reduce the Penalty of Control Hazards
 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.
COMP381 by M. Hamdi 1 (Recap) Control Hazards. COMP381 by M. Hamdi 2 Control (Branch) Hazard A: beqz r2, label B: label: P: Problem: The outcome.
Computer Organization Lecture Set – 06 Chapter 6 Huei-Yung Lin.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 17 - Pipelined.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 8: MIPS Pipelined.
Chapter 4 CSF 2009 The processor: Pipelining. Performance Issues Longest delay determines clock period – Critical path: load instruction – Instruction.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
11/13/2015 8:57 AM 1 of 86 Pipelining Chapter 6. 11/13/2015 8:57 AM 2 of 86 Overview of Pipelining Pipelining is an implementation technique in which.
ECE 445 – Computer Organization
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Pipelining Basics.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS 1104 Help Session IV Five Issues in Pipelining Colin Tan, S
Chapter 6 Pipelined CPU Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides Pipelined operation – laundry analogy Text Fig. 6.1.
Winter 2002CSE Topic Branch Hazards in the Pipelined Processor.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
Branch Hazards and Static Branch Prediction Techniques
1/24/ :00 PM 1 of 86 Pipelining Chapter 6. 1/24/ :00 PM 2 of 86 Overview of Pipelining Pipelining is an implementation technique in which.
Pipelining Example Laundry Example: Three Stages
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
CMPE 421 Parallel Computer Architecture Part 3: Hardware Solution: Control Hazard and Prediction.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
PROCESSOR PIPELINING YASSER MOHAMMAD. SINGLE DATAPATH DESIGN.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
Computer Organization CS224
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers The Processor
Instructor: Justin Hsia
Single Clock Datapath With Control
Pipeline Implementation (4.6)
Morgan Kaufmann Publishers The Processor
Chapter 4 The Processor Part 4
ECS 154B Computer Architecture II Spring 2009
Morgan Kaufmann Publishers The Processor
ECE 445 – Computer Organization
Chapter 4 The Processor Part 3
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
The processor: Pipelining and Branching
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
The Processor Lecture 3.6: Control Hazards
Control unit extension for data hazards
CS203 – Advanced Computer Architecture
CSC3050 – Computer Architecture
Pipelining (II).
Control unit extension for data hazards
Wackiness Algorithm A: Algorithm B:
Control unit extension for data hazards
Systems Architecture II
Presentation transcript:

Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization and Design, 4 th Edition, by Patterson and Hennessey, and were used with permission from Morgan Kaufmann Publishers.

Fall 2010ECE Computer Organization2 Material to be covered... Chapter 4: Sections 5 – 9, 13 – 14

Fall 2010ECE Computer Organization3 Hazards Situations that prevent starting the next instruction in the next cycle Structure hazards  A required resource is busy Data hazard  Need to wait for previous instruction to complete its data read/write Control hazard  Deciding on control action depends on previous instruction

Fall 2010ECE Computer Organization4 Control Hazards What happens when a branch statement is encountered? Branch determines flow of control  Fetching next instruction depends on branch outcome  Pipeline can’t always fetch correct instruction Still working on ID stage of branch In MIPS pipeline  Need to compare registers and compute target early in the pipeline  Add hardware to do it in ID stage

Fall 2010ECE Computer Organization5 Stall on Branch Wait until branch outcome determined before fetching next instruction

Fall 2010ECE Computer Organization6 Branch Prediction Longer pipelines can’t readily determine branch outcome early  Stall penalty becomes unacceptable Predict outcome of branch  Only stall if prediction is wrong In MIPS pipeline  Can predict branches not taken  Fetch instruction after branch, with no delay

Fall 2010ECE Computer Organization7 MIPS with Predict Not Taken Prediction correct Prediction incorrect

Fall 2010ECE Computer Organization8 More-Realistic Branch Prediction Static branch prediction  Based on typical branch behavior  Example: loop and if-statement branches Predict backward branches taken Predict forward branches not taken Dynamic branch prediction  Hardware measures actual branch behavior e.g., record recent history of each branch  Assume future behavior will continue the trend When wrong, stall while re-fetching, and update history

Fall 2010ECE Computer Organization9 Branch Hazards If branch outcome determined in MEM §4.8 Control Hazards PC Flush these instructions (Set control values to 0) Is this correct?

Fall 2010ECE Computer Organization10 Reducing Branch Delay Move hardware to determine outcome to ID stage  Target address adder  Register comparator Example: branch taken 36: sub $10, $4, $8 40: beq $1, $3, 7 44: and $12, $2, $5 48: or $13, $2, $6 52: add $14, $4, $2 56: slt $15, $6, $ : lw $4, 50($7)

Fall 2010ECE Computer Organization11 Example: Branch Taken

Fall 2010ECE Computer Organization12 Example: Branch Taken

Fall 2010ECE Computer Organization13 Data Hazards for Branches If a comparison register is a destination of 2 nd or 3 rd preceding ALU instruction … IFIDEXMEMWB IFIDEXMEMWB IFIDEXMEMWB IFIDEXMEMWB add $4, $5, $6 add $1, $2, $3 beq $1, $4, target Can resolve using forwarding

Fall 2010ECE Computer Organization14 Data Hazards for Branches If a comparison register is a destination of preceding ALU instruction or 2 nd preceding load instruction  Need 1 stall cycle beq stalled IFIDEXMEMWB IFIDEXMEMWB IFID EXMEMWB add $4, $5, $6 lw $1, addr beq $1, $4, target

Fall 2010ECE Computer Organization15 Data Hazards for Branches If a comparison register is a destination of immediately preceding load instruction  Need 2 stall cycles beq stalled IFIDEXMEMWB IFID EXMEMWB beq stalled lw $1, addr beq $1, $0, target

Fall 2010ECE Computer Organization16 Dynamic Branch Prediction In deeper and superscalar pipelines, branch penalty is more significant Use dynamic prediction  Branch prediction buffer (aka. branch history table)  Indexed by recent branch instruction addresses  Stores outcome (taken/not taken)  To execute a branch Check table, expect the same outcome Start fetching from fall-through or target If wrong, flush pipeline and flip prediction

Fall 2010ECE Computer Organization17 1-Bit Predictor Use a single bit to indicate whether a branch should be taken or should not be taken. Flip the bit if prediction was incorrect.

Fall 2010ECE Computer Organization18 1-Bit Predictor: Shortcoming Inner loop branches mispredicted twice! outer: … … inner: … … beq …, …, inner … beq …, …, outer Mispredict as “taken” on last iteration of inner loop Then mispredict as “not taken” on first iteration of inner loop next time around

Fall 2010ECE Computer Organization19 2-Bit Predictor Only change prediction on two successive mispredictions

Fall 2010ECE Computer Organization20 Calculating the Branch Target Even with predictor, still need to calculate the target address  1-cycle penalty for a taken branch Branch target buffer  Cache of target addresses  Indexed by PC when instruction fetched If hit and instruction is branch predicted taken, can fetch target address immediately

Fall 2010ECE Computer Organization21 Questions?