Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company

 

MATLAB Digest - September 2003

Creating Custom Code with Real-Time Workshop Embedded Coder 3.1


by Tom Erkkinen and Pete Szpak

  View related webinar

Featuring a collection of tips and best practices for Simulink, Stateflow, and Real-Time Workshop Embedded Coder users, this article describes how to generate custom code files, create a custom user interface for code generation, and improve code efficiency. The examples are based on MathWorks R13 Service Pack 1.

Tips and Models

Unless specified, the tips are independent of each other and do not have to be read in a particular order. The tips follow a consistent format that includes a references section with related tips.

For more Real-Time Workshop Embedded Coder tips and techniques, see the 2003: July, May, March, January, and 2002: November issues of MATLAB Digest.

Tip 1: Generating Efficient Code via Optimized ERT Targets

R13 SP1 includes new Embedded Real-Time (ERT) targets that make generating efficient code easier through automation. These new targets are based on the auto-configuration tools and techniques described in the May issue of MATLAB Digest. They enable developers to get optimized code for initial benchmarks studies or analyses even if they have not reviewed the individual code generation option and studied the various efficiency tradeoffs, and are a great starting point for fined-tuned optimization.

Description

The three ERT targets are:
  • Real-Time Workshop Embedded Coder (no auto configuration) This is the default ERT target. Its code-generation configuration options are set to the same values used in R13. The auto-configuration capability is not employed and the configuration values that are set within the model are used for code generation.
  • Real-Time Workshop Embedded Coder (auto configures for optimized fixed-point code)
    This is a new ERT target. Its code-generation configuration options are set to values that maximize fixed-point code efficiency. The model’s settings are overwritten during the auto-configuration process and a warning is displayed within MATLAB informing the user of this.
  • Real-Time Workshop Embedded Coder (auto configures for optimized floating-point code)
    This is a new ERT target. Its code-generation configuration options are set to values that maximize floating-point code efficiency. The model’s settings are overwritten during the auto-configuration process and a warning is displayed within MATLAB informing the user of this.

Procedure

To use an optimized ERT target:
  1. Browse System Target Files (see Figure 1)
  2. Select the appropriate target
    1. Optimized for fixed-point code
    2. Optimized for floating-point code
  3. Set Target Word Sizes if required
  4. Generate code

Figure 1: Browsing system target files. Click on image to see enlarged view.


Figure 2: The selected optimized fixed-point target. Click on image to see enlarged view.

The make command includes an optimized_fixed_point=1 argument. This argument is automatically passed into the ert_make_rtw_hook.m hook file, described in Tip 1 in “Configuring the Code Generator and Tailoring the Build Process for Embedded Targeting," which appears in the May issue of MATLAB Digest, to configure the model with optimized fixed-point settings.


The optimized targets verify that you are using ert_rtw_info_hook.m to specify target word sizes as described in Tip 2 in “Configuring the Code Generator and Tailoring the Build Process for Embedded Targeting," which appears in the May issue of MATLAB Digest. If not, an editor will appear with a default file for you to edit and save.


References

  • Related tips: Tip 1 and Tip 2 in "Configuring the Code Generator and Tailoring the Build Process for Embedded Targeting," which appeared in the May 2003 MATLAB Digest
  • Additional software: R13 SP1 includes an optimized ert target file. Visit MATLAB Central for R13.0.1 Optimized ert target file support files.
  • User documentation: Real-Time Workshop: Release Notes R13 SP1
Contact sales
E-mail this page
Print this page
Subscribe to newsletters