Target Language Compiler    

Available Target Files

Target files are the set of files that are interpreted by the Target Language Compiler to transform the intermediate Real-Time Workshop code (model.rtw) produced by Simulink into target-specific code.

Target files provide you with the flexibility to customize the code generated by the Compiler to suit your specific needs. By modifying the target files included with the Compiler, you can dictate what the compiler produces. For example, if you use the available system target files, you produce generic C code from your Simulink model. This executable C code is not platform specific.

All of the parameters used in the target files are read from the model.rtw file and looked up using block scoping rules. You can define additional parameters within the target files using the %assign statement. The block scoping rules and the %assign statement are discussed in Directives and Built-In Functions.

Target files are written using target language directives. Directives and Built-in Functions, provides complete descriptions of the target language directives.

model.rtw, contains a thorough description of the model.rtw file, which is useful for creating and/or modifying target files.

Model-Wide Target Files and System Target Files

Model-wide target files are used on a model-wide basis and provide basic information to the Target Language Compiler, which transforms the model.rtw file into target-specific code.

The system target file is the entry point for the Target Language Compiler. It is analogous to the main() routine of a C program. System target files oversee the entire code generation process. For example, the system target file, grt.tlc, sets up some variables for codegenentry.tlc, which is the entry point into the Real-Time Workshop target files. For a complete list of available system target files for Real-Time Workshop, see the Real-Time Workshop documentation.

There are four sets of model-wide target files, one for each of the basic code formats that the Real-Time Workshop supports. The following table lists the model-wide target files associated with each of the basic code formats.

Table 4-1: Model-Wide Target Files for Static Real-Time, Malloc (dynamic) Real-Time, Embedded-C and RTW S-Function Applications  
Model-Wide Target File
Code Format
Purpose
ertautobuild.tlc
Embedded-C
Includes model_export.h in the generated code
srtbody.tlc
mrtbody.tlc
ertbody.tlc
sfcnbody.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Creates the source file, model.c, which contains the procedures that implement the model
srtexport.tlc
mrtexport.tlc
ertexport.tlc
sfcnbody.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Creates the header file model_export.h, which defines access to external parameters and signals (all formats)
srthdr.tlc
mrthdr.tlc
erthdr.tlc
sfcnhdr.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Creates the header file model.h, which defines the data structures used by model.c. The data structures defines include Block Outputs, Parameters, External Inputs and Outputs, and the various work structures. The instances of these structures are declared in model.c (all formats).

srtlib.tlc
mrtlib.tlc
ertlib.tlc
sfclib.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Contains utility functions used by the other model-wide target files (all formats)
srtmap.tlc
mrtmap.tlc
ertmap.tlc
sfcnmap.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Creates the header file model.dt, which contains the mapping information for monitoring block outputs and modifying block parameters
sfcnmid.tlc
RTW S-function
Creates model.c, which contains data for an RTW S-function
srtparam.tlc
mrtparam.tlc
ertparam.tlc
sfcnparam.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Creates the source file model.prm, which is included by the model.c file to declare instances of the various data structures defined in model.h (all formats)
srtreg.tlc
mrtreg.tlc
ertreg.tlc
sfcnreg.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
Creates the source file model.h that is included by the model.c file to satisfy the API (all formats)
sfcnsid.tlc
RTW S-function
Creates model.c, which contains data for an RTW S-function.
srtwide.tlc
mrtwide.tlc
ertwide.tlc
sfcnwide.tlc

Static real-time
Malloc real-time
Embedded-C
RTW S-function
The entry point for code format. This file produces model.c, model.h, and, optionally, model.dt.
Table 4-2:

Block Target Files

Block target files are files that control a particular Simulink block. Typically, there is a block target file for each Simulink basic building block. These files control the generation of inline code for the particular block type. For example, the target file, gain.tlc, generates corresponding code for the Gain block.

The file genmap.tlc (included by codegenentry.tlc) tells TLC which .tlc files to include for particular blocks.


  TLC Files Summary of Target File Usage