CA Classes-86-90
CA Classes-86-90
back (WB) pipe stage, but the value is read by the SUB instruction during
the instruction decode (ID) stage (ID sub). This problem is referred to as the
data hazard because a wrong value is read by the sub instruction and an
attempt is made to use it.
The WB stage of ADD will get complete when an interrupt occurs between
the ADD and SUB instructions, and the value of R1 at that point will be the
outcome of the ADD.
As we can see in figure 4.4 and 4.5, AND instruction is also effected by data
hazard, the write of R1 does not finish till the end of clock cycle 5.
Therefore, AND instruction when executed at cycle 4 will not retrieve the
correct results.
The SUB instruction reads the wrong value as it reads the data (cycle 3)
before the ADD instruction writes the value (cycle 5). The register read of
XOR instruction occurs in clock cycle 6. This is performed correctly as it is
done after the register write by ADD. The OR instruction can function
without any problem. To attain this, the register files reads are performed in
the second half of the cycle and writes in the first half. In cycle 5, the first of
the cycle performs the write to register file by ADD and the second half of
the cycle will perform the read of registers by OR.
not know the outcome of the branch when it needs to insert a new
instruction into the pipeline stage).
As soon as the branch is detected, the method used to deal with branches
is to stall the pipeline. Until the instruction is confirmed to be a branch, there
is no need to stall the pipeline. Thus, the stall does not occur until after the
ID stage. The pipelining behaviour looks as in figure 4.6.
The control hazard stall is not implemented in the same way as the data
hazard stall, since the instruction fetch (IF) cycle is to be repeated as soon
the branch cycle is known. Thus, the first IF cycle is definitely a stall, as it
never performs essential tasks. By setting the ID/IF to zero, we can
implement the stall for the three cycles. The repetition of the IF stage is not
required, if the branch is untaken, since the correct instruction may already
have been fetched.
Self Assessment Questions
14. __________ cause a greater performance failure for a pipeline than
_____________________.
15. If the PC is changed by the branch to its target address, then it is
known as ______________ branch; else it is known as ___________.