Download Target Language Compiler Reference Guide

Transcript
3
Code Generation Architecture
System Target Files
The entire code generation process starts with the single system target file that
you specify in the Real-Time Workshop page of the Simulation Parameters
dialog box. A close examination of a system target file reveals how code
generation occurs. This a listing of the non-comment 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 the 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
3-16