Page 102 - Computer_Science_F5
P. 102
(d) Forwarding the result: If a dependency is detected and the result is available
(e.g., from the ALU output in the EX stage), the forwarding unit directly sends
the result to the dependent instruction.
While forwarding offers performance benefits, it can be more complex to implement
FOR ONLINE READING ONLY
compared to stalling. Processors often use a combination of both techniques. Chapter Two: Performance and optimisation of computer processor
Processors prioritise forwarding for frequent data hazard types (such as, ALU output
to dependent instructions). Stalling is used for less frequent or complex dependencies
since it is a simpler solution.
Program
execution order 200 400 600 800 1000
(in instructions) Time
Add $r1, $r2, $r3 IF ID EX MEM WB
Sub $r4, $r1, $r5
IF ID EX MEM WB
Figure 2.9: Forwarding to Resolve a Data Hazard.
In Figure 2.9, the graphical Activity 2.3:
representation of the pipeline has
been used. The shading indicates the Coin flip challenge for data hazard
element is used by the instruction. Aim:
Hence, MEM has a white background To simulate a processor pipeline with
because add and sub do not access and without forwarding to understand
the data memory. Shading on the data hazards and explore the impact on
right half of the register file or performance.
memory means the element is read Materials:
in that stage, and shading on the Computer, Simulator or Emulator (such as
left half means it is written in that Ripes, RARS and MARS)
stage. Hence, the right half of ID is
shaded in the second stage because Instructions:
the register file is read, and the left Imagine a program that simulates a coin
flip game. It needs to:
half of WB is shaded in the fifth stage (a) Read a user’s bet amount (heads or
because the register file is written. tails).
93
Student’s Book Form Five
Computer Science Form 5.indd 93 23/07/2024 12:33