A fixed-point model with generated code and its simulation mode set for SIL execution. Embedded Coder lets you quickly generate, document, and test code for production embedded systems.

Configuring and Working with Targets

To configure code generation settings for Embedded Coder, you use the MATLAB Coder project user interface or the Simulink Model Explorer. You can also configure each setting directly using MATLAB commands and scripts.

Selecting Targets

For a MATLAB configuration object, you specify one of the following output targets:

MEX-file

C/C++ static library

C/C++ executable

For a Simulink system target file, you specify the real-time environment on which your generated code will run. Embedded Coder includes target files for several ready-to-run configurations, and supports third-party and custom targets as well. Built-in targets include:

Defining Embedded Hardware Characteristics

For MATLAB or Simulink code generation, you select the deployment processor from a predefined list or use generic target settings. You can also extend the predefined list for your custom environment.

Simulink Model Explorer, which provides access to a predefined list or generic settings for specifying the microprocessor for code deployment. Embedded Coder generates code for any microprocessor or DSP, including 8-bit, 16-bit, and 32-bit.

Defining and Controlling Custom Data

Embedded Coder enables you to define and control how the model data appears in the generated code. To facilitate software integration, you can specify class, size, and complexity of MATLAB data with the MATLAB Coder project user interface for entry point functions and global data.

User data type — Lets you create abstract types for complex data so you can precisely control how model data appears in the generated code, interface with any legacy data, and augment or replace Simulink built-in types

The following tools help you design and manage project data in Simulink:

Simulink Model Explorer — Displays all data used by Simulink models and Stateflow® charts and provides customizable views so you can tailor the information in a data dictionary format

Embedded Coder gives you access to ASAP2 data exchange files in Simulink, enabling you to export model data with complex data definitions using the ASAP2 standard. You can modify the built-in capabilities to produce other data exchange mechanisms.

A custom storage class created with the Customer Storage Class Designer, which lets you design, view, and validate complex data types using an intuitive graphical interface.

Optimizing and Packaging Code

Using Embedded Coder, you can control function boundaries, preserve expressions, and apply optimizations on multiple blocks to further reduce code size. Data is exchanged with the generated code via global variables or function arguments. You can trace the generated code to blocks and signals in your model.

Include MATLAB code as comments in generated code, including function help text

With Simulink, Embedded Coder also provides the ability to insert high-level requirements as code comments with links to the requirement source (requires Simulink Verification and Validation™) The code report for Simulink code generation also includes a code interface description, traceability report, and display of generated source files and code. Bidirectional links exist between the model and generated code, making it easy to navigate between every line of code and its corresponding Simulink model element, including subsystems, blocks, MATLAB functions and code, and Stateflow charts and transitions. You can click a link to highlight the corresponding model element or line of code, facilitating code reviews and debugging.

Executing and Verifying Code

With MATLAB, the code generated from Embedded Coder executes using the same execution framework as provided by MATLAB Coder.

With Simulink, Embedded Coder significantly extends the real-time execution framework provided by Simulink Coder. By default, the code can be executed with or without a real-time operating system (RTOS) and in single-tasking, multitasking, or asynchronous mode. You can also verify the code execution results using software-in-the-loop (SIL) and processor-in-the-loop (PIL) testing.

Generating a Main Program

Embedded Coder generates an extensible main program based on information you provide for deploying the code in your real-time environment. This capability lets you generate and build a complete customized executable from your model.

Grouping Rates

Embedded Coder generates single-rate or multirate code using periodic sample times specified in the model. For multirate, multitasking models, it employs a strategy called rate grouping that generates separate functions for the base rate task and for each sub-rate task in the model.

Using Links and Targets

Automated deployment, integration, optimization, and execution of generated code is available for supported third-party IDEs, microprocessors, and RTOSs, including Wind River Systems® VxWorks®.