I have recently installed Simplescalar in my Laptop which has Ubuntu 10.04 (gcc version: 4.4.3). I am writing down the steps which I followed in the format of instructions. Also I am providing links to some references which I had gone through during the process of installation. Hope this would be of some help!!
Installation Steps
(It should be noted that the complete installation is done from terminal using command-line instructions. The terminal should not be closed until all the steps upto 6 are complete)
Step-1 (Making the installation directory ready)
Create the folder which is going to be your installation directory for Simplescalar. In my case it was: /home/debdeepece/simplescalar. Copy all the files into it. Then unzip all the compressed files should be unzipped. Delete the folder gcc-2.6.3 as it will not be needed. Finally the installation directory should contain the following folders:
f2c-1994.09.27, gcc-2.7.2.3, glibc-1.09, simplesim-3.0, simpleutils-990811, ssbig-na-sstrix, sslittle-na-sstrix
along with the files ar and ranlib.
You can also try using the folder I prepared before installation which contains all the necessary files, without following the previous download, folder-creation, unzipping and deletion steps. I am uploading the folder in two parts:
Part-1
Part-2
You can use Hjsplit for joining the two parts, in order to get the complete zip file.
Step-2 (Dependencies)
The required dependencies are to be installed. You can simply do:
sudo apt-get install bison flex build-essential
Step-3 (Setting up Environment variables from terminal)
export IDIR=<YOUR_INSTALLATION_DIR>
export HOST=i686-pc-linux
export TARGET=sslittle-na-sstrix
Step-4 (Install SimpleUtils)
Go to the directory simpleutils-990811. Find yy_current_buffer in the file ld/ldlex.l & replace it with YY_CURRENT_BUFFER.
Then carry out the following instructions in the terminal:
cd $IDIR/simpleutils-990811
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
make CFLAGS=-O
make install
Step-5 (Install the Simplescalar simulators like sim-safe, sim-outorder etc)
cd $IDIR/simplesim-3.0
make config-pisa
make
This should work with no errors. You can test the installation by executing sim-safe from terminal:
./sim-safe tests/bin.little/test-fmath
It produced an output like this in my computer.
Step-6 (Installing the gcc cross-compiler)
This is the trickiest part in the installation. The objective is to generate the cross-compiler sslittle-na-sstrix-gcc in the directory $IDIR/bin/ which would be used instead of standard C-compilers to generate executables from C-programs. This cross-compiled executables can then be analyzed accordingly using the simplescalar simulators.
Let us proceed:
cd $IDIR/gcc-2.7.2.3
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
chmod -R +w .
(Don’t miss the final dot in the last instruction)
First you must fix the following errors in the source:
i) In line#60 of file protoize.c, replace #include <varargs.h> with #include<stdarg.h>
ii) In line#341 of file obstack.h, replace:
*((void **)__o->next_free)++ = ((void *)datum);\
with
*((void **)__o->next_free++)=((void *)datum;\
iii) cp ./patched/sys/cdefs.h ../sslittle-na-sstrix/include/sys/cdefs.h
iv) cp ../sslittle-na-sstrix/lib/libc.a ../lib/
v) cp ../sslittle-na-sstrix/lib/crt0.o ../lib/
vi) Copy files ar & ranlib into $IDIR/sslittle-na-sstrix/bin.
vii) Also change the permission of ar and ranlib by allowing execution of these files as program.
Now execute:
make LANGUAGES=c CFLAGS=-O CC="gcc -m32"
This will produce an error regarding insn-output.c. To fix it, Insert \ at the end of lines 675, 750 & 823 of file insn-output.c. The lines are like "return "FIXME\n\".
Then again execute:
make LANGUAGES=c CFLAGS=-O CC="gcc -m32"
[Note: If you get an error regarding libgcc1.null at this point please check that you have done (vii). I am mentioning this again because I didn’t do it and got a similar error. Complete (vii) and again run make LANGUAGES=c CFLAGS=-O CC="gcc -m32".]
This time there should be an error regarding cxxmain.o. Comment out lines 2978-2979 in file cxxmain.c. After fixing it, you have to run:
make LANGUAGES=c CFLAGS=-O CC="gcc -m32"
for the final time. This should be completed without any errors. Then execute the following commands to complete installation:
make enquire
$IDIR/simplesim-3.0/sim-safe ./enquire -f > float.h-cross
make LANGUAGES=c CFLAGS=-O CC="gcc -m32" install
In my case this completed the gcc cross-compiler installation.
Checking the Operation of Simplescalar
In a new directory, create a simple hello world C program say hello.c:
#include<stdio.h>
int main()
{
printf(" \n Hello, World! \n");
return 0;
}
Compile it using the cross-compiler with the following command :
$IDIR/bin/sslittle-na-sstrix-gcc -o hello hello.c
Run it using a simulator:
$IDIR/simplesim-3.0/sim-safe hello
This will produce the following output.
Some References (For more queries regarding installation):
1. http://www.cse.iitd.ernet.in/~drajeswari/ss_installn.html
2. http://www.ann.ece.ufl.edu/courses/eel5764_10fal/project/ubuntu.html
3. http://www.igoy.in/simplescalar-installation-made-simple/