Target Language Compiler | ![]() ![]() |
System Target Files
The entire code generation process starts with the single system target file that you specify in the Real-Time Workshop pane of the Simulation Parameters dialog box. A close examination of a system target file reveals how code generation occurs. This a listing of the noncomment lines in grt.tlc
, the target file to generate code for a generic real-time executable:
%selectfile NULL_FILE %assign MatFileLogging = 1 %assign TargetType = "RT" %assign Language = "C" %include "codegenentry.tlc"
The three variables, MatFileLogging
, TargetType
, and Language
, are global TLC variables used by other functions. Code generation is then initiated with the call to codegenentry.tlc
, the main entry point for Real-Time Workshop.
If you want to make changes to modify overall code generation, you must change the system target file. After the initial setup, instead of calling codegenentry.tlc
, you must call your own TLC files. The code below shows an example system target file called mygrt.tlc
.
%% Set up variables, etc.
...
%% Load my library functions
%% Note that mylib.tlc should %include funclib.tlc at the
%% beginning.
%include "mylib.tlc"
%% Load mygenmap, the block target file mapping.
%% mygenmap.tlc should %include genmap.tlc at the beginning.
%include "mygenmap.tlc"
%include "commonsetup.tlc"
%% Next, you can include any of the TLC files that you need for
%% preprocessing information about the model and to fill in
%% Real-Time Workshop hooks. The following is an example of
%% including a single TLC file which contains custom hooks.
%include "myhooks.tlc"
%% Finally, call the code generator.
%include "commonentry.tlc"
Generated code is placed in a model or subsystem function. The relevant generated function names and their execution order is detailed in the Real-Time Workshop documentation. During code generation, functions from each of the block target files are executed and the generated code is placed in the appropriate model or subsystem functions.
![]() | Summary of Target File Usage | Block Target Files | ![]() |