MIPS-Simulator is a C++ application that simulates a pipelined MIPS processor by executing a list of instructions from an input assembly file and displaying the contents of the register file and memory after each instruction execution.
g++ -o mips -std=c++11 *.cpp
./mips assemblyfile.txt
- Register values (except the zero register and stack pointer) are initially set to -1
- Stack pointer in register 31 is set to 8
- Data memory contains randomly generated values between 1 and 100
- Control signals are set to false
- After running the application, the contents of instruction memory are presented
- Each instruction is executed in a consecutive manner
- After executing a load instruction, data from memory is loaded to a register
- To calculate the memory address, the stack pointer value from register 31 is added to the offset value
- Data from the calculated memory address is then written to the destination register
- After executing an ALU instruction, the ALU operates on data values from two source registers and writes the result to the destination register
- After executing a branch instruction, the ALU compares the data values from two source registers
- If the two data values are equal, the offset value will be shifted by 2 and added to the program counter
- The value of the updated program counter will determine the next instruction executed from instruction memory
- After executing a store instruction, data from a register is stored to memory
- To calculate the memory address, the stack pointer value from register 31 is added to the offset value
- Data from the source register is then written to the calculated memory address
- When DEBUG mode is enabled in main.cpp, the emitted control signals and the contents of the state registers are printed
- Additionally, controls signals are reset to false before the next instruction is executed