Skip to main content

What and Why SystemC

Published on

  • embedded system
  • informatic
  • systemc
  • electronics
  • c/c++

A beginner-friendly engineering guide to modeling concurrent hardware, simulated physical time, and hardware-software interactions in standard C++.

Table of Contents

  1. Why Embedded Engineers Need Virtual Hardware

  2. What Is SystemC?

  3. Why Use SystemC in Embedded Systems?

  4. Installing SystemC on Linux

  5. Hands-On Example: Modeling an Embedded Thermal Monitor

  6. Conclusion

  7. References


1. Why Embedded Engineers Need Virtual Hardware

An embedded system is a dedicated computing unit designed to perform a specific real-world task—often under strict timing, memory, and power constraints. From automotive anti-lock braking controllers and medical wearables to industrial sensors and smart thermostats, every embedded product combines two tightly coupled worlds: custom digital hardware (processors, timers, buses, and sensors) and embedded software (firmware, device drivers, and real-time operating systems).

Traditionally, this tight coupling created a costly bottleneck. Designing and fabricating a custom System-on-Chip (SoC) or printed circuit board takes many months. If firmware engineers must wait until physical chips arrive from the factory before testing a single line of driver code, discovering a hardware-software integration flaw late in the schedule can force an expensive hardware redesign. Modern engineering teams solve this problem through virtual prototyping: building an executable software model of the hardware so architects and firmware developers can design, test, and debug the complete system on a standard computer long before physical silicon exists. This is the exact problem SystemC was created to solve.


2. What Is SystemC?

SystemC is an open-source C++ class library and discrete-event simulation kernel used for electronic system-level (ESL) modeling, hardware-software co-design, and architectural verification. Originally introduced in 1999 by the Open SystemC Initiative (now part of the Accellera Systems Initiative), SystemC is not merely an informal convention—it is an official international standard maintained by the IEEE as IEEE Std 1666 (most recently revised in IEEE Std 1666-2023, which adopts modern C++17 as its baseline).

Because SystemC is implemented purely as a standard C++ library rather than a standalone proprietary language, you do not need a specialized hardware compiler to run it. Any compliant C++ compiler—such as GCC or Clang—compiles your SystemC hardware-software model directly into a native executable simulator.

2.1 SystemC vs. Embedded C/C++: A Common Misconception

If you are new to embedded systems, it is vital to distinguish between Embedded C/C++ and SystemC:

  • Embedded C/C++ (Target Firmware): Cross-compiled into machine code and flashed directly onto a physical microcontroller (such as an STM32, AVR, or ESP32) to run inside the final product.

  • SystemC (System Modeling & Simulation): Compiled and executed on a workstation or server to simulate the hardware components themselves—clocks, signal wires, memory buses, sensors, and custom accelerators—working alongside the firmware.

Why can we not model digital hardware easily in plain C++ alone? Standard C++ executes instructions sequentially (one statement after another) and has no built-in notion of hardware clock cycles. Real digital circuits, by contrast, operate concurrently—dozens of independent hardware blocks react in parallel at the exact same nanosecond—and depend on physical time. SystemC extends C++ with both cooperative hardware concurrency and a precise simulated timeline.

2.2 Core Architectural Building Blocks

Every SystemC model is assembled from five foundational concepts provided under the sc_core namespace:

  • Modules (SC_MODULE): Self-contained building blocks representing hardware or system components (such as a timer, sensor interface, or bus router) that can be nested hierarchically.

  • Ports and Channels (sc_in, sc_out, sc_signal, sc_fifo): Typed interfaces and communication wires or queues that connect modules cleanly without hardcoding internal pointers between them.

  • Concurrent Processes (SC_METHOD and SC_THREAD): Member functions scheduled by the simulation kernel to mimic parallel hardware execution. An SC_METHOD triggers on events and returns immediately without blocking, whereas an SC_THREAD runs as a coroutine that can suspend itself across simulated time using wait().

  • Simulated Time and Events (sc_time and sc_event): A virtual hardware clock tracking units from femtoseconds (SC_FS) up to seconds (SC_SEC), completely decoupled from how fast your host CPU runs.

  • Simulation Entry Point (sc_main and sc_start): The SystemC library defines the underlying C++ main() function to initialize the kernel and then calls your sc_main() function to wire modules together and launch simulation via sc_start().

Before diving deeper, look at how concise a complete timed hardware module looks in modern SystemC:

heartbeat.cpp — Minimal SystemC Module with Simulated Time
#include <iostream>
#include <systemc>

using namespace sc_core;

SC_MODULE(Heartbeat) {
    SC_CTOR(Heartbeat) {
        SC_THREAD(run);               // Register a concurrent hardware thread
    }

    void run() {
        while (true) {
            std::cout << "LED toggle at " << sc_time_stamp() << '\n';
            wait(500, SC_MS);         // Pause this module for 500 ms of simulated time
        }
    }
};

int sc_main(int, char*[]) {
    Heartbeat led("led");             // Instantiate hardware block
    sc_start(1500, SC_MS);            // Simulate 1.5 seconds of hardware time
    return 0;
}

When compiled and executed, this program finishes in less than a millisecond of real wall-clock time on your computer, yet its internal simulation clock accurately steps through 0 s, 500 ms, and 1 s of virtual hardware time.


3. Why Use SystemC in Embedded Systems?

3.1 Abstraction Levels: Why SystemC Simulates So Fast

Digital hardware engineers traditionally design circuits using Hardware Description Languages (HDLs) such as VHDL, Verilog, or SystemVerilog at the Register-Transfer Level (RTL). RTL describes every individual wire toggle and clock edge—which is indispensable when synthesizing physical transistors, but far too detailed when you want to boot an operating system or test high-level firmware. Simulating just a few seconds of an embedded processor at full RTL detail can take hours.

A common misconception is that SystemC is faster than VHDL or Verilog simply because SystemC uses an event-driven simulation kernel. In reality, VHDL and Verilog simulators also use discrete-event kernels. SystemC achieves orders-of-magnitude higher simulation speeds—often 100× to 1,000× faster than RTL—because it enables Transaction-Level Modeling (TLM-2.0), standardized directly inside IEEE Std 1666. Instead of simulating dozens of individual address, data, and handshake pin transitions on a bus clock-by-clock, a TLM model transfers an entire memory packet in a single C++ function call (b_transport) while still annotating realistic timing delays.

Abstraction Level Typical Language Timing & Communication Detail Primary Embedded Use Case
Register-Transfer Level (RTL) Verilog, VHDL, SystemVerilog Cycle-accurate and pin-accurate (every clock edge and wire) Silicon synthesis and gate-level hardware verification
Approximately-Timed TLM SystemC + TLM-2.0 Multi-phase bus transactions with contention and latency SoC bus architecture, arbitration, and performance analysis
Loosely-Timed TLM SystemC + TLM-2.0 Single-call transactions (b_transport) with coarse timing Virtual prototypes and early firmware/OS development

3.2 Key Applications in the Embedded Lifecycle

  1. Virtual Prototyping ("Shift-Left" Firmware Development): Firmware engineers write and debug device drivers, interrupt handlers, and RTOS tasks against a SystemC virtual platform months before physical boards arrive.

  2. Design Space Exploration: Architects compare candidate system configurations—such as cache sizes, DMA buffer depths, or bus topologies—under realistic workloads to optimize latency and energy efficiency early.

  3. Hardware-Software Partitioning: Because both hardware models and software algorithms are written in C++, teams can profile compute-intensive workloads (such as signal filtering, motor control, or encryption) and decide which parts belong in CPU firmware versus dedicated hardware accelerators.

  4. Pre-Silicon Verification (Golden Reference Models): Verification teams build clean behavioral SystemC models to serve as trusted reference outputs against which complex RTL Verilog/VHDL designs are checked automatically.

  5. High-Level Synthesis (HLS): Specialized EDA tools can translate synthesizable subsets of algorithmic SystemC/C++ code into RTL hardware descriptions for FPGAs and custom ASICs.


4. Installing SystemC on Linux

Linux is the primary operating system for embedded toolchains and Electronic Design Automation. Below are two reliable ways to set up SystemC on Linux: a one-step package installation for quick experimentation, and an official source build using CMake for the latest SystemC 3.0+ (IEEE Std 1666-2023) release, which requires a C++17-capable compiler (such as GCC 9.3+ or Clang 13+) and CMake 3.16+.

4.1 Option A: Quick Install via Package Manager (Ubuntu / Debian)

On modern Ubuntu and Debian distributions, the Accellera SystemC development headers and shared library can be installed directly from the system repositories:

Install SystemC via APT (Ubuntu/Debian)
sudo apt update
sudo apt install -y build-essential cmake libsystemc-dev

4.2 Option B: Building SystemC 3.0+ from Source with CMake

If your distribution packages an older release or you want the latest upstream features from Accellera, build SystemC from source using CMake. Passing -DCMAKE_INSTALL_LIBDIR=lib keeps the installed library path consistent across different Linux distributions:

Build and Install SystemC 3.0.2 from Source
# 1. Install build prerequisites
sudo apt update && sudo apt install -y build-essential cmake git

# 2. Clone the official Accellera SystemC repository (release 3.0.2)
git clone --branch 3.0.2 --depth 1 https://github.com/accellera-official/systemc.git
cd systemc

# 3. Configure an out-of-source CMake build (C++17 required for SystemC 3.0+)
cmake -B build \
  -DCMAKE_CXX_STANDARD=17 \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$HOME/systemc" \
  -DCMAKE_INSTALL_LIBDIR=lib

# 4. Compile in parallel and install to ~/systemc
cmake --build build -j"$(nproc)"
cmake --install build

If you installed SystemC into $HOME/systemc (Option B) and plan to compile programs directly with g++ on the command line, add the installation paths to your shell profile:

Optional: Configure SYSTEMC_HOME in ~/.bashrc
echo 'export SYSTEMC_HOME="$HOME/systemc"' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH="$SYSTEMC_HOME/lib:${LD_LIBRARY_PATH}"' >> ~/.bashrc
source ~/.bashrc

5. Hands-On Example: Modeling an Embedded Thermal Monitor

To see how SystemC models hardware-software interaction in practice, let us build a simplified thermal protection subsystem—similar to what monitors battery cells in an electric vehicle or power supply:

  • Sensor Peripheral (TemperatureSensor): Uses an SC_THREAD to sample temperature every 10 ms of simulated time and drive the value onto an output port (sc_out<int>).

  • Embedded Controller (CoolingController): Uses an event-triggered SC_METHOD sensitive to incoming sensor updates (sc_in<int>), switching a cooling fan control signal (sc_out<bool>) on whenever the temperature reaches 75 °C or higher.

  • Top-Level Interconnect (sc_main): Instantiates both modules, connects their ports with sc_signal channels, and runs the simulation for 60 ms.

thermal_monitor.cpp
#include <iostream>
#include <systemc>

using namespace sc_core;

// 1. Hardware Peripheral Module: Periodic Temperature Sensor
SC_MODULE(TemperatureSensor) {
    sc_out<int> temp_out;

    SC_CTOR(TemperatureSensor) {
        SC_THREAD(sample_loop);
    }

    void sample_loop() {
        const int readings[] = {65, 72, 78, 81, 70};
        for (int temp : readings) {
            wait(10, SC_MS);          // Advance simulated time by 10 ms
            temp_out.write(temp);     // Drive new reading onto signal wire
        }
    }
};

// 2. Embedded Controller Module: Reacts to Sensor Updates
SC_MODULE(CoolingController) {
    sc_in<int>   temp_in;
    sc_out<bool> fan_enable;

    static constexpr int THRESHOLD_C = 75;

    SC_CTOR(CoolingController) {
        SC_METHOD(evaluate_temperature);
        sensitive << temp_in;         // Trigger whenever temp_in changes
        dont_initialize();            // Wait for the first real sensor event
    }

    void evaluate_temperature() {
        int current_temp = temp_in.read();
        bool turn_on = (current_temp >= THRESHOLD_C);
        fan_enable.write(turn_on);

        std::cout << "[" << sc_time_stamp() << "] "
                  << "Temp: " << current_temp << " C -> Cooling Fan: "
                  << (turn_on ? "ON" : "OFF") << '\n';
    }
};

// 3. Top-Level Entry Point: Wire Modules and Start Simulation
int sc_main(int, char*[]) {
    sc_signal<int>  temp_wire;
    sc_signal<bool> fan_wire;

    TemperatureSensor sensor("sensor");
    CoolingController controller("controller");

    sensor.temp_out(temp_wire);
    controller.temp_in(temp_wire);
    controller.fan_enable(fan_wire);

    sc_start(60, SC_MS);              // Run simulation for 60 ms
    return 0;
}

5.1 Compiling and Running the Simulation

Save the code above as thermal_monitor.cpp alongside the following CMakeLists.txt, which works automatically with both the APT package (Option A) and a custom source installation (Option B):

CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(thermal_monitor LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(SystemCLanguage QUIET CONFIG)

add_executable(thermal_monitor thermal_monitor.cpp)

if(SystemCLanguage_FOUND)
    target_link_libraries(thermal_monitor PRIVATE SystemC::systemc)
else()
    target_link_libraries(thermal_monitor PRIVATE systemc)
endif()

Compile and execute the simulation using CMake (or directly with g++):

Build and Run the Simulation
# Build with CMake (append -DCMAKE_PREFIX_PATH="$HOME/systemc" if built from source)
cmake -B build && cmake --build build
./build/thermal_monitor

# Alternative: Compile directly in one command with g++
# For Option A (APT package):
g++ -std=c++17 -Wall -Wextra thermal_monitor.cpp -lsystemc -o thermal_monitor && ./thermal_monitor

# For Option B (Source build in $SYSTEMC_HOME):
# g++ -std=c++17 -Wall -Wextra -I"$SYSTEMC_HOME/include" -L"$SYSTEMC_HOME/lib" -Wl,-rpath,"$SYSTEMC_HOME/lib" thermal_monitor.cpp -lsystemc -o thermal_monitor && ./thermal_monitor

Running the executable produces the following timestamped simulation trace:

Simulation Output
        SystemC 3.0.2-Accellera --- Nov  5 2025 12:44:46
        Copyright (c) 1996-2025 by all Contributors,
        ALL RIGHTS RESERVED
[10 ms] Temp: 65 C -> Cooling Fan: OFF
[20 ms] Temp: 72 C -> Cooling Fan: OFF
[30 ms] Temp: 78 C -> Cooling Fan: ON
[40 ms] Temp: 81 C -> Cooling Fan: ON
[50 ms] Temp: 70 C -> Cooling Fan: OFF

Notice three essential hardware behaviors captured cleanly in fifty lines of standard C++:

  • Initialization Control: Calling dont_initialize() inside CoolingController prevents a premature check at time 0 s before the sensor produces its first reading at 10 ms.

  • Zero-Polling Concurrency: Unlike a busy-wait loop in sequential software, evaluate_temperature() consumes zero simulation effort until temp_wire actually changes value—mirroring a hardware comparator or interrupt line.

  • Decoupled Architecture: Neither module knows the other exists; both interact solely through typed ports bound to sc_signal channels inside sc_main(), making it straightforward to attach waveform tracing or replace the controller with real embedded firmware.


6. Conclusion

For newcomers to embedded systems, SystemC (IEEE Std 1666) bridges the gap between software engineering and digital hardware design. By augmenting standard C++ with hardware hierarchy, concurrent processes, typed communication channels, and simulated physical time, it empowers engineering teams to explore architectures, verify peripherals, and develop embedded firmware on fast virtual prototypes long before physical chips are manufactured.

Once you are comfortable building modular SC_MODULE designs like the thermal monitor above, natural next steps include recording signal waveforms to VCD files (sc_create_vcd_trace_file) for visual inspection in GTKWave, and exploring TLM-2.0 sockets to model memory-mapped processor buses at high speed.


7. References

  1. IEEE Standards Association & Accellera Systems Initiative. (2023). IEEE Standard for Standard SystemC Language Reference Manual (IEEE Std 1666-2023). Available via the IEEE GET Program at https://systemc.org/

  2. Accellera Systems Initiative. SystemC Standards and Proof-of-Concept Library Downloads. https://www.accellera.org/downloads/standards/systemc

  3. Accellera Systems Initiative. Official SystemC Open-Source Reference Implementation (GitHub Repository). https://github.com/accellera-official/systemc

  4. Black, D. C., Donovan, J., Bunton, B., & Keist, A. (2010). SystemC: From the Ground Up (2nd ed.). Springer. https://doi.org/10.1007/978-0-387-69958-5

  5. Grötker, T., Liao, S., Martin, G., & Swan, S. (2002). System Design with SystemC. Springer / Kluwer Academic Publishers. https://doi.org/10.1007/b116588

Comments 0

No comments yet.

Leave a comment