Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Identify data-hazard(s) in the following code block. ADD XI, X3, X1 ORR X2, X2,

ID: 3940941 • Letter: I

Question

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.

Explanation / Answer


(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