The SystemC/Simulink Tool Kit was created during my master's thesis, written in 2008 at Robert Bosch GmbH. Aim of my master's thesis was to create an interface that allows the developer to use SystemC modules inside a MATLAB/Simulink simulation environment. This allows reusing the same modules in a SystemC as well as in a Simulink environment. This is especially useful in a simulation-based verification flow. A system description can initially be implemented as Simulink model. After the correctness of the high-level Simulink model has been shown, the system can be transformed into a more detailed SystemC description. On both levels the same test bench modules can be used, assuring that both descriptions of the system fulfil the same requirements. Reusing test bench modules also reduces the likelihood of errors and speeds up the development.
Embedding SystemC modules into a Simulink environment is done by a set of wrappers. These wrappers implement a so-called S-Function, which can be used inside Simulink. Inside the Simulink environment SystemC modules appear as ordinary Simulink building blocks. Ports of the SystemC module can be connected to Simulink building blocks using connecting lines. Synchronisation as well as data conversion is done automatically and completely transparent.
The wrapper S-Function instantiates the SystemC module, sets up Simulink-specific parameters like the sample time, and is responsible for the data conversion. All in all there are three wrapper classes. The first one is used the forward S-Function calls, implemented in C to a C++-class. The second class instantiates ordinary SystemC modules. And finally, the third class allows to instantiated special SystemC test bench modules.
Most difficult part when implementing a co-simulation between SystemC and Simulink is the synchronisation. Both environments use different concepts of how the simulation is driven. SystemC is event driven, meaning that there is an event-queue that is processed event by event. Simulink however uses a so-called sample time that defined the points in time when a building block is to be updated. Unfortunately there is no golden solution covering all possible combination of occurring events and sample time. So five synchronisation procedures have been implemented, each covering a certain scenario.
The second problem to cope with is data conversion between both environments. In order to provide a different conversions with respect to the different data types provided by Simulink as well as different Simulink toolboxes like the FixedPoint toolbox, a flexible solution was implemented. When instantiating a SystemC module inside a Simulink model a parameter can be given to the S-Function, specifying which data conversion should be used. Currently there are three types of conversion possible.
If other data types are required or if different ports of the same module should be converted in different ways, Simulink provides a large set of converters that can be instantiated inside the model.