Main Content

Embedded Coder

Generate readable, compact, and fast C and C++ code for embedded processors used in mass production

Description

Use the Embedded Coder app to generate C or C++ code from a model that represents a discrete-time system. The app extends the Simulink Coder app capabilities with advanced optimizations for precise control of the generated functions, files, and data. When you open the app, a C Code tab is added to the toolstrip. The C Code tab represents groups of tasks in the Embedded Coder workflow.

Use the app to perform these tasks:

  • If you are new to Embedded Coder, use the Embedded Coder Quick Start to prepare your model for code generation. The Embedded Coder Quick Start chooses fundamental code generation settings based on your goals and application. Open the Embedded Coder Quick Start by clicking Quick Start.

  • Set code generation objectives and prepare your model for code generation by clicking the C/C++ Code Advisor.

  • For a model hierarchy, specify the deployment type of each model by using the Deployment Type drop-down. If you have not configured deployment types, the drop-down says Automatic because Embedded Coder determines the deployment types automatically.

  • To set model configuration parameters, select Settings > C/C++ Code generation settings or Settings > Hardware Implementation.

  • Opening the Embedded Coder app opens the Code perspective. The Code perspective contains an integrated help pane, the Code Mappings editor, and the Property Inspector or Code view. Use the Code Mappings editor to configure data elements and entry-point functions in a model. Select Code Interface > Individual Element Code Mappings.

  • To create custom code definitions, open the Embedded Coder Dictionary by selecting Code Interface > Embedded Coder Dictionary.

  • Generate code only by selecting Build > Generate Code. Build the model and generate code by selecting Build > Build.

  • To view the generated code alongside your model, use the Code view. You can trace between model elements and the code by clicking hyperlinked lines of code in the Code view. Open the latest code generation report by selecting Open Report.

  • Verify the equivalence of the simulation and the code execution results by opening the SIL/PIL app. Select Verify Code > SIL/PIL Manager.

  • Create a protected model for simulation and code generation to share with a third party by selecting Share > Generate Protected Model.

  • Package the code and artifacts by selecting Share > Generate Code and Package.

Embedded Coder app

Open the Embedded Coder App

In the Apps gallery, under Code generation, click Embedded Coder. The C Code tab opens.

Tips

  • If you are working with a model hierarchy, the Embedded Coder app automatically determines the deployment type of each model based on the position in the hierarchy. The top model is the component and referenced models are subcomponents. On the C Code tab, the functionalities apply to the component model. To configure the deployment types of the models in the hierarchy:

    • Specify simulation only models, such as test harnesses, by selecting Output > Simulation Only. When you view a simulation only model in the Embedded Coder app, the toolstrip hides the code generation options.

    • Specify component and subcomponent models by using the Deployment Type drop-down.

  • To configure and view code for a referenced model, navigate to the model in the hierarchy and use the Code Mappings editor, Model Data Editor, Property Inspector, and Code view. These views apply to the active model, which can be the top model or a referenced model.

Version History

Introduced in R2019b

See Also

Functions