SystemC hello world

Miniaml example how to run SystemC without installation

Compiling SystemC

Downloadin and compiling systemc framework

1
2
3
4
curl http://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.2.tar.gz --output systemc-2.3.2.tar.gz
tar -xvf systemc-2.3.2.tar.gz
cd systemc-2.3.2/
./configure

Prepare Makefile

After compilation of systemc libraries we can create "Hello World" example.

1
2
3
4
5
6
7
SYSTEMC_PATH=/home/user/downloads/source/systemc/systemc-2.3.2
SYSTEMC_INC=$(SYSTEMC_PATH)/src
SYSTEMC_LIB=$(SYSTEMC_PATH)/src/.libs

make:
	g++ hello_world.cpp -I$(SYSTEMC_INC) -L$(SYSTEMC_LIB) -Wl,-rpath=$(SYSTEMC_LIB)\
		-o hello_world -lsystemc -lm
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include "systemc.h"

SC_MODULE (hello_world) {
	SC_CTOR(hello_world) {

	}

	void say_hello() {
		cout << "Hello world\n";
	}
};

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

after compilation try to run

1
./hello_world

output of this example is

1
2
3
4
SystemC 2.3.2-Accellera --- Jul 13 2018 19:20:02
        Copyright (c) 1996-2017 by all Contributors,
        ALL RIGHTS RESERVED
Hello world

Links

  1. http://www.accellera.org/downloads/standards/systemc
  2. http://cfs-vision.com/systemc-tutorial/