Target Language Compiler |
 |
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. Chapter 5, Directives and Built-in Functions, provides complete descriptions of the target language directives.
Appendix A, 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 TLC program, which 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 the Real-Time Workshop, see the Real-Time Workshop User's Guide.
There are four sets of model-wide target files, one for each of the basic code formats that the Real-Time Workshop supports. These tables list the model-wide target files associated with each of the basic code formats.
Table 3-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 BlockOutputs, Parameter, 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 _sf_mid.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 _reg.h that is included by the model .c file to satisfy the API (all formats)
|
sfcnsid.tlc
|
RTW S-function
|
Creates model _sf_sid.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 .h , model .c , model _reg.h , model _prm.h , model _export.h , and, optionally, model .dt .
|
Table 3-2: Model-Wide Target Files for Ada
Model-Wide Target File
|
Purpose
|
adabody.tlc
|
Generates the model .adb file, which contains the package body for the model.
|
adalib.tlc
|
Contains utility functions used by the other model-wide target files
|
adaspec.tlc
|
Generates the model .ads file, which contains the package specification for the model, and the package specifications required for auto-building simulation and real-time targets:
register.ads
register2.ads
rt_engine-rto_data.ads
|
adatypes.tlc
|
Generates the model _types.ads file, which contains the data structures required by the model. Note that all data declaration instances are declared in the model .adb file.
|
adawide.tlc
|
The entry point for Ada code format. It produces these files:
model .ads
model .adb
model _types
register.ads
register2.ads
rtengine-rto_data.ads
|
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.
Note
Functions declared inside a block file are local. Functions declared in all other target files are global.
|
| Block Target File Mapping | | Writing Target Language Files: A Tutorial |  |