simplescalar安装手册

10 篇文章 0 订阅
9 篇文章 0 订阅

转自http://www.igoy.in/simplescalar-installation-made-simple/


SIMPLESCALAR INSTALLATION MADE SIMPLE

Preface

The following text describes the procedure of installation of Simple Scalar on Linux distro – Ubuntu. It was tested on Ubuntu 9.04 by me, and 8.10. The sources used while writing the post have been listed at the bottom and they hold the highest credit.

Update:
[September 23rd 2009] – It has been tested on Redhat too with the exception of omitting/avoiding Error  #1 of GCC Cross Compiler installation
[August 14th 2011] – Check the video tutorial for Installation of SimpleScalar.

[September 25th 2012] – Removed Error #1 of GCC (September 2009 update. No need to do that) Checked on Ubuntu 11.04 & 12.04. If you run into errors feel free to ping me via contact page. I WILL do my best to assist you via TeamViewer or Join.me

Necessary Files

Download the necessary Source code files.

(Just for precaution, I’ve uploaded to my web-host in case the actual source is not available. The link igoY.in directs to my host space)

Simpletools-2v0.tgz – igoY.in | Simplescalar.com

Simplesim-3v0d.tar.gz – igoY.in | Simplescalar.com

Simpleutils-990811.tar.gz – igoY.in | Simplescalar.com

Gcc-2.7.2.3.ss.tar.gz – igoY.in

Setting up environment

Open up the terminal and type

1 uname -a

You will get to know your kernel version and the type of linux installed (i386/i686)

Depending on that change the Host id below as either
HOST=i686-pc-linux or HOST=i386-pc-linux

1 export HOST=FROM_ABOVE_OPTION
2 export IDIR=/home/YOUR_USER_NAME/simplescalar
3 export TARGET=sslittle-na-sstrix

(If you use tcsh or the like, the only difference should be in how environment variables are set.)

Create the directory “simplescalar” under your home directory and copy all the four tar files into it. To do so, use the following commands.

1 mkdir $IDIR
2 cd $IDIR

Make sure you have installed the following packages

  • flex
  • bison
  • build-essential

You can use the command “sudo apt-get install <PACKAGE_NAME>” to retrieve and install these packages.

Installing Simple tools

Just un-pack the package file, and remove the old gcc folder. To do so, use:

1 cd $IDIR
2 tar xzvf simpletools-2v0.tgz
3 rm -rf gcc-2.6.3

Installing SimpleUtils

First un-pack the package file. To do so, use:

1 tar xzvf simpleutils-990811.tar.gz
2 cd simpleutils-990811

Before building the code, you need to fix some sources of errors. In directory ld find file ldlex.l and replace all instances of
yy_current_buffer with YY_CURRENT_BUFFER.

You may either do it manually by opening the respected file and renaming it or to make it simple just type this code

1 find . -type f -print0 | xargs -0 sed -i -e's,yy_current_buffer,YY_CURRENT_BUFFER,g'
1 $ ./configure –host=$HOST –target=$TARGET –with-gnu-as –with-gnu-ld –prefix=$IDIR
2 make
3 make install

Installing Simulator

Un-pack the simulator package.

1 cd $IDIR
2 tar xzvf simplesim-3v0d.tgz
3 cd simplesim-3.0
4 make config-pisa
5 make

You may test the installation of simplesim by

1 $ ./sim-safe tests/bin.little/test-math

Installing GCC Cross-Compiler

This is the important step where most of the newbies (including me) are/were struggling. So please follow these steps carefully.

1 cd $IDIR
2 tar xzvf gcc-2.7.2.3.ss.tar.gz
3 cd gcc-2.7.2.3
4 exportPATH=$PATH:/home/YOUR_USER_NAME/simplescalar/sslittle-na-sstrix/bin
5 $ ./configure –host=$HOST –target=$TARGET –with-gnu-as –with-gnu-ld –prefix=$IDIR

Now before you proceed ahead, there are quite a few corrections that have to be made in some files:

1.) Lets start encountering our errors. We begin by issueing make command

1 make

2.) Edit line 60 of protoize.c, and replace

#include <varargs.h> with #include <stdarg.h>

Todo so you can use command

1 chmod +w protoize.c
2 $ gedit protoize.c

3.) Edit obstack.h at line 341 and change

*((void **)__o->next_free)++=((void *)datum);  

with

*((void **)__o->next_free++)=((void *)datum);

To do so you can use the following command

1 chmod +w obstack.h
2 $ gedit obstack.h

4.) Copy the patched files located in the patched directory to avoid some parse errors while compiling. To do so use the following command.

1 cp ./patched/sys/cdefs.h ../sslittle-na-sstrix/include/sys/cdefs.h
2 cp ../sslittle-na-sstrix/lib/libc.a ../lib/
3 cp ../sslittle-na-sstrix/lib/crt0.o ../lib/

*If you dont find the patched directory in your browser, you probably didnt unrar it properly. Again unrar the GCC tar file “at a different location” (say your Desktop) and copy from it.

5.) *** Crucial Step*** Download this file, un-tar it and place its contents .i.e ar & ranlib in $IDIR/sslittle-na-sstrix/bin – FILE

You would also want to confirm that these files have “execution & write permission” You can do so by

1 $ cd $IDIR/sslittle-na-sstrix/bin
2 ls -al

If you see each file of this folder with write(w) & execution(x) permission then you are ready to go further. If not then you have to assign them the permission by using

chmod +w <filename>
chmod +x <filename>

1 make

Again you will face few errors

1.) Now you will get many insn-output.c errors. To solve this you need to add line breaks (‘’) after each of the three FIXME (line 675, 750 and 823) in the insn-output.c
To open this file, use

1 $ gedit insn-output.c
2 make

2.) In objc/sendmsg.c, add the following code at line 35

#define STRUCT_VALUE 0
1 cd $IDIR/gcc-2.7.2.3/objc
2 chmod +w sendmsg.c
3 $ gedit sendmsg.c
4 cd ..
5 make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"

3.) The last make command will lead to an error message which requires you to edit cxxmain.c file

To solve this you need to remove lines 2978-2979 in file cxxmain.c .i.e Remove the following lines

char * malloc ();
char * realloc ();

To do so, use this command.

1 chmod +w cxxmain.c
2 $ gedit cxxmain.c

Now cross your fingers, because we are about to execute the final error free make command.

1 make LANGUAGES="c c++" CFLAGS="-O" CC="gcc"
2 make install  LANGUAGES="c c++" CFLAGS="-O" CC="gcc"

Testing

To test the simulator use these commands

1 clear
2 cd $IDIR
3 $ gedit hello.c

Now in Gedit you can write your program like this (You may modify it)

[c]
#include<stdio.h>
main (void)
{
printf(“My name is Yogesh Mhatre.”);
}
[/c]

Once you are done writing the code, use the following command to test it.

1 $ $IDIR/bin/sslittle-na-sstrix-gcc -o hello hello.c
2 $ $IDIR/simplesim-3.0/sim-safe hello

You would “hopefully” get an output similar to this

01 sim: ** starting functional simulation **
02 My name is Yogesh Mhatre.
03
04 sim: ** simulation statistics **
05 sim_num_insn                   9242 # total number of instructions executed
06 sim_num_refs                   4328 # total number of loads and stores executed
07 sim_elapsed_time                  1 # total simulation time in seconds
08 sim_inst_rate             9242.0000 # simulation speed (in insts/sec)
09 ld_text_base             0×00400000 # program text (code) segment base
10 ld_text_size                  71968 # program text (code) size in bytes
11 ld_data_base             0×10000000 # program initialized data segment base
12 ld_data_size                   8528 # program init’ed `.data’ and uninit’ed `.bss’ size in bytes
13 ld_stack_base            0×7fffc000 # program stack segment base (highest address in stack)
14 ld_stack_size                 16384 # program initial stack size
15 ld_prog_entry            0×00400140 # program entry point (initial PC)
16 ld_environ_base          0×7fff8000 # program environment base address address
17 ld_target_big_endian              0 # target executable endian-ness, non-zero if big endian
18 mem.page_count                   26 # total number of pages allocated
19 mem.page_mem                   104k # total size of memory pages allocated
20 mem.ptab_misses                  26 # total first level page table misses
21 mem.ptab_accesses            495046 # total page table accesses
22 mem.ptab_miss_rate           0.0001 # first level page table miss rate

Thats said. You may scream now. “Whoopiee”

Good Luck! (Now wake me up when september ends)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值