Questions tagged [cpu-hazard]

In [computer-architecture], data hazards, control hazards or structural hazards can exist between two nearby instructions. CPU pipelines need to handle them, or require software to avoid them, to correctly execute code.

Questions about hazards should usually also be tagged .

A pipelined CPU starts working on an instruction before completely finishing previous instructions. Maintaining correctness while doing this requires avoiding hazards, for example making sure that an instruction reading a value from a register actually gets the right value, even if it was only written by the previous instruction. (Read After Write (RAW) data hazard).

Data hazards, control hazards, and/or structural hazards can exist between two nearby instructions. CPU pipelines need to handle them, or require software to avoid them, otherwise execution could give wrong or unpredictable results.

See Wikipedia for details:


Things this tag is not about:

20 questions
0
votes
1 answer

Why are these 2 instructions considered data dependent?

So , I have learnt that when we use the technique of pipelining in CPU , we may have to tackle some hazards such as data dependency between two instructions. I do get for example this data dependecy: add $t0, $t1, $t2 lw $s1, 0($t0) lw does need…
tonythestark
  • 519
  • 4
  • 15
0
votes
1 answer

Data hazards in a single instruction

Considering the following mips code snippet add $t1, $t1,$t2 lw $t1, 0($sp) I understand that there is a WAW data hazard on $t1 between instructions 1 and 2, but is there a WAR hazard on line 1 because we read from and write to $t1 in a single…
richbai90
  • 4,994
  • 4
  • 50
  • 85
0
votes
1 answer

Data Hazard(True Dependencies) in MIPS

I1:LW R1, 0(R4) ; R1 ← address (0+R4) I2:ADDI R2, R1, #8 ; R2 ← R1+8 I3:MULT R3, R1, R1 ; R3 ← R1*R1 I4:SW R3, 4(R2) ; address(4+R2) ← R3 In the MIPS code above, in an solution sheet, a true dependency is marked as I3->I4 for R3. From my…
HotWheels
  • 444
  • 3
  • 23
0
votes
1 answer

Do store instructions create a hazard the same way loads do?

I do not think there is a hazard, but wanted to confirm. I know that if there was a load word then I should assume a hazard, but is it the same for a store word? sw $t4,8($t0) add $t3,$t4,$t0
DJSQUARE
  • 1
  • 1
-1
votes
1 answer

MIPS Pipeline forwarding: How to forward to the second succeeding instruction?

Say, for example, I have 3 instructions: 1, 2, and 3. I want to forward data from instruction 1 to instruction 3. The catch is, I can only forward from the EX/MEM register of instruction 1. So we have: 1: IF ID EX MEM WB 2: IF ID EX MEM…
1
2