Check Model and Configuration for Code Generation
By using Embedded Coder®, you can assess whether your model is ready to generate code and also satisfies the intended code generation objectives. These capabilities are provided in:
Code Generation Advisor — Evaluate whether your model satisfies the intended code generation objectives, such as execution efficiency, traceability, and MISRA C:2012 compliance. For a complete list of high-level objectives, see High-Level Code Generation Objectives. By using the advisor interface, you can update the model to satisfies the code generation objectives. For more information, see Configure Model for Code Generation Objectives by Using Code Generation Advisor.
Model Advisor — If you have Embedded Coder or Simulink® Coder™ , you use Model Advisor checks to assess the readiness of your model for generating code, including configuration parameter settings and compliance with standards. You can use the advisor interface to modify configuration parameters. For more information, see:
Check Model During Code Generation by Using the Code Generation Advisor
To review a model as part of the code generation process, use the Code Generation Advisor.
To select and prioritize your code generation objectives, on the Configuration Parameters > Code Generation pane, click Set Objectives.
On the Configuration Parameters > Code Generation > General pane, select one of the following from Check model before generating code:
On (proceed with warnings)
On (stop for warnings)
If you want to only generate code, select Generate code only. Otherwise clear the check box to build an executable.
Apply your changes. Press Ctrl+B to generate code or build the model.
If the Code Generation Advisor issues failures or warnings, and you specified:
On (proceed with warnings)— The Code Generation Advisor window opens while the build process proceeds. After the build process is complete, you can review the results.
On (stop for warnings)— The build process halts and displays the Diagnostic Viewer. To continue, you must review and resolve the Code Generation Advisor results or clear the Check model before generating code parameter.
In the Code Generation Advisor window, review the results by selecting a check from the left pane. The results for that check display in the right pane.
After reviewing the check results, you can choose to fix warnings and failures as described in Fix a Model Advisor Check Warning or Failure.
When you specify an efficiency or Safety precaution objective, the Code Generation Advisor includes additional checks. When you make changes to one of these additional checks, previous check results can potentially become invalid and need to be rerun.
For more information, see Set Objectives — Code Generation Advisor Dialog Box
Embedded Coder Model Advisor Checks for Standards, Guidelines, and Code Efficiency
To check that your model meets guidelines, standards, and is ready to generate code, you can use the Model Advisor checks available with Embedded Coder.
On the Modeling tab, select Model Advisor.
In the Model Advisor window, expand the By Product folder. The Embedded Coder folder contains Model Advisor checks that you can run. For a complete list of checks, see Embedded Coder Checks.
For more information about the Model Advisor, see Check Your Model Using the Model Advisor.
This example shows the use of the Model Advisor to check model
rtwdemo_throttlecntrl for code
rtwdemo_throttlecntrl. Save a copy as
throttlecntrlin a writable location on your MATLAB® path.
On the Modeling tab, click Model Advisor. A dialog box opens showing the model system hierarchy.
throttlecntrland then click OK. The Model Advisor window opens.
Expand By Task > Code Generation Efficiency. To check your model for code generation efficiency, use the checks in the folder. By default, checks that do not trigger an Update Diagram are selected. The checks available for code generation efficiency depend on whether you have a Simulink Coder or Embedded Coder license.
In the left pane, select the remaining checks. Right-click on the Code Generation Efficiency folder and select Run Selected Checks.
The results shows a Run Summary that flags check warnings. The warnings identify issues that impact code efficiency. For more information about the report, see View Model Advisor Check Reports.
Check Your Model Using the Model Advisor | Industry Standards | Coding Standards | Model Advisor Checks for Verifying Compliance with Secure Coding Standards | Modeling Guidelines for Model Configuration