ECE 15B - Computer Organization

Programming Assignment #2

Due May 25, 5pm

 

This project involves creating a SPIM LITE simulator for a subset of the MIPS instructions, which we call MIPS LITE.  It is an instruction set with fewer calories and low carbs.  Best of all, it tastes great and is less filling.

 

To make it interesting, SPIM LITE must be written in MIPS assembly language.  In essence, you are using MIPS and SPIM to create a mini-SPIM written in MIPS. Your program will be called by a shell that establishes the environment and will execute until it does a return back to the shell.

MIPS LITE
The MIPS LITE instruction set consists of the following MIPS instructions:

 

MUL and MAC are not real MIPS instructions.  Their functions are described as follows:

MAC (opcode=0, function=0x17) (Multiply and accumulate)

How to call : Mac $t1, $t2, $t3

Function: $t1 acts as an accumulator. This instruction takes $t2 * $t3 and then adds it to $t1, and then stores it back to $t1, e.g. $t1 = $t1 + $t2*$t3.  You should count MAC as an R-type instruction.

 

MUL (opcode=0, function=0x18)

How to call: Mul $t1, $t2, $t3

Function: Multiply $t2 and $t3, directly just take the least significant 32 bits from the product to store in $t1, e.g. $t1=$t2*$t3.  Count MUL as an R-type instruction.

 

Environment
Your routine will be called by the given shell routine. The shell allocates memory, loads in a program, and passes you the following values:

As usual, $ra will have the return address. Execution halts on the simulator's (jr) to the address in $ra. The simulator procedure should return these values:

In addition, after you have completed simulation of the program, but before you return (via "jr $ra"), print out the following statistics:

For example, if your simulator executes 100 instructions, and if 57 are R-type, 32 are I-type, and 11 are J-type ... your code should print out the following:

R-type: 57
I-type: 32
J-type: 11

For our grading convenience, we are asking you to print out your statistics in this prescribed format and only in this prescribed format! You MUST print out your statistics in the above format! Be sure to place a carriage return at the end of each line.

Programs for your Simulator
Programs for your simulator consist of integer values, one per line, that represent hand-assembled MIPS instructions. The end of the program is signified by a 0. The shell that we give you will read in a file line-by-line, storing it into the "code" space, stopping when it reads in a 0. The 0 will also be stored in the code space so that your simulator knows where it should stop execution. The command-line used to execute a program is as follows:

 
spim -file simulator.s < myprogram

where "simulator.s" is your assembly language code implementing the MIPS simulator (shell plus your code) and "myprogram" is a text file containing integers representing MIPS instructions. The "<" symbol redirects input so that spim takes its input from the file "myprogram" rather than from the console.

A debugging shell is also supplied that works with xspim.  This has a pre-loaded program in the static memory.  Currently this program corresponds to code1.int.  You can change the program to anything you want by changing the integer values of the instructions that you want to execute.  This should be done for debugging sake.   You are only allowed to modify the lines after the sim_mips label.

Testing
We provide you with some test sequences here, but we recommend that you also create your own test sequences. While the programming is to be done individually, we encourage the group creation and sharing of test code. You will need to hand compile your test code to generate a file of integers that can be read in by the shell.

Hints

Turn in:

There will be a submission site set up (similar to project #1) where you turn in your file.  Please watch the discussion board for the URL.  You are required to submit the simulator.s file.  This includes the code given to you as well as your code in sim_mips to implement the simulator.  The grading of the project will be done by feeding an input program into your simulator and observing the outputs.  Therefore, you must output the correct format answers in $v0, $v1, which will be printed out by the skeleton file.  Additionally, you must output the number of R, I and J-type instructions in the specified format (see above) in your code.  This is not done for you.  Failure to do this or output in the wrong format will result in loss of points.