?
Solved

how to simulate MIPS architecture in C++

Posted on 2005-04-02
10
Medium Priority
?
541 Views
Last Modified: 2012-06-27
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
Comment
Question by:sjain1203
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
10 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13688452
Have a look to this emulator:
http://www.cs.wisc.edu/~larus/spim.html
0
 

Author Comment

by:sjain1203
ID: 13688646
no, i am not able to understand this. can you make a simple step-by-step tutorial for me.


regards,
siddharth
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 1000 total points
ID: 13688682
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.

 

Author Comment

by:sjain1203
ID: 13688777
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
 
LVL 22

Expert Comment

by:grg99
ID: 13691363
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
 

Author Comment

by:sjain1203
ID: 13694166
I need option (1)
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 1000 total points
ID: 13696843
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question