Generating Efficient Code with Optimized ERT Targets

Overview

To make it easier for you to generate code that is optimized for your target hardware, the Real-Time Workshop® Embedded Coder™ software provides three variants of the ERT target. These targets are based on a common system target file, ert.tlc. They are displayed in the System Target File Browser as shown in the figure below.

The ERT target variants differ with respect to:

The following sections describe the ERT target variants, and how to select and use the optimized ERT targets.

Default ERT Target

The default ERT target is listed in the System Target File Browser as

Real-Time Workshop Embedded Coder (no auto configuration)

The Real-Time Workshop documentation refers to this target as the ERT target.

This target does not invoke an auto-configuration utility. Specification of target hardware characteristics is optional (although strongly recommended).

Optimized Fixed-Point ERT Target

The optimized fixed-point ERT target is listed in the System Target File Browser as

Real-Time Workshop Embedded Coder (auto configures for optimized fixed-point code)

Select this target to optimize for fixed-point code generation.

The optimized fixed-point ERT target passes in the command optimized_fixed_point=1 to the target selection process, and also to the build process with the Make command field of the Real-Time Workshop pane of the Configuration Parameters dialog box. This in turn invokes the M-file ert_config_opt.m, which auto-configures the model. The auto-configuration process overrides the model settings, informing users with a message in the MATLAB® command window.

You can, if desired, customize the option settings in the auto-configuration file, file, ert_config_opt.m. See Auto-Configuring Models for Code Generation for a complete description of the auto-configuration mechanism.

The optimized fixed-point ERT target requires specification of target hardware characteristics prior to code generation. Before generating code, you should select the desired Device vendor and Device type (or define a Custom device type with Device vendor set to Generic) in the upper panel of the Hardware Implementation pane of the Configuration Parameters dialog box, and set the other properties appropriately for your target. In the figure below, the Device vendor and Device type fields are configured for the Infineon C166x and XC16x microprocessor family.

If the Device type field is set to Unspecified (assume 32-bit Generic) (with Device vendor set to Generic), an error message (similar to that in the figure below) is displayed at the start of the code generation process.

Optimized Floating-Point ERT Target

The optimized floating-point ERT target is listed in the System Target File Browser as

Real-Time Workshop Embedded Coder (auto configures for optimized floating-point code)

Select this target to optimize for floating-point code generation.

The optimized floating-point ERT target passes in the command optimized_floating_point=1 to the target selection process, and also to the build process with the Make command field of the Real-Time Workshop pane of the Configuration Parameters dialog box. This in turn invokes the M-file ert_config_opt.m, which auto-configures the model. The auto-configuration process overrides the model settings, informing users with a message in the MATLAB command window.

You can, if desired, customize the option settings in the auto-configuration file, file, ert_config_opt.m. See Auto-Configuring Models for Code Generation for a complete description of the auto-configuration mechanism.

The optimized floating-point ERT target requires specification of target hardware characteristics prior to code generation. Before generating code, you should select the desired Device vendor and Device type (or define a Custom device type with Device vendor set to Generic) in the upper panel of the Hardware Implementation pane of the Configuration Parameters dialog box, and set the other properties appropriately for your target. In the figure below, the Device vendor and Device type fields are configured for the Freescale™ 32-bit PowerPC® family of microprocessors.

If the Device type field is set to Unspecified (assume 32-bit Generic) (with Device vendor set to Generic), an error message (similar to that in the figure below) is displayed at the start of the code generation process.

Using the Optimized ERT Targets

This section describes how to use the optimized ERT targets in code generation.

Configuring Hardware Implementation Properties

Before using one of the optimized versions of the ERT targets, make sure that you have specified the Hardware Implementation properties for the model's active configuration set correctly. If this is not done properly, an error message displays at the start of the code generation process and the build terminates.

To avoid such problems, select the desired Device vendor and Device type (or define a Custom device type with Device vendor set to Generic) in the upper panel of the Hardware Implementation pane of the Configuration Parameters dialog box, and set the other properties appropriately for your target (see Optimized Fixed-Point ERT Target and Optimized Floating-Point ERT Target). Do not leave the Device type unspecified.

Note that if your model was created prior to MATLAB Release 14 and has not yet been updated, the Device vendor and Device type default to Generic and Unspecified (assume 32-bit Generic), and the Emulation hardware properties (in the lower section of the Hardware Implementation pane) are in an undefined state. This condition is indicated by the presence of a button labeled Configure current execution hardware device, as shown in this figure.

In this case you should click the button to set the Emulation hardware properties to a valid (default) state, and save the model.

Generating Code

To generate code using one of the optimized ERT targets:

  1. From the Real-Time Workshop pane of the Configuration Parameters dialog box, open the System Target File Browser and select the desired target. This figure shows the browser with the optimized fixed-point ERT target selected.

  2. When you click Apply or OK to apply the target selection, the auto-configuration code executes. This is reported in a message similar to the following:

    *** Auto configuring 'optimized_fixed_point' for model 'untitled' as specified by:
    ert_config_opt.m
    *** Overwriting model settings if they do not yield optimized code.
  3. Initiate the build process.

  4. If your model's Hardware Implementation parameters are not configured correctly, an error message is displayed. If the error appears, see Configuring Hardware Implementation Properties to learn how to correct the problem, and then retry Step 3.

  5. During code generation, the auto-configuration code executes a second time, and the auto-configuration message displayed in Step 2 appears again.

  6. Other than the auto-configuration messages, the build process executes normally, reporting the usual progress and completion messages.

  


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