Getting Started with SystemC

Santosh

2013/04/20

Categories: SystemC Tags: SystemC

SystemC is a set of C++ libraries, which enables a designer to perform cuncurrent simulation of system level model. It is used for Electronic System Level design and Transaction Level Modelling(TLM). In this article we will discuss the setup of SystemC in an Ubuntu 12.04 Machine and executing our first Hello World! program.

sudo mkdir /usr/local/systemc230

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

Open your favourite text editor and enter the following program:

 // All systemc modules should include systemc.h header file
#include <systemc.h>
// Hello_world is module name
SC_MODULE (hello_world) {
  SC_CTOR (hello_world) {
    // Nothing in constructor
  }
  void say_hello() {
    //Print "Hello World" to the console.
    cout << "Hello World.\n";
  }
};

// sc_main in top level function like in C++ main
int sc_main(int argc, char* argv[]) {
  hello_world hello("HELLO");
  // Print the hello world
  hello.say_hello();
  return(0);
}

Save the file as hello.cpp. Use following command to export a variable SYSTEMC_HOME.

export SYSTEMC_HOME=/usr/local/systemc230/

Now you can use following command to compile the program:

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

Once the program is compiled type following to run your program

./hello

and you should get output

SystemC 2.3.0-ASI --- Aug 12 2012 09:27:22
Copyright (c) 1996-2012 by all Contributors,
ALL RIGHTS RESERVED

Hello World.

If you get above output, you have successfully completed the setup and run your first SystemC program.

Note: This set of instruction has been tested with Linux Mint 14 which is derivative of Ubuntu Linux. In Ubuntu 12.10, user might need to install g++ before going through these steps.