Develop and Deploy Embedded Software Components to Platform Services by Using Embedded Coder - MATLAB & Simulink (original) (raw)

Main Content

Embedded Coder® enables you to generate readable, compact, and fast C and C++ code for embedded processors used in mass production. This set of examples shows how you can use Embedded Coder to generate, optimize, verify, and deploy code in a scalable workflow. For background information about Embedded Coder and a basic code generation workflow, see Get Started with Embedded Coder.

The major steps of the workflow depend on your requirements and goals for deploying the generated code, including:

These examples show how to generate and deploy component C code by using CMake, but Embedded Coder supports many other deployment workflows. Each example includes information about how you can modify the workflow for other deployment goals.

Target Hardware

Your target hardware determines many of the options that are available for your generated code, including many code optimization options. For some hardware targets, Embedded Coder provides support packages that help to automate the integration, execution, and verification of generated code. Some common targets include:

For more hardware support packages, see Embedded Coder Supported Hardware.

For this example, you use the MATLAB® development computer as the target execution environment and you do not use a hardware support package.

Deployment Objectives

Deployment objectives define the type of code you want to generate and how you plan to deploy it in the target execution environment. The typical deployment objectives are:

For this example, you generate component code from a top model and subcomponent code from a referenced model. For more information, seeSoftware Deployment Objectives and Deployment Types.

Code Generation Workflow

The workflow follows these steps:

  1. Prepare Models for Code Generation — Set up your models using model-based design practices that support your code generation goals and the scalability of your project.
  2. Configure Basic Code Generation Settings — Choose the basic settings for code generation based on your objectives, including target deployment hardware. In this example, you save these settings so that you can reuse them for other models that generate code for the same platform.
  3. Define the Interfaces Between the Generated Code and Your Deployment Platform — Specify how generated code interacts with your deployment platform. In this example, you define these interfaces so that you can reuse them for other models that generate code for the same platform.
  4. Apply Code and Deployment Configurations to Models — Configure your model to use the configurations that you defined in the two previous steps. By defining the configurations separately from the models, you can easily re-use them for other models that generate code for the same platform. You can also define different configurations for other platforms so that you can reuse the same models to generate code for other platforms.
  5. Call Existing Code from a Model and Generated Code — This optional but common step shows how to integrate existing C code into the model and generated code.
  6. Optimize the Generated Code — Generate and examine the code that includes standard optimizations for your target. Depending on your goals, you can use more advanced techniques to further optimize the code.
  7. Test the Generated Code — Test the generated code by running a software-in-the-loop (SIL) simulation, which compares results from running the generated code to results from model simulation.
  8. Deploy the Generated Code — Build and deploy an executable from the generated code. For this example, use CMake.

To start the workflow, see Prepare Models for Code Generation.

See Also

Topics