(原創) 第一个SystemC的程序:Hello World (C/C++) (SystemC) (IC Design)
1// All systemc modules should include systemc.h header file
2#include "systemc.h"
3// Hello_world is module name
4SC_MODULE (HelloWorld) {
5 SC_CTOR (HelloWorld) {
6 // Nothing in constructor
7 }
8 void sayHello() {
9 //Print "Hello World" to the console.
10 std::cout << "Hello World." << std::endl;
11 }
12};
13
14// sc_main in top level function like in C++ main
15int sc_main(int argc, char* argv[]) {
16 HelloWorld myHelloWorld("HELLO");
17 // Print the hello world
18 myHelloWorld.sayHello();
19
20 return 0;
21}
22
23
2#include "systemc.h"
3// Hello_world is module name
4SC_MODULE (HelloWorld) {
5 SC_CTOR (HelloWorld) {
6 // Nothing in constructor
7 }
8 void sayHello() {
9 //Print "Hello World" to the console.
10 std::cout << "Hello World." << std::endl;
11 }
12};
13
14// sc_main in top level function like in C++ main
15int sc_main(int argc, char* argv[]) {
16 HelloWorld myHelloWorld("HELLO");
17 // Print the hello world
18 myHelloWorld.sayHello();
19
20 return 0;
21}
22
23