I need an algorithm that will simulate a processor executing instructions. Each instruction is divided into 5 execution parts or stages (IF, ID, EX, MEM, WB) Each of these parts or stages should be executed for each clock cycle. And for each clock cycle, a new instruction (with the same 5 stages) should be activated and executed in the same manner. Time-------------->Cycle1--->Cycle2--->Cycle3--->Cycle4--->Cycle5--->Cycle6 Instruction1-----> IF--------->ID--------->EX-------->MEM----->WB Instruction2------------------->IF--------->ID--------->EX-------->MEM---- >WB and so on. I suspect I will use Threads on this one but I don't know how? Any help?? thanks.
If you are simulating a multithreaded processor, you should use create multiple Threads, but if you are just simulating the streamline of those instructions, a single loop can do that.