Identify datahazards in the following code block ADD XI X3 X

Identify data-hazard(s) in the following code block. ADD XI, X3, X1 ORR X2, X2, X1 STUR X2, [X1, #100] b) Assume, you started with X1 = 10, X2 = 20, and X3 = 20. If there is no \"Hazard Detection Unit\" or \"Forward Control Unit\", what will be the value of X2 while STUR instructs is working at its decode phase. c) Add \"NOP\" instructions to the code above so that it will run correctly on a pipeline that does not handle Data-Hazards. Justify you answer by showing the flow of instructions in a MULTI-CYCLE PIPELINE diagram.

Solution


(a) There are two Data Hazards present in the given code:

1. RAW (Read After Write): later instruction tries to read an operand before earlier instruction writes it

ADD x1, x3, x1 than ORR x2, x2, x1 => Here x1 Writes in first instruction and Read in second instruction

2. WAR (Write After Read): later instruction tries to write an operand before earlier instruction reads it

ADD x1, x3, x1 => Here value of x1 Reads and than writes

ORR x2, x2, x1 => Here value of x2 Reads and than writes

 Identify data-hazard(s) in the following code block. ADD XI, X3, X1 ORR X2, X2, X1 STUR X2, [X1, #100] b) Assume, you started with X1 = 10, X2 = 20, and X3 = 2

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site