【技术】在Ubuntu12.04上安装SimpleScalar的方法
【技术】Install SimpleScalar on Ubuntu 12.04
1.在gedit(Ubuntu自带的文本编辑器)中加入以下代码:
NAME=Simplescalar
PACKAGE=simplescalar
TOOL=simpletools-2v0
UTIL=simpleutils
SIM=simplesim
sudo apt-get update
sudo apt-get install flex-old bison build-essential
cd
mkdir $NAME
cd $NAME
wget http://csrl.unt.edu/downloads/$PACKAGE.tgz
tar xvfz $PACKAGE.tgz
export CC="gcc"
export HOST=i686-unknown-linux
export TARGET=sslittle-na-sstrix
export IDIR=~/$NAME
cd ~/$NAME
tar xvfz $TOOL.tgz
rm -rf gcc-2.6.3
cd ~/$NAME
tar xvfz $UTIL-990811.tar.gz
cd $UTIL-990811
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
make CC=gcc
sudo make install CC=gcc
cd ~/$NAME
tar xvfz $SIM-3v0d.tgz
cd $SIM-3.0
make config-pisa
make CC=gcc
cd ~/$NAME
tar xvfz gcc-2.7.2.3.ss.tar.gz
cd ~/$NAME/gcc-2.7.2.3
export PATH=$PATH:$IDIR/simpleutils-990811/sslittle-na-sstrix/bin
./configure --host=$HOST --target=$TARGET --with-gnu-as --with-gnu-ld --prefix=$IDIR
make LANGUAGES="c c++" CFLASS=-O3 CC="gcc"
sed -i 's/return \"FIXME\\n/return \"FIXME\\n\\/g' ~/$NAME/gcc-2.7.2.3/insn-output.c
make LANGUAGES="c c++" CFLASS=-O3 CC="gcc"
wget http://www.ict.kth.se/courses/IS2202/ar
wget http://www.ict.kth.se/courses/IS2202/ranlib
chmod 700 ar
chmod 700 ranlib
sudo cp ar $IDIR/sslittle-na-sstrix/bin/ar
sudo cp ranlib $IDIR/sslittle-na-sstrix/bin/ranlib
rm ar
rm ranlib
chmod +w ~/$NAME/gcc-2.7.2.3/obstack.h
sed -i 's/next_free)++/next_free++)/g' ~/$NAME/gcc-2.7.2.3/obstack.h
make LANGUAGES="c c++" CFLASS=-O3 CC="gcc"
sed -i '98i\
' ~/$NAME/gcc-2.7.2.3/libgcc2.c
cp $IDIR/gcc-2.7.2.3/patched/sys/cdefs.h $IDIR/sslittle-na-sstrix/include/sys/cdefs.h
make LANGUAGES="c c++" CFLASS=-O3 CC="gcc"
make enquire CC=gcc
sudo make install LANGUAGES="c c++" CFLASS=-O3 CC="gcc" PATH=$PATH:~/$NAME/bin
exit 0
2.将以上代码保存成: SimpleScalar.build 文件,放在/home/Document文件夹中
3.在 Terminal 中运行:
cd
cd Document
source SimpleScalar.build
4.坐等安装完成。
5.验证方法:
假设有hello.c在你的simplescalar文件夹下:
~/simplescalar> $ bin/sslittle-na-sstrix-gcc hello.c
~/simplescalar> $ simplesim-3.0/sim-safe a.out
或者:
假设你的示例源文件hello.c在home文件夹,而simplescalar的gcc工具在simplescalar/bin/文件夹下,sim-safe工具在simplescalar/simplesim-3.0文件夹下,
那么,在当前位置为home 时(执行ls会看到hello.c),执行:/simplescalar/bin/sslittle-na-sstrix-gcc hello.c会在home文件夹下生成a.out的文件。再执行:/simplescalar/simplesim-3.0/sim-safe a.out会进行模拟仿真,并显示结果。
【演示视频】: