J doh
J doh

Reputation: 115

Confused with pipelining, hazards, dependency

For homework we have been given the sequence:

ADD $r0,    $r1,    ->  $r2
SUB $r4,    $r0,    ->  $r3
AND $r5,    $r0,    ->  $r6
OR  $r7,    $r0,    ->  $r8
XOR $r9,    $r0,    ->  $r10

It follows IF, ID, EX, MEM, WR stages.

First we have to identify the dependencies. I have done that (I believe).

Secondly, identify hazards and their type. I think I've done this correctly.

Thirdly "iii. Evaluate the number of cycles it takes to execute all the given five instructions and the corresponding CPI (number of cycles per instruction)"

Referencing the image here, I answered with

"As table 7 shows, it takes 17 cycles for all five (ADD, SUB, AND, OR, XOR) instructions to complete. As each instruction was dependent on $r0, they took longer as they progressed.

ADD – 5 CPI SUB – 7 CPI AND – 9 CPI OR – 11 CPI XOR – 13 CPI"

I am very confused by part iv. which says

"iv. Suggest one technique used to eliminate these type of hazards. Draw the resulting new multi-cycle pipeline diagram and workout the new CPI."

I would be so grateful for any help anyone can give me.

Upvotes: 0

Views: 111

Answers (1)

T-Fox
T-Fox

Reputation: 1

First off, I'm not seeing any dependencies in the instructions you have posted. Also, I'm not too sure what they mean by eliminate the hazards.

However, one technique you can try is forwarding. Since these are all arithmetic instructions they are finished after the EX stage. Therefore, you can forward the value computed by the ALU from MEM to EX or WB to EX. Where EX is the execute stage of the next instruction.

Upvotes: 0

Related Questions