Real-Time Workshop | ![]() ![]() |
System Target Files
The Target Language Compiler (TLC) generates target-specific C code from an intermediate description of your Simulink block diagram (model
.rtw
). The Target Language Compiler reads model
.rtw
and executes a program consisting of several target files (.tlc
files.) The output of this process is a number of source files, which are fed to your development system's make utility.
The system target file controls the code generation process. You will need to create a customized system target file to set code generation parameters for your target. We recommend that you copy, rename, and modify one of the standard system target files:
matlabroot
/rtw/c/grt/grt.tlc
, for rapid prototyping targets
matlabroot
/rtw/c/ert/ert.tlc
, for embedded (production) targets
Building an Application of the Getting Started Guide and Code Generation and the Build Process describe the role of the system target file in the code generation and build process. Guidelines for creating a custom system target file are given in Customizing the Build Process.
Template Makefiles
A template makefile (.tmf
file) provides information about your model and your development system. Real-Time Workshop uses this information to create an appropriate makefile (.mk
file) to build an executable program. Real-Time Workshop provides a large number of template makefiles suitable for different types of targets and development systems. The standard template makefiles are described in Template Makefiles and Make Options.
If one of the standard template makefiles meets your requirements, you can simply copy and rename it in accordance with the conventions of your project. If you need to make more extensive modifications, see Template Makefiles for a full description of the structure of template makefiles.
Hook Files for Communicating Target-specific Word Characteristics
In order to communicate details about target hardware characteristics, such as word lengths and overflow behavior, you need to supply an M-file named <target>_rtw_info_hook.m
. Each system target file needs to implement a hook file. Those provided for built-in targets are placed in the respective target directories under toolbox/rtw/targets/
.
Hook files provide an API to describe two essential aspects of hardware characteristics:
CharNumBits
Size of C char
type
ShortNumBits
Size of C short
type
IntNumBits
Size of C int
type
LongNumBits
Size of C long
type
ShiftRightIntArith
Set true
if shift right on a signed integer is implemented as arithmetic shift, and false
otherwise.
Float2IntSaturates
Conversion from float to integer automatically saturates, thus do not generate software saturation code.
IntPlusIntSaturates
Integer addition automatically saturates, thus do not generate software saturation code.
IntTimesIntSaturates
Integer multiply automatically saturates, thus do not generate software saturation code.
To supply a hookfile for the GRT target (grt.tlc
), for example, you must name the file grt_rtw_info_hook.m
, and place it somewhere on the MATLAB path. If the hook file is present, the target-specific information is extracted via the API found in this file. If the hookfile is not provided, default values based on the host's characteristics will be used, which may not be appropriate.
For an example, see toolbox/rtw/rtwdemos/example_rtw_info_hook.m
.
Note
The TLC directive %assign DSP = 1 no longer has any effect. You need to provide a hook file instead.
|
![]() | Run-Time Interface for Embedded Targets | Tutorial: Creating a Custom Target Configuration | ![]() |