Generate readable, compact, and fast C and C++ code for embedded processors used in mass production
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.
The app contains five sections which are representative of 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 Generation Advisor.
To set model configuration parameters, select Settings > 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. Open or close these panes by selecting or clearing them in the Settings menu. Use the Code Mappings editor to associate model data elements and entry-point functions with code definitions.
To create custom code definitions, open the Embedded Coder Dictionary by selecting Settings > Embedded Coder Dictionary or by clicking the Embedded Coder Dictionary icon in the Code Mappings
editor .
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 Latest 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.
In the Apps gallery, under Code generation, click Embedded Coder. The C Code tab opens.
If you are working with a model hierarchy, open the Embedded Coder app in the Simulink Editor window for the top model of the hierarchy that you are generating code for. On the C Code tab, the functionalities apply to the top model of the hierarchy that is open in the editor.
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.