1
votes

The code below runs on a 5-stage pipelined datapath. I am having a hard time knowing whether my understanding of how pipelining works is correct or not. In my attempt below, I try to solve a data hazard in a datapath with no data forwarding unit, by inserting 'bubbles' in the oppropriate places. My first question is, is my pipelining logic below correct?

My second question is assuming there IS a forwarding unit in the datapath, from MEM->EX and from WB->EX, how would that change my logic from the first question?

add t0, s1, s2
add t1, t0, s3
sub t2, t0, t1
xor t3, t2, a0
lw t4, 0(t7)
slt t5, t4, t3

This is my attempt for question 1:

add t0, s1, s2 //IF add1 instruction
nop            //ID add1 instruction
nop            //EX add1 instruction
add t1, t0, s1  //MEM add1 instruction,  IF add2 instruction
nop             //WB add1 instruction,  ID add2 instruction
nop            //EX add2 instruction
nop            //MEM add2 instruction
nop            //WB add2 instruction
sub t2, t0, t1 //IF sub instruction
nop            //ID sub instruction
nop            //EX sub instruction
nop            //MEM sub instruction
xor t3, t2, a0 //WB sub instruction, IF xor instruction
lw t4, 0(t7)   //ID xor instruction, IF lw instruction
nop            //EX xor instruction, ID lw instruction 
nop            //MEM xor instruction, EX lw instruction 
nop            //WB xor instruction, MEM lw instruction
slt t5, t4, t3 //WB lw instruction, IF slt instruction
1
Is this CS 251 from University of Waterloo by chance?sampson-chen
It would help if you could post some images of the circuitry, because there are different data-forwarding setups. Also you can stagger your instructions on pipelines to see where the hazards are without and without dataforwardingsampson-chen
images are not given and are not neccessary to solve this problem. thanks anyways though.AnchovyLegend

1 Answers

-1
votes

Take a look at the pipeline diagrams illustrated here: https://www.student.cs.uwaterloo.ca/~cs251/S12/a4.pdf and map your instructions to similarly staggered pipelines, and it will help you visualize the data hazards.

In addition, the exact data-forwarding implementation will depend on the design of the questions on your assignments, which will affect how many nops you need.