Target Language Compiler    

Inlining S-Function Concepts

To inline an S-function means to provide a TLC file for an S-function block that will replace the C (or Fortran or M) code version of the block that was used during simulation.

Noninlined S-Function

If an inlining TLC file is not provided, most Real-Time Workshop targets will still support the block by recompiling the C-MEX S-function for the block. As discussed earlier, there is overhead in memory usage and speed when using the C coded S-function and only a limited subset of mx* API calls are supported within the Real-Time Workshop context. If you want the most efficient generated code, you must inline S-functions by writing a TLC file for them.

When Simulink needs to execute one of the functions for an S-function block during a simulation, it calls into the MEX-file for that function. When Real-Time Workshop executes a noninlined S-function, it does so in a similar manner as this diagram illustrates.

Types of Inlining

When inlining an S-function with a TLC file, it is helpful to define two categories of inlining:

While both effectively inline the S-function and remove the overhead of a noninlined S-function, the two approaches are different. The first example below using timestwo.tlc is considered a fully inlined TLC file, where the full implementation of the block is contained in the TLC file for the block.

The second example uses a wrapper TLC file. Instead of generating all the algorithmic code in place, this example calls a C function that contains the body of code. There are several potential benefits for using the wrapper TLC file:


  model.rtw and Target Language Compiler Overview Fully Inlined S-Function Example