Archer:SPIM EEL4713C Spring 2008

From Grid-Appliance Wiki

Jump to: navigation, search

Contents

Simulation-based self-study of the MIPS ISA

Author: Renato Figueiredo renato
Level: Undergraduate
Effort: Few hours to complete. Appropriate as lab part of a 1-week first or second assignment of a computer architecture class using MIPS
Overview: The goal of this assignment is for you to get acquainted with the SPIM simulator, which will help you familiarize yourself with the MIPS instruction set and debug simple MIPS programs.


Installation

Install the Archer virtual machine Grid appliance in your computer. This will create a Linux-based virtual environment in your computer which will be used for various kinds of simulations.

Browse to the Grid appliance portal and follow the “quick start guide” instructions to install a virtual machine appliance in your laptop and go through its tutorial.

SPIM introduction

Assuming you are done with the application installation. Within a command-line terminal window in the Grid appliance, download and uncompress the SPIM simulator package with the following commands:

cd ~
sudo wget http://www.acis.ufl.edu/~ipop/edu-docs/eel4713spim.tgz
tar –xzf eel4713spim.tgz

Browse the SPIM manual for a summary of its features and command syntax.

In this tutorial you will step through the execution of a simple example program, named larger.s, located in the spim-6.4/Examples directory. You can view the contents of this file with a text editor as explained in the appliance tutorial, or with the Unix commands:

cd spim-6.4
cd Examples
more larger.s

Now go inside the spim-6.4 directory and start the SPIM simulator:

cd ~/spim-6.4
./spim

Within the SPIM console, load the larger.s example:

load “Examples/larger.s”

To execute the test program, simply type:

run

The program will prompt you for a sequence of integer numbers. Once you enter the number zero, the program will display the largest of all numbers you entered. Enter a sequence of numbers of your choice, then the number zero. Once the program exits, inspect the value of register $5 with:

print $5

It should contain the largest value you entered. Step through the execution of this program instruction by instruction with the command:

step

Inspect the values of individual registers (e.g. $1) with and the values of all registers with the commands:

print $1
print_all_regs

Continue with this process until you are comfortable with the step-by-step simulation feature.

Quiz

Inspect the assembly code for the program “lab1.s”:

cd ~/spim-6.4/Examples
more lab1.s

Then, simulate its execution with SPIM to answer the following questions:

  1. What function is computed by this program?
  2. Which registers are used to hold operands and results

Debugging the MIPS ISA with bugSPIM

In this part of the tutorial, you will use the application “bugspim” in much the same way that you used “spim” in the tutorial above. This exercise will help you understand the MIPS ISA by challenging you to systematically come up with MIPS programs that will let you "zoom in" on the bugs that have been introduced

However, “bugspim” simulates a MIPS processor like “spim” does except that the microprocessor it simulates has a number of bugs that make the execution of certain instructions incorrect. Your task is to identify these bugs by running MIPS assembly code in “bugspim” and verifying whether the behavior of instructions follow the instruction set specifications.

There are a total of 5 instructions with bugs: one ALU operation, two control flow instructions, an instruction which uses immediate values, and a memory access instruction. Download and setup the BugSPIM simulator in the same directory as your original spim simulator with the following commands:

cd ~/spim-6.4
sudo wget http://www.acis.ufl.edu/~ipop/edu-docs/bugspim
sudo chmod 755 bugspim
sudo chown griduser bugspim

Quiz

Simulate bugspim with your own assembly programs to try to identify the five bugs that it contains. Be systematic in your search - you cannot trust any instruction to be correct once you test it!

Determine a) which instructions have bugs, b) what is the incorrect behavior you observed, and c) what assembly code you used to determine the incorrect behavior.

Personal tools