问题
What should be a good approach to simulate MIPS pipe lining ? Like should pipeline simulates in forward direction or in backward direction ? I am confused. I have instruction set and i have disassembled the instructions but i need some direction to move further.
回答1:
The advantage of simulating the pipeline stages "backwards" (e.g. in reverse order like writeback, cache, alu, register, decode, fetch) is that each stage can read the variables that represent the input latches and then simply overwrite the variables that represent the output latches. This will not work if you simulate the pipeline "forward" because each stage would overwrite the input of the following stage and the original input would be lost. Of course, if you copy the latches before you overwrite them, you can simulate the pipeline stages in any order you want. So it's rather a minor implementation detail. A simple MIPS simulator that does this reverse order trick is SimpleScalar.
来源:https://stackoverflow.com/questions/22955154/mips-pipeline-simulator-using-scoreboarding