1. Introduction
The following text describes the procedure of installing the simulator Simplescalar [1] on a modern Linux distribution. The procedure has been tested on Ubuntu Linux 10.10 (Maverick Meerkat) but should work on most Linux distributions. The instructions are modified from [2] and [3].
2. Preparations
You may find these files useful: install_guide_v2.txt, users_guide_v2.pdf
These can be found on the SimpleScalar website, http://www.simplescalar.com/docs.html
Download the necessary source code files:
simpletools-2v0.tgz from http://www.simplescalar.com/tools.html
simplesim-3v0d-with-cheetah.tar.gz from http://www.ict.kth.se/courses/IS2202/software (you can find single sim-cheetah package also)
simpleutils-990811.tar.gz from http://csrl.unt.edu/downloads/simplescalar.tgz (In this package, flex-2.5.4a/gcc-2.7.2.3.ss/simplesim-3v0d/simpleutils-990811/simpletools-2v0 and hello.c for test can be found)
gcc-2.7.2.3.ss.tar.gz from http://american.cs.ucdavis.edu/RAD/gcc-2.7.2.3.ss.tar.gz
Setup some environment variables (assuming your home directory is /home/matsbror and that you are using a bash-compatible shell):
$ export IDIR=/home/matsbror/simplescalar
$ export HOST=i686-pc-linux (or i386-unknown-linux)
$ export TARGET=sslittle-na-sstrix
Create the directory “simplescalar” under your home directory, and copy all the four tarballs into it:
$ mkdir $IDIR
$ mv simplesim-3v0d-with-cheetah.tgz $IDIR
$ mv simpletools-2v0.tgz $IDIR
$ mv simpleutils-990811.tar.gz $IDIR
$ mv gcc-2.7.2.3.ss.tar.gz $IDIR
Note:
Before installing simple scalar package, make sure your system has the following packages installed:
C library header: libc6-dev
binutils
flex
bison
In Ubuntu you can just say: sudo apt-get install <all the packages above>
3. Installing SimpleTools
Just un-pack the package file, and remove the old gcc folder:
$ cd $IDIR
$ tar xvfz simpletools-2v0.tgz
$ rm -rf gcc-2.6.3
4.Installing SimpleUtils
First un-pack the package file.
$ cd $IDIR
$ tar xvfz simpleutils-990811.tar.gz
$ cd simpleutils-990811
$ ./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
$ make
--If errors show up during the process, apply the following fixes:
insert a semi-colon (;) at line 77 of simpleutils-990811/binutils/arparse.y file.
insert a semi-colon (;) at line 168 of simpleutils-990811/ld/ldgram.y file.
--If error is about "yy_input", apply the following fix:
find . -type f -print0 | xargs -0 sed -i -e 's,yy_current_buffer,YY_CURRENT_BUFFER,g'
$ make install
Note:
If you experience compilation problems with “'yy_current_buffer ' undeclared” there may be problems with flex. Download and install the following version which is known to work together with Simplescalar. Http://www.ict.kth.se/courses/IS2202/flex.tar.gz. The following command(s) should work for installation: “./configure; make; sudo make install”.
After installation of flex, if needed you should remove the installation directory of simpleutils and restart unpacking, configuration etc.
If you have a multicore processor, you may speed up the compilation process by using “make –j 2” for a dual core and “make –j 4” for a quad core. It may even go faster if you specify a number higher than the core count as compilations are I/O intensive and you then may overlap CPU-intensive parts of the build process with disk operations.
5.Building the simulators
Un-pack the simulator package.
$ cd $IDIR
$ tar xvfz simplesim-3v0d-with-cheetah.tar.gz
$ cd simplesim-3.0
$ make config-alpha
$ make
--if error encountered "machine.h:224: error: array type has incomplete element type", then
Move the line:
extern enum md_opcode md_mask2op[];
below the definition of md_opcode (about 6 lines below). That should do the trick with gcc 4.x
If sucess, "my works done here ..." will show
6. Installation of gcc cross-compiler
Un-pack the source code and configure the installation:
$ cd $IDIR
$ tar xvfz gcc-2.7.2.3.ss.tar.gz
$ cd gcc-2.7.2.3
$ make LANGUAGES="c c++" CFLAGS="-O3" CC="gcc"
- For insn-output.c error:
In insn-output.c, add line breaks ('\') after each of the three FIXME (line 675, 750 and 823)
- For decl.c "invalid increment"error:
edit obstack.h (remember to 'chmod +w' this file) at line 341 and
change "*((void **)__o->next_free)++=((void *)datum);\" to "*((void **)__o->next_free++)=((void *)datum);\"
- For parse error in libgcc2.c:
In libgcc2.c, add "#define BITS_PER_UNIT 8" to the 98th line.
- For parse error in stdio.h:
update the original cdefs.h (under $IDIR/sslittle-na-sstrix/include/sys) with patched one (under $IDIR/gcc-2.7.2.3/patched/sys)
copy files "libc.a" and "crt0.o" $IDIR/sslittle-na-sstrix/lib/ to $IDIR/lib/
- Edit line 60 of protoize.c, and replace “#include <varargs.h>” with “#include <stdarg.h>”
- If you encoutered a “buffer overflow”, download the following files and put them in $IDIR/sslittle-na-sstrix/bin:
- http://www.ict.kth.se/courses/IS2202/ar
- http://www.ict.kth.se/courses/IS2202/ranlib
- do all above, then RUN <make LANGUAGES="c c++" CFLAGS="-O3" CC="gcc"> again
Now, run:
$ make install LANGUAGES="c c++" CFLAGS="-O3" CC="gcc"
7. Verify
(1) First verify that simplesim is installed correctly.
cd $IDIR/simplesim-3.0
./sim-outorder tests-pisa/bin.little/test-math
If results are generated from this, simplesim is most likely installed correctly.
Next verify that the cross-compiler is working. Create a basic C program (like the "hello world" program), name
it test.c, and place it in a new directory called dev.
With that, Simple Scalar has been installed, along with its tools, utils, and compilers. Let’s now test compiling a new code and running it on top of simplescalar:
In a separate directory, create a new file, hello.c, that has the following code:
#include<stdio.h>
main()
{
printf("Hello World!\n");
}
then compile it using the following command:
$ $IDIR/bin/sslittle-na-sstrix-gcc –o hello hello.c
That should generate a file hello, which we will run over the simulator:
$ $IDIR/simplesim-3.0/sim-safe hello
In the output, you should be able to find the following:
sim: ** starting functional simulation **
Hello World!
If results are generated from this, the cross compiler is most likely installed correctly.
References
[1] SimpleScalar. SimpleSclar home page. [Online] [Cited: July 28, 2011.] http://www.simplescalar.com.
[2] Mats Brorsson. Simplescalar installation instructions. [Online PDF Document] [Cited: July 28, 2011.] http://www.ann.ece.ufl.edu/courses/eel5764_10fal/project/1.36445-Simplescalar-installation-instructios.pdf
[3] Dr. Narahari. SimpleScalar Install Guide.[Online Document] [Cited: July 28, 2011.] http://www.seas.gwu.edu/~cheng/211/Projects/SimpleScalar/simplescalar-ubuntu-install.txt