Choosing and Configuring Your Target

Introduction

The first step to setting up a file for code generation is to choose and configure a system target. The process of generating target-specific code is controlled by the following:

You can specify this configuration information for a specific type of target in one step by using the System Target File Browser. The browser lists a variety of ready-to-run configurations.

When you select a target, the Real-Time Workshop® software changes settings in the current configuration set to be compatible with the corresponding system target file. For example, many hardware emulation target settings, such as word size and byte ordering, are set automatically according to device type requirements. After selecting a system target, you can modify other model configuration settings to meet model or system requirements.

If you want to apply different system target files to a given model, you can do so by creating multiple configuration sets for that model. At any given time, you choose one configuration set to be the active configuration set. This is the preferred practice over simply changing the model's system target file.

Selecting a System Target File

To select a target configuration using the System Target File Browser,

  1. Click Real-Time Workshop on the Configuration Parameters dialog box. The Real-Time Workshop pane appears.

  2. Click the Browse button next to the System target file field. This opens the System Target File Browser. The browser displays a list of all currently available target configurations, including customizations. When you select a target configuration, the Real-Time Workshop software automatically chooses the appropriate system target file, template makefile, and make command.

    Selecting a System Target File shows the System Target File Browser with the generic real-time target selected.

  3. Click the desired entry in the list of available configurations. The background of the list box turns yellow to indicate an unapplied choice has been made. To apply it, click Apply or OK.

    System Target File Browser

    When you choose a target configuration, the Real-Time Workshop software automatically chooses the appropriate system target file, template makefile, and make command for the selected target, and displays them in the System target file field. The description of the target file from the browser is placed below its name in the general Real-Time Workshop pane.

Selecting a System Target File Programmatically

Simulink® models store model-wide parameters and target-specific data in configuration sets. Every configuration set contains a component that defines the structure of a particular target and the current values of target options. Some of this information is loaded from a system target file when you select a target using the System Target File Browser. You can configure models to generate alternative target code by copying and modifying old or adding new configuration sets and browsing to select a new target. Subsequently, you can interactively select an active configuration from among these sets (only one configuration set can be active at a given time).

Scripts that automate target selection need to emulate this process.

To program target selection

  1. Obtain a handle to the active configuration set with a call to the getActiveConfigSet function.

  2. Define string variables that correspond to the required Real-Time Workshop system target file, template makefile, and make command settings. For example, for the ERT target, you would define variables for the strings 'ert.tlc', 'ert_default_tmf', and 'make_rtw'.

  3. Select the system target file with a call to the switchTarget function. In the function call, specify the handle for the active configuration set and the system target file.

  4. Set the TemplateMakefile and MakeCommand configuration parameters to the corresponding variables created in step 2.

For example:

cs = getActiveConfigSet(model);
stf = 'ert.tlc';
tmf = 'ert_default_tmf';
mc  = 'make_rtw';
switchTarget(cs,stf,[]);
set_param(cs,'TemplateMakefile',tmf);
set_param(cs,'MakeCommand',mc);

Available Targets

The following table lists supported system target files and their associated code formats. The table also gives references to relevant manuals or chapters in this book. All of these targets are built using the make_rtw make command.

Each system target file invokes one or more template makefiles. The template makefile that is invoked activates a particular compiler (for example, Lcc, gcc, or Watcom compilers). This is specified for you by MEXOPTS, which is determined when you run mex -setup to select a compiler for mex. One exception is the Microsoft® Visual C++® project target, which has separate System Target File Browser entries.

Targets Available from the System Target File Browser

Target/Code Format

System Target File

Template Makefile and Comments

Reference

Real-Time Workshop Embedded Coder (for PC or UNIX®[a] platforms)

ert.tlc
ert_shrlib.tlc

ert_default_tmf

Use mex -setup to configure for Lcc, Watcom, vc, gcc, and other compilers

Real-Time Workshop Embedded Coder documentation

Real-Time Workshop Embedded Coder for Visual C++®[b] Project Makefile

ert.tlc

ert_msvc.tmf

Creates a makefile which can be loaded into the Visual C++ IDE

Real-Time Workshop Embedded Coder documentation

Real-Time Workshop Embedded Coder for Tornado® (VxWorks®)[c]

ert.tlc

ert_tornado.tmf

Real-Time Workshop Embedded Coder documentation

Real-Time Workshop Embedded Coder for AUTOSAR

autosar.tlc

ert_default_tmf

Real-Time Workshop Embedded Coder documentation

Generic Real-Time for PC or UNIX platforms

grt.tlc

grt_default_tmf

Use mex -setup to configure for Lcc, Watcom, vc, gcc, and other compilers

Generated Code Formats

Generic Real-Time for Visual C++ Project Makefile

grt.tlc

grt_msvc.tmf

Generated Code Formats

Generic Real-Time (dynamic) for PC or UNIX platforms

grt_malloc.tlc

grt_malloc_default_
tmf

Use mex -setup to configure for Lcc, Watcom, vc, gcc, and other compilers

Does not support SimStruct.

Generated Code Formats

Generic Real-Time (dynamic) for Visual C++ Project Makefile

grt_malloc.tlc

grt_malloc_msvc.tmf

Does not support SimStruct.

Generated Code Formats

Rapid Simulation Target (default for PC or UNIX platforms)

rsim.tlc

rsim_default_tmf

Use mex -setup to configure

Running Rapid Simulations

Rapid Simulation Target for LCC compiler

rsim.tlc

rsim_lcc.tmf

Running Rapid Simulations

Rapid Simulation Target for UNIX platforms

rsim.tlc

rsim_unix.tmf

Running Rapid Simulations

Rapid Simulation Target for Visual C++ compiler

rsim.tlc

rsim_vc.tmf

Running Rapid Simulations

Rapid Simulation Target for Watcom compiler

rsim.tlc

rsim_watc.tmf

Running Rapid Simulations

S-Function Target for PC or UNIX platforms

rtwsfcn.tlc

rtwsfcn_default_tmf

Use mex -setup to configure

S-Function Target

S-Function Target for LCC

rtwsfcn.tlc

rtwsfcn_lcc.tmf

S-Function Target

S-Function Target for UNIX platforms

rtwsfcn.tlc

rtwsfcn_unix.tmf

S-Function Target

S-Function Target for Visual C++ compiler

rtwsfcn.tlc

rtwsfcn_vc.tmf

S-Function Target

S-Function Target for Watcom

rtwsfcn.tlc

rtwsfcn_watc.tmf

S-Function Target

Tornado (VxWorks) Real-Time Target

tornado.tlc

tornado.tmf

Targeting the Wind River Systems Tornado® Environment for Real-Time Applications

ASAM-ASAP2 Data Definition Target

asap2.tlc

asap2_default_tmf

Blocks That Depend on Absolute Time

Real-Time Windows Target for Open Watcom

rtwin.tlc

rtwin.tmf

Real-Time Windows Target documentation

xPC Target™ for Visual C++ or Watcom C/C++ compilers

xpctarget.tlc
xpctargetert.tlc

xpc_default_tmf
xpc_vc.tmf
xpc_watc.tmf

xPC Target documentation

Target Support Package™ FM5

mpc555exp.tlc
mpc555pil.tlc
mpc555rt.tlc
mpc555rt_grt.tlc

mpc555exp.tmf
mpc555exp_diab.tmf
mpc555pil.tmf
mpc555pil_diab.tmf
mpc555rt.tmf
mpc555rt_grt.tmf

Target Support Package FM5 documentation

Target Support Package IC1

c166.tlc
c166_grt.tlc

c166.tmf
c166_grt.tmf

Target Support Package IC1 documentation

Target Support Package TC2

ti_c2000_grt.tlc
ti_c2000_ert.tlc

tti_c2000_grt.tmf
ti_c2000_ert.tmf

Target Support Package TC2 documentation

Target Support Package TC6

ti_c6000.tlc (GRT)
ti_c6000_ert.tlc

ti_c6000.tmf
ti_c6000_ert.tmf

Target Support Package TC6 documentation

[a] UNIX is a registered trademark of The Open Group in the United States and other countries.

[b] Visual C++ is a registered trademark of Microsoft Corporation.

[c] Tornado and VxWorks are registered trademarks of Wind River Systems, Inc.

Targets Supporting Nonzero Start Time

When you try to build models with a nonzero start time, if the selected target does not support a nonzero start time, the Real-Time Workshop software does not generate code and displays an error message. The Rapid Simulation (RSim) target supports a nonzero start time when the Configuration Parameters > RSim Target > Solver selection parameter is set to Use Simulink solver module. All other targets do not support a nonzero start time.

Creating Custom Targets

You can create your own system target files to build custom targets that interface with external code or operating environments. If you have in the past created system target files, note that the form of callbacks has changed between Versions 5 and 6 of the Real-Time Workshop product. See the Real-Time Workshop Embedded Coder documentation for details, including how to make your custom targets appear in the System Target File Browser and display appropriate controls in panes of the Configuration Parameters dialog box.

Template Makefiles and Make Options

The Real-Time Workshop product includes a set of built-in template makefiles that are designed to build programs for specific targets.

There are two types of template makefiles:

You can supply options to makefiles by using arguments to the Make command field in the general Real-Time Workshop pane of the Configuration Parameters dialog box. Append the arguments after make_rtw (or make_xpc or other make command), as in the following example:

make_rtw OPTS="-DMYDEFINE=1"

The syntax for make command options differs slightly for different compilers.

Complete details on the structure of template makefiles are provided in the Real-Time Workshop Embedded Coder documentation. This information is provided for those who want to customize template makefiles. This section describes compiler-specific template makefiles and common options you can use with each.

Template Makefiles for UNIX® Platforms

The template makefiles for UNIX platforms are designed to be used with the Free Software Foundation's GNU® Make. These makefile are set up to conform to the guidelines specified in the IEEE®[4] Std 1003.2-1992 (POSIX) standard.

You can supply options by using arguments to the make command.

These options are also documented in the comments at the head of the respective template makefiles.

Template Makefiles for the Microsoft® Visual C++® Compiler

The Real-Time Workshop product offers two sets of template makefiles designed for use with the Visual C++ compiler.

To build an executable within the Real-Time Workshop build process, use one of the target_vc.tmf template makefiles:

You can supply options by using arguments to the make command.

These options are also documented in the comments at the head of the respective template makefiles.

Visual C++® Code Generation Only.   To create a Visual C++ project makefile (model.mak) without building an executable, use one of the target_msvc.tmf template makefiles:

These template makefiles are designed to be used with nmake, which is bundled with the Visual C++ compiler.

You can supply the following options by using arguments to the nmake command:

These options are also documented in the comments at the head of the respective template makefiles.

Template Makefiles for the Watcom C/C++ Compiler

The Real-Time Workshop product provides template makefiles to create an executable for the Microsoft® Windows® platform using Watcom C/C++. These template makefiles are designed to be used with wmake, which is bundled with Watcom C/C++.

You can supply options by using arguments to the make command. Note that the location of the quotes is different from the other compilers and make utilities discussed in this chapter.

These options are also documented in the comments at the head of the respective template makefiles.

Template Makefiles for the LCC Compiler

The Real-Time Workshop product provides template makefiles to create an executable for the Windows platform using Lcc compiler Version 2.4 and GNU Make (gmake).

You can supply options by using arguments to the make command:

These options are also documented in the comments at the head of the respective template makefiles.

Enabling the Real-Time Workshop® Software to Build When Path Names Contain Spaces

The Real-Time Workshop software is able to handle path names that include spaces. Spaces might appear in the path from several sources:

If your work environment includes one or more of the preceding scenarios, use the following support mechanisms, as necessary and appropriate:


[a] UNIX is a registered trademark of The Open Group in the United States and other countries.

[b] Visual C++ is a registered trademark of Microsoft Corporation.

[c] Tornado and VxWorks are registered trademarks of Wind River Systems, Inc.

[4] IEEE is a registered trademark of The Institute of Electrical and Electronics Engineers, Inc.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS