Overview of Pinapa's Implementation

Parsing SystemC

To parse SystemC, we have to deal with all C++, and consider SystemC function calls as primitives. Building a C++ front-end from scratch requires too much manpower and is therefore not an option. Our solution is to use the C++ front-end of GCC to parse C++ programs, and to execute the constructors of the modules to get the structure of the design (this phase is called ``elaboration''). Another solution would be to parse the constructors too, and infer the structure of the model from their body, but the advantage of our method is that the constructors of the modules can be of any complexity. We just compile and execute them, we do not parse them ourselves.

At the end of elaboration, instead of starting the simulation, we examine the data structures of the SystemC kernel (K) and make a link with some objects in the internal representation (G) of the source code parsed by GCC:

Architecture of the front-end.

Architecture.png

The traditional way to compile a SystemC model is to link it to the SystemC library. The main function is in the SystemC library, and calls the function sc_main. The elaboration is executed (the constructors of each modules, and the binding), and then, the function sc_start() is executed.

This front-end use a slightly modified version of the SystemC header and library. (see the page Modifications applied to SystemC). The call to sc_start is replaced by a call to pinapa::parser_start, who will call the parser in the GCC front-end (Calling the function toplevel_main with the right arguments.). This function, as well as all other functions related to SystemC, are grouped in the module SystemC related code.

Inside GCC's source code, a function call has been added to the function pinapa_gcc_analyze_function_hook, with the abstract representation of the body of a function as an argument. This scans the data structure of the SystemC kernel and decides wether this function is the body of a process. If so, it attaches a pointer to the body of the function in the appropriate process handler. The second step is to search for SystemC primitives such as wait, notify, write or read in the body of the function. This is done by the function analyze_function_body. Those functions, as well as all other functions related to GCC are grouped in the module GCC related code..

When all function have been parsed, and if necessary linked to the SystemC structures, the function pinapa::analyze_function_body is called and will use the data structure built.

Generated by
Matthieu Moy <Matthieu.Moy@st.com>
Back to Pinapa Home Page