Question

Identify all of the data dependencies in the following code. Which dependencies are data hazards that...

Identify all of the data dependencies in the following code. Which dependencies are data hazards that will be resolved via forwarding? Which dependencies are data hazards that will cause a stall?

S1: add $3, $4, $6
S2: sub $5, $3, $2
S3: lw $7, 100($5)
S4: add $8, $7, $2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Number of data dependencies : 3 (all are Read after write dependencies).

Number of dependencies that are hazard : 3 (all dependencies are also hazard)

Number of dependencies that can be resolved via forwarding : 2

Number of dependencies that causes hazard : 1

The data dependencies of instructions along with pipeline diagram is explained below :

Above pipeline diagram is for the five stage pipeline. The stages are : Instruction fetch (IF), Instruction decode (ID), Execution (EX), Memory (MEM) and Write back (WB). Here stall are shown with ' X ' symbol. The data forwarding is shown using red arrow in the diagram.

The dependency S2->S1 is for register $3, whose value is available in EX stage of S1. So it can directly used by EX stage of S2 in next clock cycle.

The dependency S3->S2 is for register $5, whose value is available in EX stage of S2. So, it can directly used by EX stage of S3 in next clock cycle to compute address value 100 + $5.

The dependency S4->S3 is for register $7, whose value is available after MEM stage of S3 (clock cycle 7). The value of $7 is required in EX stage of S4 (clock cycle 6). So, there has to be a stall in order to S3 to finish getting data from memory in MEM stage. Hence this dependency can not be resolved using data forwarding.

If you have any doubts then you can ask in comment section. Thank you.

Add a comment
Know the answer?
Add Answer to:
Identify all of the data dependencies in the following code. Which dependencies are data hazards that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT