Page 100 - Computer_Science_F5
P. 100
This is similar to a branch instruction. The chit acts like the program, and the
“butter” instruction is the condition. The condition is the presence or absence of the
“butter” instruction on the chit. If there’s “butter,” Mama Chapati jumps (branches)
to the butter application step before cooking. The specific step for applying butter
becomes the target address for the branch. Chapter Two: Performance and optimisation of computer processor
FOR ONLINE READING ONLY
A control hazard, also known as a branch hazard, occurs when the pipeline makes
the wrong decision on a branch prediction and therefore brings instructions into the
pipeline that must subsequently be discarded. Imagine planning a picnic based on the
weather forecast, only to have it change drastically. The processor needs to adjust its
course based on the actual branch outcome, as shown in Program Example 2.2.
Program Example 2.2:
beq $r2, $r1, Label //Branch to Label if $r1=$r2
add $r3, $r2, $r1
lw $r3,4($r2)
sw $r1,0($r2)
Label: sub $r4, $r3, $r2
In Program Example 2.2, the pipeline Read After Write (RAW), and Write
must wait until after the branch decision to After Read (WAR).
determine the correct instruction address.
Control hazards can be solved through 2. The following instructions
stalling or through a more intelligent represent a program to be processed
approach called predictive branching. by a simplified processor pipeline.
In predictive branching, the processor Identify the type(s) of hazards for
predicts the branch outcome in advance each instruction, if any. Write
and fetches the predicted instruction. We “None” if no hazard is present.
will cover branch predictions in another add $r1, $r2, $r3
section. sub $r4, $r1, $r5
lw $r6, 100 ($r6)
Exercise 2.2
add $r7, $r4, $r8
1. Use resources such as the internet beq $r7, $r2, Loop
and the library to research on the
following types of data hazards: add $r9, $r10, $r1
91
Student’s Book Form Five
Computer Science Form 5.indd 91 23/07/2024 12:33