Friday, October 15, 2010

Installing SCoPE and M3P plugin (XML I/O plug-in) for M3Explorer on Ubuntu 10.10

You can download everything you need (except systemc 2.20) from http://www.teisa.unican.es/gim/en/scope/scope_web/scope_download.php download SCoPE 1.1.5 and XML I/O plug-in(Compatible with SCoPE 1.1.5) 1.0.5

You can obtain SystemC 2.2.0 from http://www.systemc.org/downloads/standards/
Extract everything in your home folder. You should have the following directories:

systemc-2.2.0
SCoPE-v1.1.5
m3p-v1.0.5
Installing the required libraries
* GNU C/C++ toolchain: gcc/g++ (v4.x), make
* Bison and flex tools (as riquired by SCoPE)
* zlib-devel library

Installing SystemC

create a file called systemc.patch and add the following code:
diff -Nurd systemc-2.2.0/Makefile.am systemc-2.2.0-ubuntu9.04/Makefile.am
--- systemc-2.2.0/Makefile.am 2006-12-15 21:31:28.000000000 +0100
+++ systemc-2.2.0-ubuntu9.04/Makefile.am 2009-10-17 15:25:42.000000000 +0200
@@ -32,8 +32,8 @@
SUBDIRS = \
src \
- examples \
.
+# examples
INST_FILES = \
AUTHORS \
diff -Nurd systemc-2.2.0/src/sysc/utils/sc_utils_ids.cpp systemc-2.2.0-ubuntu9.04/src/sysc/utils/sc_utils_ids.cpp
--- systemc-2.2.0/src/sysc/utils/sc_utils_ids.cpp 2006-12-15 21:31:39.000000000 +0100
+++ systemc-2.2.0-ubuntu9.04/src/sysc/utils/sc_utils_ids.cpp 2009-10-17 15:26:54.000000000 +0200
@@ -58,6 +58,8 @@
// the source.
//
+#include
+#include
#include "sysc/utils/sc_report.h"

Save this file in the systemc-2.2.0 folder
Run this command from a terminal:

cd systemc-2.2.0
patch -p1 < ../systemc.patch

Then compile SystemC:

aclocal
automake
autoconf
./configure
make
make install

Installing SCoPE 1.15
Set the environment variables:
gedit ~/.bashrc

add at the end (replace horicul with your username):

export CXX=g++
export SYSTEMC=/home/horicul/systemc-2.2.0
export SCOPE_HOME=/home/horicul/SCoPE-v1.1.5
export PATH=$PATH:/home/horicul/SCoPE-v1.1.5/bin
export SCOPE_XML_PLUGIN=/home/horicul/m3p-v1.0.5
export LD_LIBRARY_PATH=/home/horicul/m3p-v1.0.5/build

Open a terminal and go to your SCoPE directory then run:
make all
If it crashes do the following (and then rerun make all):
copy from:
/home/horicul/SCoPE-v1.1.5/utils/Compiler
the file:
scope-g++
to:
/home/horicul/SCoPE-v1.1.5/bin

copy from:
/home/horicul/SCoPE-v1.1.5/utils/OpCost
the file:
opcost
to:
/home/horicul/SCoPE-v1.1.5/bin

Even if it does not crash do the steps above

Installing M3P
Navigate to your m3p folder and in src/arp_lib/Makefile add
ARP_HOME = /home/horicul/sim/m3p-v1.0.5/src/arp_lib/
on the first line (repalce accordingly with your path)
Open a terminal and navigate to the m3p folder then run:

make

Go to Synaptic and install gcc-4.1 and cpp-4.1
Open a terminal:

cd /usr/bin
sudo rm cpp gcc
sudo ln -s gcc-4.1 gcc
sudo ln -s cpp-4.1 cpp

Now you have replaced your gcc.
Open a terminal and navigate to the m3p folder then run:

make examples
make run

If you wish to return to your previous gcc version run:

cd /usr/bin
sudo rm cpp gcc g++
sudo ln -s g++-4.4 g++
sudo ln -s gcc-4.4 gcc
sudo ln -s cpp-4.4 cpp

How to change your gcc compiler in Ubuntu 10.10 32Bit to another gcc version

Ubuntu 10.10 comes by default with gcc 4.4 (at least when this post was written)
You might need to change the gcc to an older version for whatever reasons (installing SCoPE simulator for example)
Go to Synaptic and install the desired gcc version ( gcc-4.3, gcc-4.5, etc.) also install cpp and g++ for the same version. If you need gcc-4.1 skip the g++ (I did not find it)
After installing these packages open a terminal and run the following commands (replace 4.4 to your desired version of gcc - with the code below you go back to the original settings):

cd /usr/bin
sudo rm cpp gcc g++
sudo ln -s g++-4.4 g++
sudo ln -s gcc-4.4 gcc
sudo ln -s cpp-4.4 cpp

If you want to install gcc-4.1 do this:

cd /usr/bin
sudo rm cpp gcc
sudo ln -s gcc-4.1 gcc
sudo ln -s cpp-4.1 cpp

This works for Ubuntu 10.10 on 32 bits. You might have to do other steps on 64 bits. See this post about this