Main Content

嵌入式Coder

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

Description

Use the嵌入式Coderapp to generate C or C++ code from a model that represents a discrete-time system. The app extends theSimulink Coderapp capabilities with advanced optimizations for precise control of the generated functions, files, and data. When you open the app, aC Codetab is added to the toolstrip. TheC Code标签代表组织任务的嵌入式鳕鱼er 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 clickingQuick Start.

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

  • For a model hierarchy, specify the deployment type of each model by using theDeployment Typedrop-down. If you have not configured deployment types, the drop-down saysAutomaticbecause Embedded Coder determines the deployment types automatically.

  • To set model configuration parameters, selectSettings>C/C++ Code generation settingsorSettings>Hardware Implementation.

  • Opening the嵌入式Coderapp 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. SelectCode Interface>Individual Element Code Mappings.

  • To create custom code definitions, open the Embedded Coder Dictionary by selectingCode Interface>嵌入式Coder Dictionary.

  • Generate code only by selectingBuild>Generate Code. Build the model and generate code by selectingBuild>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 selectingOpen Report.

  • Verify the equivalence of the simulation and the code execution results by opening theSIL/PILapp. SelectVerify Code>SIL/PIL Manager.

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

  • Package the code and artifacts by selectingShare>Generate Code and Package.

Open the Embedded Coder App

In theAppsgallery, underCode generation, click嵌入式Coder. TheC Codetab opens.

Tips

  • If you are working with a model hierarchy, the嵌入式Coderapp 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 theC Codetab, 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 selectingOutput>Simulation Only. When you view a simulation only model in the嵌入式Coderapp, the toolstrip hides the code generation options.

    • Specify component and subcomponent models by using theDeployment Typedrop-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