Target Language Compiler | ![]() ![]() |
Code Generation Process
Real-Time Workshop invokes the TLC after a Simulink model is compiled into an intermediate form (model
.rtw
) that is suitable for generating code. To generate code apropriately, the TLC uses its library of functions to transform two classes of target files:
System target files are used to specify the overall structure of the generated code, tailoring for specific target environments. Block target files are used to implement the functionality of Simulink blocks, including user-defined S-function blocks.
You can create block target files for C MEX, Fortran, and M-file S-functions to fully inline block functionality into the body of the generated code. C MEX S-functions can be noninlined, wrapper-inlined, or fully inlined. Fortran S-functions must be wrapper- or fully inlined.
How TLC Determines S-Function Inlining Status
Whenever the Target Language Compiler encounters an entry for an S-function block in the model
.rtw
file, it must decide whether to generate a call to the S-function or to inline it.
Because they cannot use simStructs, Fortran, and M-file S-functions must be inlined. This inlining can either be in the form of a full block target file or a "one-liner" block target file that references a "substitute" C MEX S-function source file.
A C MEX S-function will be selected for inlining by the Target Language Compiler if there is an explicit mdlRTW()
function in the S-function code or if there is a target file for the current target language for the current block in the TLC file search path. If a C MEX S-function has an explicit mdlRTW()
function, there must be a corresponding target file or an error condition will result.
The target file for an S-function must have the same root name as the S-function and must have the extension .tlc
. For example, the example C MEX S-function source file sfun_bitop.c
has its compiled form in toolbox/simulink/blocks/sfun_bitop.dll
(.mex*
for UNIX) and its C target file is located in toolbox/simulink/blocks/tlc_c/sfun_bitop.tlc
.
![]() | Capabilities | A Look at Inlined and Noninlined S-Function Code | ![]() |