Hello world

A simple example will get us started. We use a classical "Hello, world'' example, which will do nothing meaningful except printing a text string. The code for the example is shown in Figure 1.

#include "systemc"
#include "tlm.h"

#include <iostream>

int sc_main(int argc, char* argv[])
{
    std::cout << "Hello, world" << std::endl; 
    sc_core::sc_start();
    return 0;
}

Figure 1. A hello world example in SystemC.

This the SystemC-TLM view - other views are VHDL - Verilog

The code in Figure 1 starts with three include directives. The first and the second include directive include functionality for SystemC and TLM, respectively. The third include directive includes the iostream header, which contains functionality for printing text.

The code in Figure 1 contains a function named sc_main. The function starts with a statement that prints a string. The simulation is then started, by calling the function sc_core::sc_start, and after that the value zero is returned.

You can read about in SystemC and TLM in Wikipedia, and at other places, such as Doulos, who provides this SystemC Guide.