Pipelining Data and Control Hazards - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Pipelining Data and Control Hazards

Description:

... depends on completion of data access by a previous instruction. add ... Don't wait for it to be stored in a register. Requires extra connections in the datapath ... – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 21
Provided by: constantin56
Category:

less

Transcript and Presenter's Notes

Title: Pipelining Data and Control Hazards


1
Pipelining Data and Control Hazards
  • ECE 411 - Fall 2009
  • Lecture 10

2
MIPS Pipelined Datapath
4.6 Pipelined Datapath and Control
MEM
Right-to-left flow leads to hazards
WB
3
Pipeline registers
  • Need registers between stages
  • To hold information produced in previous cycle

4
Pipelined Control (Simplified)
5
Pipelined Control
  • Control signals derived from instruction
  • As in single-cycle implementation

6
Pipelined Control
7
IF for Load, Store,
8
ID for Load, Store,
9
EX for Load
10
MEM for Load
11
WB for Load
Wrongregisternumber
12
Corrected Datapath for Load
13
Data Hazards
  • An instruction depends on completion of data
    access by a previous instruction
  • add s0, t0, t1sub t2, s0, t3

14
Forwarding (aka Bypassing)
  • Use result when it comes out of the EX stage
  • Dont wait for it to be stored in a register
  • Requires extra connections in the datapath

15
Multi-Cycle Pipeline Diagram
  • Form showing resource usage

16
Multi-Cycle Pipeline Diagram
  • Traditional form

17
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

18
Structure Hazards
  • Conflict for use of a resource
  • In MIPS pipeline with a single memory
  • Load/store requires data access
  • Instruction fetch would have to stall for that
    cycle
  • Would cause a pipeline bubble
  • Hence, pipelined datapaths require separate
    instruction/data memories
  • Or separate instruction/data caches

19
Load-Use Data Hazard
  • Cant always avoid stalls by forwarding
  • If value not available when needed
  • Cant forward backward in time!

20
Code Scheduling to Avoid Stalls
  • Reorder code to avoid use of load result in the
    next instruction
  • C code for A B E C B F

lw t1, 0(t0) lw t2, 4(t0) add t3, t1,
t2 sw t3, 12(t0) lw t4, 8(t0) add t5, t1,
t4 sw t5, 16(t0)
lw t1, 0(t0) lw t2, 4(t0) lw t4,
8(t0) add t3, t1, t2 sw t3, 12(t0) add t5,
t1, t4 sw t5, 16(t0)
stall
stall
11 cycles
13 cycles
Write a Comment
User Comments (0)
About PowerShow.com