• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 544
  • Last Modified:

how to simulate MIPS architecture in C++

hello!

how will i simulate multi cycle implementaion of  MIPS architecture in C++, which has memory, 32 registers, 32 bit ALU, PC, IR, MDR registers.


regards,
siddharth
0
sjain1203
Asked:
sjain1203
  • 3
  • 2
  • 2
2 Solutions
 
Jaime OlivaresSoftware ArchitectCommented:
Have a look to this emulator:
http://www.cs.wisc.edu/~larus/spim.html
0
 
sjain1203Author Commented:
no, i am not able to understand this. can you make a simple step-by-step tutorial for me.


regards,
siddharth
0
 
Jaime OlivaresSoftware ArchitectCommented:
Sorry, sincerly I can't write an entire book here. To emulate a processor arquitecture is not a trivial task, you have to read much. If you want the whole theory, you can buy these books:
http://www.amazon.com/exec/obidos/tg/detail/-/0030988160/ref=lpr_g_2/103-8213741-5164620?v=glance&s=books
http://www.amazon.com/exec/obidos/tg/detail/-/1558602976/qid=1112462927/sr=1-7/ref=sr_1_7/103-8213741-5164620?v=glance&s=books
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
sjain1203Author Commented:
i dont have this much time.

okay, i want to simulate a MIPS architecture in c++, which has 32 bit adder, memory, 32 registers, PC, IR, MDR registers and some multiplexers.

how should i start

0
 
grg99Commented:
It depends how accurately you need to simulate.

If you just want to execute the instructions correctly, that's a simpler level of simulation.

If you want to be able to accurately time sequences of instructions, that's quite a bit harder.

Please tell us if you want (1)  or (2).

0
 
sjain1203Author Commented:
I need option (1)
0
 
grg99Commented:
For data structures, you need some variables to hold your emulated main memory, something like:
 uint32 MainMem[ MAINMEMSIZE ],

an array to hold the main registers:
uint32 Regs[ 64 /* or however many there are */ ];

you also need some variables to hold the registers that are not part of the regular register array:  uint32 PC, SP, SR;

Some more variables to hold the memory management unit registers: uint32 MemMap[ 4096 ];

Then for code you need a big switch statement, something like:

Instruction = MainMem[ PC ];

OpCode = Instruction >> 24;  /* or whatever it takes to isolate the opcode */

Running = 1;

while( Running ) {
switch ( Opcode ) {
case 000:  /*  NOP */   PC++; break;
case 001:  /*  HLT  */   Running = 0;  break;
... and so on
}
}

0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now