I am trying to simulate 5 stage of pipeline. I have saved all the instruction into a struct. ( basically done with the stage of lixcal analysis )
eg:
ADD R1 R2 R3 // R1 = R2+ R3 ... struct pipe{ int pc, string instruction , int r1, int r2....}
now if p[i]
is one of the stage of pipeline and ( p[1]
could be pc=pc+1
;
I[i]
is instructions, ( I[1]
could be ADD R1 R2 R3
)
what I want to do is
at t=1 : p[1] = I[1]
at t=2 :p[2] = I[1], p[1] = I[2]
at t=3 :p[3] = I[1], p[2] = I[2], p[1] = I[3]
at t=4 :p[4] = I[1], p[3] = I[2], p[2] = I[3], p[1] = I[4]
... and goes like that I am using c++ so far. how could any one represent this cycle in c++ ?