Technical data
Using the Target Language Compiler
1-3
For those familiar with HTML, Perl, and MATLAB
®
, you will find that the 
Target Language Compiler borrows ideas from each of them. It has the 
mark-up-like notion of HTML, and the power and flexibility of Perl and other 
scripting languages. It has the data handling power of MATLAB. The Target 
Language Compiler is designed for one purpose—to convert the model 
description file, 
model.rtw, (or similar files) into target specific code or text.
The code generated by the Compiler is highly optimized and fully commented 
C code, and can be generated from any Simulink model, including linear, 
nonlinear, continuous, discrete, or hybrid. All Simulink blocks are 
automatically converted to code, with the exception of MATLAB function 
blocks and S-function blocks that invoke M-files. The Target Language 
Compiler uses “block target files” to transform each block in the 
model.rtw file 
and a “model-wide target file” for global customization of the code.
You can incorporate C MEX S-functions, along with the generated code, into 
the program executable. You can also write a target file for your C MEX 
S-function to “inline” the S-function, thus improving performance by 
eliminating function calls to the S-function itself. Inlining an S-function 
incorporates the S-function block’s code into the generated code for the model. 
When no target file is present for the S-function, its C code file is invoked via a 
function call. For more information on inlining S-functions, see “Inlining an 
S-Function,” in Chapter 3. You can also write target files for M-files or Fortran 
S-functions.
Figure 1-1 shows how the Target Language Compiler works with its target files 
and Real-Time Workshop output to produce code. When generating code from 
a Simulink model using Real-Time Workshop, the first step in the automated 
process is to generate a 
model.rtw file. The model.rtw file includes all of the 
model-specific information required for generating code from the Simulink 
model. 
model.rtw is passed to the Target Language Compiler, which uses the 
model.rtw file in combination with a set of included target files to generate the 
body source C code (
model.c), a header file (model.h), a model registration 
include file (
model.reg) that registers the model’s SimStruct, and a parameter 
include file (
model.prm) that contains information about all the parameters 
contained in the model.










