Saturday, December 8, 2012

Install SystemC 2.3.0 on Linux


1. Download SystemC source from Accellera.

2. Decompress the package using the command
tar -xvf systemc-2.3.0.tgz

3. Change to the top level directory systemc-2.3.0
$cd systemc-2.3.0

4. Make a directory  systemc-2.3.0 for installation in your /usr/local/ path.
$mkdir /usr/local/systemc-2.3.0

5. Make a directory “objdir” in the directory systemc-2.3.0
$mkdir objdir

6. Change to objdir
$cd objdir

7. now type:
export CXX=g++

8. Run configure from objdir:
../configure --prefix=/usr/local/systemc230

9. And then:
make

10. Install by typing command:
sudo make install

At this Point we are done with installation of SystemC 2.3.0. This version is packed with TLM package also. Here we can run our first Hello World! program.

Open your favourite "text editor" and enter the following program:


#include <systemc.h>

SC_MODULE (hello_world) {
  SC_CTOR (hello_world) {
  }

  void say_hello() {
    cout << "Hello World systemc-2.3.0.\n";
  }
};

int sc_main(int argc, char* argv[]) {
  hello_world hello("HELLO");
  hello.say_hello();
  return(0);
}


Save the file as hello.cpp

Use following command to export variable SYSTEMC_HOME.
export SYSTEMC_HOME=/usr/local/systemc230/

Now you can use following command to compile the program:

for 32-bit OS:
g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -Wl,-rpath=$SYSTEMC_HOME/lib-linux -o hello hello.cpp -lsystemc -lm

for 64-bit OS:
g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -o hello hello.cpp -lsystemc -lm

Once the program has compiled type following to run your program:
./hello

and you should get output:

SystemC 2.3.0-ASI --- Dec 8 2012 20:50:24
Copyright (c) 1996-2012 by all Contributors,
ALL RIGHTS RESERVED


Hello World system 2.3.