Professional Documents
Culture Documents
Hazards: Situations That Prevent Starting The Next Instruction in The Next Cycle Structure Hazards Data Hazard
Hazards: Situations That Prevent Starting The Next Instruction in The Next Cycle Structure Hazards Data Hazard
Situations that prevent starting the next instruction in the next cycle Structure hazards
A required resource is busy Need to wait for previous instruction to complete its data read/write Deciding on control action depends on previous instruction
Chapter 4 The Processor 1
Data hazard
Control hazard
Structure Hazards
Load/store requires data access Instruction fetch would have to stall for that cycle
Data Hazards
add sub
Dont wait for it to be stored in a register Requires extra connections in the datapath
Reorder code to avoid use of load result in the next instruction C code for A = B + E; C = B + F;
lw lw add sw lw add sw $t1, $t2, $t3, $t3, $t4, $t5, $t5, 0($t0) 4($t0) $t1, $t2 12($t0) 8($t0) $t1, $t4 16($t0) lw lw lw add sw add sw $t1, $t2, $t4, $t3, $t3, $t5, $t5, 0($t0) 4($t0) 8($t0) $t1, $t2 12($t0) $t1, $t4 16($t0)
stall
stall
13 cycles
11 cycles
Chapter 4 The Processor 6