1 / 30

Data Hazards

Data Hazards. 0x30 sub $6 $0 $1 0x34 add $7 $6 $1. Step 3, we calculate $0 - $1. Reg. 0x30 sub $6 $0 $1. IM. DM. Reg. 0x34 add $7 $6 $1. Reg. IM. DM. Reg. ! ! ! HAZARD ! ! ! OLD VALUE OF $6. Step 4, we calculate $1 + $6. Reg. 0x30 sub $6 $0 $1. IM. DM. Reg.

Download Presentation

Data Hazards

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Hazards • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • ... • .. • .

  2. Step 3, we calculate $0 - $1 Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 add $7 $6 $1 Reg IM DM Reg ! ! ! HAZARD ! ! ! OLD VALUE OF $6

  3. Step 4, we calculate $1 + $6 Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 add $7 $6 $1 Reg IM DM Reg

  4. Step 5, Now we write $6 Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 add $7 $6 $1 Reg IM DM Reg HAZARD OVER NEW VALUE OF $6 WRITTEN TO REGFILE

  5. Step 2, nop Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 nop Reg IM DM Reg Reg IM DM Reg Reg IM DM Reg

  6. Step 3, nop Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 nop Reg IM DM Reg • 0x38 nop Reg IM DM Reg Reg IM DM Reg

  7. Step 4, add $7 $6 $1 Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 nop Reg IM DM Reg • 0x38 nop Reg IM DM Reg • 0x3C add $7 $6 $1 Reg IM DM Reg

  8. Step 5, new $6 used Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 nop Reg IM DM Reg • 0x38 nop Reg IM DM Reg • 0x3C add $7 $6 $1 Reg IM DM Reg

  9. Data Hazards • Read After Write • Solved by inserting “nop” operations (bubbles) • or by hardware “stalling” the pipe

  10. Cost? • + Hardware inexpensive • - Performance (throughput)

  11. Data Hazards sub $6 $0 $1 add $7 $6 $1 add $7 $7 $6 .. .

  12. We calculate $0 - $1 Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 add $7 $6 $1 Reg IM DM Reg ! ! ! HAZARD ! ! ! OLD VALUE OF $6

  13. We “forward” the new result Reg • 0x30 sub $6 $0 $1 IM DM Reg • 0x34 add $7 $6 $1 Reg IM DM Reg HAZARD SOLVED BY “FORWARDING”

  14. Zeroext. HERE IS THE RESULT Branch logic 0 A ALU 4 B + 31 + Sgn/Ze extend • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • > 0x38 add $7 $7 $1 • ... • ..

  15. Zeroext. WE NEED IT HERE Branch logic 0 A ALU 4 B + 31 + Sgn/Ze extend • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • > 0x38 add $7 $7 $1 • ... • ..

  16. sub $6 $0 $1 • add $7 $6 $1 0 A B DATA WORD • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • > 0x38 add $7 $7 $1 • ... • ..

  17. sub $6 $0 $1 • add $7 $6 $1 = 0 A B REG NR • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • > 0x38 add $7 $7 $1 • ... • ..

  18. Zeroext. Branch logic 0 A ALU 4 B + 31 + Sgn/Ze extend • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • 0x38 add $7 $7 $6 • > 0x3C sw $5 4($0)

  19. add $7 $7 $6 • add $7 $6 $1 • sub $6 $0 $1 = 0 A ALU B = • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • 0x38 add $7 $7 $6 • > 0x3C sw $5 4($0)

  20. add $7 $7 $6 • add $7 $6 $1 • sub $6 $0 $1 = = 0 A ALU B = = • 0x30 sub $6 $0 $1 • 0x34 add $7 $6 $1 • 0x38 add $7 $7 $6 • > 0x3C sw $5 4($0)

  21. Data Hazards sub $6 $0 $1 add $6 $6 $1 add $7 $6 $1 .. .

  22. add $7 $6 $1 • add $6 $6 $1 • sub $6 $0 $1 = = 0 A ALU B = = • 0x30 sub $6 $0 $1 • 0x34 add $6 $6 $1 • > 0x38 add $7 $6 $1 • ... • ..

  23. Performance • No “Bubbles” or “Stalls” • increased throughput • But did we change the critical path? • Topological sort • Static timing analysis

  24. Zeroext. = = Branch logic 0 A ALU 4 B + = = 31 + Sgn/Ze extend

  25. Forwarding Logic W Reg # DRD/DWT W >=1 = Reg # = & & DATA DATA

  26. Critical path ALU? Zeroext. = = Branch logic 0 A ALU 4 B + = = 31 + Sgn/Ze extend

  27. Critical path DATA MEMORY? Zeroext. = = Branch logic 0 A ALU 4 B + = = 31 + Sgn/Ze extend

  28. All problems solved? • NO, what will happen if...... • lw $6 $0($1) • add $4 $6 $1 • add $7 $6 $2

  29. OK, “DM” to “DE” Reg • 0x30 lw $6 $0($1) IM DM Reg Reg IM DM Reg • 0x34 add $4 $6 $1 • 0x38 add $7 $6 $2 Reg IM DM Reg

  30. “DM” to “EX” ? Reg • 0x30 lw $6 $0($1) IM DM Reg Reg IM DM Reg • 0x34 add $4 $6 $1 • 0x38 add $7 $6 $2 Reg IM DM Reg

More Related