CSIE30300 Computer Architecture Unit 06: Containing Control Hazards

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

Pipelining and Control Hazards Oct
Pipeline Control Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
Review: MIPS Pipeline Data and Control Paths
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
John Lazzaro (
CS 152 L12 RAW Hazards, Interrrupts (1)Fall 2004 © UC Regents CS152 – Computer Architecture and Engineering Lecture 12 – Pipeline Wrap up: Control Hazards,
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.
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
Chapter 6 Pipelining to Increase Effective Computer Speed.
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.
Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
Control Hazards.1 Review: Datapath with Data Hazard Control Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register.
ENGS 116 Lecture 51 Pipelining and Hazards Vincent H. Berk September 30, 2005 Reading for today: Chapter A.1 – A.3, article: Patterson&Ditzel Reading for.
Chapter 4B: The Processor, Part B. Review: Why Pipeline? For Performance! I n s t r. O r d e r Time (clock cycles) Inst 0 Inst 1 Inst 2 Inst 4 Inst 3.
Pipelining. 10/19/ Outline 5 stage pipelining Structural and Data Hazards Forwarding Branch Schemes Exceptions and Interrupts Conclusion.
Pipeline Data Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
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.
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.
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CS.305 Computer Architecture Enhancing Performance with Pipelining Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
CMPE 421 Parallel Computer Architecture
1 Designing a Pipelined Processor In this Chapter, we will study 1. Pipelined datapath 2. Pipelined control 3. Data Hazards 4. Forwarding 5. Branch Hazards.
Computer Architecture and Design – ELEN 350 Part 8 [Some slides adapted from M. Irwin, D. Paterson. D. Garcia and others]
CMPE 421 Parallel Computer Architecture Part 2: Hardware Solution: Forwarding.
CECS 440 Pipelining.1(c) 2014 – R. W. Allison [slides adapted from D. Patterson slides with additional credits to M.J. Irwin]
CSIE30300 Computer Architecture Unit 04: Basic MIPS Pipelining Hsin-Chou Chi [Adapted from material by and
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
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.
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
CSE431 L06 Basic MIPS Pipelining.1Irwin, PSU, 2005 MIPS Pipeline Datapath Modifications  What do we need to add/modify in our MIPS datapath? l State registers.
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.
Designing a Pipelined Processor
EI209 Chapter 4D.1Haojin Zhu, CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 4D: Pipeline Hazard [Adapted from Computer Organization and Design,
ECE/CS 552: Pipeline Hazards © Prof. Mikko Lipasti Lecture notes based in part on slides created by Mark Hill, David Wood, Guri Sohi, John Shen and Jim.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Exceptions Another form of control hazard Could be caused by…
Computer Organization CS224
Stalling delays the entire pipeline
Mary Jane Irwin ( ) [Adapted from Computer Organization and Design,
Lecture 08: Control Hazards
Appendix C Pipeline implementation
Morgan Kaufmann Publishers The Processor
Chapter 4 The Processor Part 4
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
Processor Design: Pipeline Handling Hazards
Pipelining: Advanced ILP
Chapter 4 The Processor Part 3
Review: MIPS Pipeline Data and Control Paths
Peng Liu Lecture 9 Pipeline Peng Liu
Morgan Kaufmann Publishers The Processor
EI 209 Computer Organization Fall 2017
Pipelining review.
The processor: Pipelining and Branching
The Processor Lecture 3.6: Control Hazards
Control unit extension for data hazards
The Processor Lecture 3.5: Data Hazards
CSC3050 – Computer Architecture
Pipelining (II).
Control unit extension for data hazards
Control unit extension for data hazards
ELEC / Computer Architecture and Design Spring 2015 Pipeline Control and Performance (Chapter 6) Vishwani D. Agrawal James J. Danaher.
Presentation transcript:

CSIE30300 Computer Architecture Unit 06: Containing Control Hazards Hsin-Chou Chi [Adapted from material by Patterson@UCB and Irwin@PSU] Other handouts To handout next time

Review: Datapath with Data Hazard Control PCSrc ID/EX.MemRead Hazard Unit ID/EX IF/ID.Write ID/EX.RegisterRt EX/MEM PC.Write IF/ID 1 Control Add MEM/WB Branch Add 4 Shift left 2 Instruction Memory Read Addr 1 Data Memory Register File Read Data 1 Read Addr 2 Read Address PC Read Data Address Write Addr ALU Read Data 2 Write Data Write Data ALU cntrl 16 32 Sign Extend Forward Unit

Control Hazards When the flow of instruction addresses is not sequential (i.e., PC = PC + 4); incurred by change of flow instructions Conditional branches (beq, bne) Unconditional branches (j, jal, jr) Exceptions Possible approaches Stall (impacts CPI) Move decision point as early in the pipeline as possible, thereby reducing the number of stall cycles Delay decision (requires compiler support) Predict and hope for the best ! Control hazards occur less frequently than data hazards, but there is nothing as effective against control hazards as forwarding is for data hazards

Datapath Branch and Jump Hardware ID/EX EX/MEM IF/ID Control Add MEM/WB 4 Instruction Memory Read Addr 1 Data Memory Register File Read Data 1 Read Addr 2 Read Address PC Read Data Address Write Addr ALU Read Data 2 Write Data Write Data ALU cntrl 16 32 For class handout Sign Extend Forward Unit

Datapath Branch and Jump Hardware Shift left 2 Jump PC+4[31-28] Branch PCSrc Shift left 2 Add ID/EX EX/MEM IF/ID Control Add MEM/WB 4 Instruction Memory Read Addr 1 Data Memory Register File Read Data 1 Read Addr 2 Read Address PC Read Data Address Write Addr ALU Read Data 2 Write Data Write Data ALU cntrl 16 32 For lecture Sign Extend Forward Unit

Jumps Incur One Stall Jumps not decoded until ID, so one flush is needed ALU IM Reg DM Fix jump hazard by waiting – stall – but affects CPI j I n s t r. O r d e flush ALU IM Reg DM j target Fortunately, jumps are very infrequent – less that 2% of the SPECint instructions and x% of the SPECfp ones. Fortunately, jumps are very infrequent – only 3% of the SPECint instruction mix

Supporting ID Stage Jumps ID/EX Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Data 1 Data 2 16 32 ALU Data IF/ID Sign Extend EX/MEM MEM/WB Control cntrl Forward Unit Branch PCSrc Shift left 2 Jump PC+4[31-28] For lecture

Two “Types” of Stalls Noop instruction (or bubble) inserted between two instructions in the pipeline (as done for load-use situations) Keep the instructions earlier in the pipeline (later in the code) from progressing down the pipeline for a cycle (“bounce” them in place with write control signals) Insert noop by zeroing control bits in the pipeline register at the appropriate stage Let the instructions later in the pipeline (earlier in the code) progress normally down the pipeline Flushes (or instruction squashing) were an instruction in the pipeline is replaced with a noop instruction (as done for instructions located sequentially after j instructions) Zero the control bits for the instruction to be flushed

Review: Branches Incur Three Stalls ALU IM Reg DM beq I n s t r. O r d e Fix branch hazard by waiting – stall – but affects CPI flush flush flush beq target ALU IM Reg DM Another “solution” is to put in enough extra hardware so that we can test registers, calculate the branch address, and update the PC during the second stage of the pipeline. That would reduce the number of stalls to only one. A third approach is to prediction to handle branches, e.g., always predict that branches will be untaken. When right, the pipeline proceeds at full speed. When wrong, have to stall (and make sure nothing completes – changes machine state – that shouldn’t have). Will talk about these options in more detail in next,next lecture.

Moving Branch Decisions Earlier in Pipe Move the branch decision hardware back to the EX stage Reduces the number of stall (flush) cycles to two Adds an and gate and a 2x1 mux to the EX timing path Add hardware to compute the branch target address and evaluate the branch decision to the ID stage Reduces the number of stall (flush) cycles to one (like with jumps) But now need to add forwarding hardware in ID stage Computing branch target address can be done in parallel with RegFile read (done for all instructions – only used when needed) Comparing the registers can’t be done until after RegFile read, so comparing and updating the PC adds a mux, a comparator, and an and gate to the ID timing path For deeper pipelines, branch decision points can be even later in the pipeline, incurring more stalls Want a small branch penalty. Need more forwarding and hazard detection hardware for second option (one stall implementation) since a branch depended on a result still in the pipeline (that is one of the source operands for the comparison logic) must be forwarded from the EX/MEM or MEM/WB pipeline latches.

ID Branch Forwarding Issues MEM/WB “forwarding” is taken care of by the normal RegFile write before read operation WB add3 $1, MEM add2 $3, EX add1 $4, ID beq $1,$2,Loop IF next_seq_instr Need to forward from the EX/MEM pipeline stage to the ID comparison hardware for cases like WB add3 $3, MEM add2 $1, EX add1 $4, ID beq $1,$2,Loop IF next_seq_instr Forwards the result from the second previous instr. to either input of the compare

ID Branch Forwarding Issues, con’t If the instruction immediately before the branch produces one of the branch source operands, then a stall needs to be inserted (between the beq and add1) since the EX stage ALU operation is occurring at the same time as the ID stage branch compare operation WB add3 $3, MEM add2 $4, EX add1 $1, ID beq $1,$2,Loop IF next_seq_instr If the branch is found to be taken, then flush the instruction currently in IF

Supporting ID Stage Branches PCSrc Hazard Unit ID/EX IF.Flush 1 EX/MEM IF/ID Control Add MEM/WB 4 Shift left 2 Add Compare Read Addr 1 Instruction Memory Data Memory RegFile Read Addr 2 Read Address PC Read Data 1 Read Data Write Addr ALU Address ReadData 2 Write Data Write Data ALU cntrl 16 Sign Extend Now IF.Flush is generated by the Hazard Unit for both jumps and for taken branches. Book claims that you have to forward from the MEM/WB pipeline latch, but with RegFile write before read, I don’t think that is the case!! 32 Forward Unit Forward Unit

Delayed Decision If the branch hardware has been moved to the ID stage, then we can eliminate all branch stalls with delayed branches which are defined as always executing the next sequential instruction after the branch instruction – the branch takes effect after that next instruction MIPS compiler moves an instruction to immediately after the branch that is not affected by the branch (a safe instruction) thereby hiding the branch delay With deeper pipelines, the branch delay grows requiring more than one delay slot Delayed branches have lost popularity compared to more expensive but more flexible (dynamic) hardware branch prediction Growth in available transistors has made hardware branch prediction relatively cheaper No processor uses delayed branches of more than 1 cycl. For longer branch delays, hardware-base branch prediction is used.

Scheduling Branch Delay Slots add $1,$2,$3 if $2=0 then delay slot becomes if $2=0 then add $1,$2,$3 Limitations on delayed-branch scheduling come from 1) restrictions on the instructions that can be moved/copied into the delay slot and 2) limited ability to predict at compile time whether a branch is likely to be taken or not. In B and C, the use of $1 prevents the add instruction from being moved to the delay slot In B the sub may need to be copied because it could be reached by another path. B is preferred when the branch is taken with high probability (such as loop branches Move the instruction before branch to delay slot Delay slot is filled and IC is reduced

Static Branch Prediction Resolve branch hazards by assuming a given outcome and proceeding without waiting to see the actual branch outcome Predict not taken – always predict branches will not be taken, continue to fetch from the sequential instruction stream, only when branch is taken does the pipeline stall If taken, flush instructions after the branch (earlier in the pipeline) in IF, ID, and EX stages if branch logic in MEM – three stalls In IF and ID stages if branch logic in EX – two stalls in IF stage if branch logic in ID – one stall ensure that those flushed instructions haven’t changed the machine state – automatic in the MIPS pipeline since machine state changing operations are at the tail end of the pipeline (MemWrite (in MEM) or RegWrite (in WB)) restart the pipeline at the branch destination This is a static scheme since the same decision is always made (not taken or taken). This is just what we have already illustrated!

Flushing with Misprediction (Not Taken) ALU IM Reg DM I n s t r. O r d e 4 beq $1,$2,2 ALU IM Reg DM 8 sub $4,$1,$5 For class handout To flush the IF stage instruction, assert IF.Flush to zero the instruction field of the IF/ID pipeline register (transforming it into a noop)

Flushing with Misprediction (Not Taken) ALU IM Reg DM I n s t r. O r d e 4 beq $1,$2,2 flush 16 and $6,$1,$7 20 or r8,$1,$9 ALU IM Reg DM For lecture Note branch address is PC-relative branch to 4+4+2*4 = 16 To flush the IF stage instruction, assert the control signal IF.Flush to zero the instruction field of the IF/ID pipeline register (transforming it into a noop)

Branching Structures Predict not taken works well for “top of the loop” branching structures Loop: beq $1,$2,Out 1nd loop instr . last loop instr j Loop Out: fall out instr But such loops have jumps at the bottom of the loop to return to the top of the loop – and incur the jump stall overhead Predict not taken doesn’t work well for “bottom of the loop” branching structures Loop: 1st loop instr 2nd loop instr . last loop instr bne $1,$2,Loop fall out instr

Static Branch Prediction, con’t Resolve branch hazards by assuming a given outcome and proceeding Predict taken – predict branches will always be taken Predict taken always incurs one stall cycle (if branch destination hardware has been moved to the ID stage) Is there a way to “cache” the address of the branch target instruction ?? As the branch penalty increases (for deeper pipelines), a simple static prediction scheme will hurt performance. With more hardware, it is possible to try to predict branch behavior dynamically during program execution Dynamic branch prediction – predict branches at run-time using run-time information Predict taken always incurs one stall at least – assuming the branch destination address hardware has been moved up to the ID stage. So predict not taken is easier since sequential instruction address can be computed in the IF stage.

Dynamic Branch Prediction A branch prediction buffer (aka branch history table (BHT)) in the IF stage addressed by the lower bits of the PC, contains a bit passed to the ID stage through the IF/ID pipeline register that tells whether the branch was taken the last time it was executed Prediction bit may predict incorrectly (may be a wrong prediction for this branch this iteration or may be from a different branch with the same low order PC bits) but it doesn’t affect correctness, just performance Branch decision occurs in the ID stage after determining that the fetched instruction is a branch and checking the prediction bit If the prediction is wrong, flush the incorrect instruction(s) in pipeline, restart the pipeline with the right instruction, and invert the prediction bit A 4096 bit BHT varies from 1% misprediction (nasa7, tomcatv) to 18% (eqntott) 4096 entry table programs vary from 1% misprediction (nasa7, tomcatv) to 18% (eqntott), with spice at 9% and gcc at 12% 4096 about as good as infinite table, but 4096 is a lot of hardware

Branch Target Buffer (BTB) The BHT predicts when a branch is taken, but does not tell where it’s taken to! A branch target buffer (BTB) in the IF stage can cache the branch target address, but we also need to fetch the next sequential instruction. The prediction bit in IF/ID selects which “next” instruction will be loaded into IF/ID at the next clock edge Would need a two read port instruction memory Read Address Instruction Memory PC BTB Or the BTB can cache the branch taken instruction while the instruction memory is fetching the next sequential instruction Except for the first time the branch is encountered, when we don’t have the branch instruction loaded into the BTB Its not quite this simple – what if the BTB instruction is for the wrong branch!! – but close enough for students at this level If the prediction is correct, stalls can be avoided no matter which direction they go

Branch History Table (BHT) Predictor 0 Predictor 1 Branch PC Predictor 7 BHT is a table of “Predictors” Could be 1-bit, could be complete state machine Indexed by PC address of Branch – without tags In Fetch state of branch: Predictor from BHT used to make prediction When branch completes Update corresponding Predictor

Dynamic Branch Prediction: BHT vs. BTB Branch History Table(BHT) Table makes prediction by keeping long-term history Example: Simple 1-bit BHT: keep last direction of branch No address check: Can be good, can be bad…. Problem: in a loop, 1-bit BHT will cause two mispredictions (avg. is 9 iterations before exit): End of loop case, when it exits instead of looping as before First time through loop on next time through code, when it predicts exit instead of looping Branch Target Buffer (BTB): identify branches and hold taken addresses

Predict taken or untaken Dynamic Prediction: Branch Target Buffer (BTB) Address of branch index to get prediction AND branch address (if taken) Must check for branch match now, since can’t use wrong branch address Grab predicted PC from table since may take several cycles to compute Update predicted PC when branch is actually resolved Branch PC Predicted PC PC of instruction FETCH =? Predict taken or untaken

1-bit Prediction Accuracy A 1-bit predictor will be incorrect twice when not taken Assume predict_bit = 0 to start (indicating branch not taken) and loop control is at the bottom of the loop code First time through the loop, the predictor mispredicts the branch since the branch is taken back to the top of the loop; invert prediction bit (predict_bit = 1) As long as branch is taken (looping), prediction is correct Exiting the loop, the predictor again mispredicts the branch since this time the branch is not taken falling out of the loop; invert prediction bit (predict_bit = 0) Loop: 1st loop instr 2nd loop instr . last loop instr bne $1,$2,Loop fall out instr For 10 times through the loop we have a 80% prediction accuracy for a branch that is taken 90% of the time

2-bit Predictors A 2-bit scheme can give 90% accuracy since a prediction must be wrong twice before the prediction bit is changed Loop: 1st loop instr 2nd loop instr . last loop instr bne $1,$2,Loop fall out instr Taken Not taken Predict Taken Predict Taken Taken Not taken Taken Not taken For class handout Predict Not Taken Predict Not Taken Taken Not taken

2-bit Predictors A 2-bit scheme can give 90% accuracy since a prediction must be wrong twice before the prediction bit is changed right 9 times Loop: 1st loop instr 2nd loop instr . last loop instr bne $1,$2,Loop fall out instr wrong on loop fall out Taken Not taken 1 Predict Taken 1 Predict Taken 11 10 Taken right on 1st iteration Not taken Taken Not taken For lecture In a counter implementation, the counters are incremented when a branch is taken and decremented when not taken (and saturate at 00 or 11). Since we read the prediction bits on every cycle, a 2-bit predictor will need both a read and a write access port (for updating the prediction bits). Predict Not Taken Predict Not Taken 00 BHT also stores the initial FSM state 01 Taken Not taken

Dealing with Exceptions Exceptions are just another form of control hazard. Exceptions arise from R-type arithmetic overflow Trying to execute an undefined instruction An I/O device request An OS service request (e.g., a page fault, TLB exception) A hardware malfunction The pipeline has to stop executing the offending instruction in midstream, let all prior instructions complete, flush all following instructions, set a register to show the cause of the exception, save the address of the offending instruction, and then jump to a prearranged address (the address of the exception handler code) The software (OS) looks at the cause of the exception and “deals” with it For undefined instrs, hardware failure, or arith overflow – the OS normally kills the program and returns an indication of the reason to the user For an I/O device request or an OS service call – the OS saves the state of the program, performs the desired task and, at some point in the future, restores the program to continue execution

Two Types of Exceptions Interrupts – asynchronous to program execution caused by external events may be handled between instructions, so can let the instructions currently active in the pipeline complete before passing control to the OS interrupt handler simply suspend and resume user program Traps (Exception) – synchronous to program execution caused by internal events condition must be remedied by the trap handler for that instruction, so much stop the offending instruction midstream in the pipeline and pass control to the OS trap handler the offending instruction may be retried (or simulated by the OS) and the program may continue or it may be aborted

Where in the Pipeline Exceptions Occur ALU IM Reg DM Stage(s)? Synchronous? Arithmetic overflow Undefined instruction TLB or page fault I/O service request Hardware malfunction For class handout

Where in the Pipeline Exceptions Occur ALU IM Reg DM Stage(s)? Synchronous? Arithmetic overflow Undefined instruction TLB or page fault I/O service request Hardware malfunction EX ID IF, MEM any yes no For lecture Note that an I/O service request is not associated with any executing instruction so can be handled when the hardware decides (to some limit) –i.e., pick the most convenient place to handle the exception Beware that multiple exceptions can occur simultaneously in a single clock cycle

Multiple Simultaneous Exceptions ALU IM Reg DM Inst 0 I n s t r. O r d e ALU IM Reg DM Inst 1 ALU IM Reg DM Inst 2 ALU IM Reg DM Inst 3 For class handout ALU IM Reg DM Inst 4 Hardware sorts the exceptions so that the earliest instruction is the one interrupted first

Multiple Simultaneous Exceptions ALU IM Reg DM Inst 0 I n s t r. O r d e D$ page fault ALU IM Reg DM Inst 1 arithmetic overflow ALU IM Reg DM Inst 2 undefined instruction ALU IM Reg DM Inst 3 For lecture ALU IM Reg DM Inst 4 I$ page fault Hardware sorts the exceptions so that the earliest instruction is the one interrupted first

Additions to MIPS to Handle Exceptions Cause register (records exceptions) – hardware to record in Cause the exceptions and a signal to control writes to it (CauseWrite) EPC register (records the addresses of the offending instructions) – hardware to record in EPC the address of the offending instruction and a signal to control writes to it (EPCWrite) Exception software must match exception to instruction A way to load the PC with the address of the exception handler Expand the PC input mux where the new input is hardwired to the exception handler address - (e.g., 8000 0180hex for arithmetic overflow) A way to flush offending instruction and the ones that follow it

Datapath with Controls for Exceptions Read Address Instruction Memory PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr RegFile Read Data 1 ReadData 2 16 32 ALU Shift left 2 Add Data Read Data IF/ID Sign Extend ID/EX EX/MEM MEM/WB Control 1 cntrl Branch PCSrc Forward Unit Hazard Compare IF.Flush 8000 0180hex ID.Flush Page 428 – incomplete and probably too much detail for this ppt slide!

Summary All modern day processors use pipelining for performance (a CPI of 1 and fast a CC) Pipeline clock rate limited by slowest pipeline stage – so designing a balanced pipeline is important Must detect and resolve hazards Structural hazards – resolved by designing the pipeline correctly Data hazards Stall (impacts CPI) Forward (requires hardware support) Control hazards – put the branch decision hardware in as early a stage in the pipeline as possible Delay decision (requires compiler support) Static and dynamic prediction (requires hardware support)