From a875779284f53a9a632aa24e5bd6d5c5465cb5ec Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Fri, 12 Oct 2018 22:16:27 +0100 Subject: Add systemc helloworld --- md/writeup/systemc_hello_world.md | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 md/writeup/systemc_hello_world.md (limited to 'md/writeup') diff --git a/md/writeup/systemc_hello_world.md b/md/writeup/systemc_hello_world.md new file mode 100644 index 0000000..b832d2e --- /dev/null +++ b/md/writeup/systemc_hello_world.md @@ -0,0 +1,72 @@ +title: SystemC hello world +keywords:c,macro,c++,systemc,HDL + +# SystemC hello world + +Miniaml example how to run SystemC without installation + +## Compiling SystemC + +Downloadin and compiling systemc framework + +```bash +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. + +```bash +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 +``` + +```c +#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 + +```bash +./hello_world +``` + +output of this example is + +```bash + 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](http://www.accellera.org/downloads/standards/systemc) +2. [http://cfs-vision.com/systemc-tutorial/](http://cfs-vision.com/systemc-tutorial/) -- cgit v1.2.3