I am trying to simulate 5 stages of a pipeline. I saved all the instructions in the structure. (mainly done with the stage of lycal 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 stages of the pipeline and ( p[1] can be pc=pc+1 ; I[i] are the instructions, ( I[1] can 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 it goes, I use C ++. how can anyone represent this loop in c ++?
source share