Skip to content

bhver3593/MIPS-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIPS-Simulator

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.

How to compile program from Linux

g++ -o mips -std=c++11 *.cpp

How to run program from Linux

./mips assemblyfile.txt

How it works

  • 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

InstructionMemory

  • 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

LoadInstruction

  • After executing an ALU instruction, the ALU operates on data values from two source registers and writes the result to the destination register

ADDInstruction

  • 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

BranchInstruction

  • 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

StoreInstruction

  • 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

DebugMode

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published