blob: b832d2e913ae791f0f7b5cd935b98bd073eff0bd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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/)
|