Introduction to High-Level Synthesis (HLS)
An overview of High-Level Synthesis and the SystemC Synthesizable Subset.
How to Read This Lesson
For synthesis, the question changes from 'can C++ run this?' to 'can hardware be built from this?' Keep storage, timing, and static structure in your head as you read.
Introduction to High-Level Synthesis (HLS)
The SystemC Synthesizable Subset (often referenced via the Accellera SystemC Synthesis Working Group) defines the subset of the SystemC C++ class library that can be reliably synthesized into register-transfer level (RTL) hardware by High-Level Synthesis (HLS) tools.
While SystemC is an incredibly powerful language for simulation and virtual prototyping, not everything you can write in C++ can be physically built in silicon. For example, dynamically allocating memory on the heap using new or malloc during the middle of a hardware simulation has no physical equivalent in a fixed silicon area.
Source and LRM Trail
For synthesis, use Docs/LRMs/SystemC_Synthesis_Subset_1_4_7.pdf as the primary contract and Docs/LRMs/SystemC_LRM_1666-2023.pdf for base SystemC semantics. Source internals explain simulation behavior, but synthesizability is a tool contract: focus on static structure, reset modeling, wait placement, and bounded loops.
The Goal of the Synthesizable Subset
The goal of the synthesis subset is to provide a standardized, common denominator of SystemC constructs that EDA vendors (like Cadence, Synopsys, Siemens, etc.) agree upon. If you write your SystemC code using only these constructs, you are guaranteed that an HLS tool can compile your C++ code into Verilog or VHDL.
Key Restrictions
To make C++ synthesizable, several major restrictions are enforced:
- No Dynamic Allocation After Elaboration: You cannot dynamically allocate memory or objects after the
start_of_simulation()phase. All hardware must be statically known. - No Dynamic Processes: Functions like
sc_spawnare generally not synthesizable. You must use staticSC_METHODorSC_CTHREADregistrations. - Restricted Pointers: Pointer arithmetic is heavily restricted or outright banned. Pointers can only be used if the HLS tool can statically determine exactly what they point to at compile time.
- No Recursion: Hardware cannot easily implement arbitrary recursion without an infinite unbounded stack. Recursive function calls are not synthesizable.
- Standard Library Limits: Standard C++ library features like
std::vector,std::map, or file I/O (std::cout,fstream) are meant for simulation only and cannot be synthesized into silicon.
In the next tutorial, we will explore which specific SystemC datatypes are supported for synthesis.
Under the Hood: Synthesizable C++ Constraints
High-Level Synthesis (HLS) tools parse SystemC using an LLVM-based frontend, but they ignore the SystemC simulation scheduler. They statically analyze the Abstract Syntax Tree (AST).
Because hardware is statically allocated, you cannot use new or malloc after the elaboration phase. std::vector with dynamic sizing will cause synthesis failure because the tool cannot determine the number of physical flip-flops to instantiate.
Furthermore, recursion and function pointers are generally forbidden because the call graph must be fully unrolled into physical logic paths. When an HLS tool sees an sc_module, it treats it as a Verilog module, converting its sc_in/sc_out directly into physical ports.
Comments and Corrections