Model Advisor Checks - MATLAB & Simulink (original) (raw)
Simulink Coder Checks Overview
Use Simulink® Coder™ Model Advisor checks to configure your model for code generation.
See Also
- Run Model Advisor Checks
- Simulink Checks
- Embedded Coder Checks (Embedded Coder)
Check reuse of subsystem code
Check ID:mathworks.codegen.SubsysCodeReuse
Identify CodeReuseSubsystem blocks that are not reusing code.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
One or more CodeReuseSubsystem blocks in the model do not reuse code. | Modify CodeReuseSubsystem blocks in the model so that they reuse code. |
Capabilities and Limitations
You can:
- Run this check on your library models.
- Look under masks,
- Exclude blocks and charts from this check if you have aSimulink Check™ license.
See Also
- Model Advisor Exclusion Overview (Simulink Check)
Check solver for code generation
Check ID:mathworks.codegen.SolverCodeGen
Check model solver and sample time configuration settings.
Description
Incorrect configuration settings can stop the code generator from producing code. Underspecifying sample times can lead to undesired results. Avoid generating code that might corrupt data or produce unpredictable behavior.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
The solver type is set incorrectly for model level code generation. | In the Configuration Parameters dialog box, on theSolver pane, set Type toFixed-step. |
Multitasking diagnostic options are not set toerror. | In the Configuration Parameters dialog box, on theDiagnostics pane, set Sample Time > Multitask conditionally executed subsystem toerrorSample Time > Multitask data transfer toerrorData Validity > Multitask data store toerror |
Tips
You do not have to modify the solver settings to generate code from a subsystem. The build process automatically changes Solver type to fixed-step
when you right-click on the subsystem and select > or > from the subsystem context menu.
See Also
Check for blocks not supported by code generation
Check ID:mathworks.codegen.codeGenSupport
Identify blocks not supported by code generation.
Description
This check partially identifies model constructs that are not suited for code generation as identified in the Simulink Block Support tables for Simulink Coder and Embedded Coder®. If you are using blocks with support notes for code generation, review the information and follow the given advice.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
The model or subsystem contains blocks that should not be used for code generation. | Consider replacing the blocks listed in the results. Click an element from the list of questionable items to locate condition. |
Capabilities and Limitations
You can:
- Run this check on your library models.
- Analyzes content of library linked blocks.
- Analyzes content in masked subsystems.
- Exclude blocks and charts from this check if you have aSimulink Check license.
See Also
- Use Products and Blocks Supported for Code Generation
- Model Advisor Exclusion Overview (Simulink Check)
Check and update model to use toolchain approach to build generated code
Check ID:mathworks.codegen.toolchainInfoUpgradeAdvisor.check
Check if model uses Toolchain settings to build generated code.
Description
Checks whether the model uses the template makefile approach or the toolchain approach to build the generated code.
Available with Simulink Coder.
When you open a model created before R2013b that has System target file set to ert.tlc
,ert_shrlib.tlc
, or grt.tlc
the software automatically tries to upgrade the model from using the template makefile approach to using the toolchain approach.
If the software does not upgrade the model, this check determines the cause, and if available, recommends actions you can perform to upgrade the model.
To determine which approach your model is using, you can also look at the Code Generation pane in the Configuration Parameters dialog box. The toolchain approach uses the following parameters to build generated code:
The template makefile approach uses the following settings to build generated code:
- Compiler optimization level
- Custom compiler optimization flags
- Generate makefile
- Template makefile
Results and Recommended Actions
Condition | Recommended Action | Comment |
---|---|---|
Model is configured to use the toolchain approach. | No action. | The model was automatically upgraded. |
Model is not configured to use the toolchain approach. | Model cannot be automatically upgraded to use the toolchain approach. | The system target file is not toolchain-compliant. SetSystem target file to a toolchain-compliant target, such as ert.tlc,ert_shrlib.tlc, orgrt.tlc. |
Model is not configured to use the toolchain approach. (Parameter values are not the default values.) | Model can be automatically upgraded to use the toolchain approach. Click Update Model. | The parameters are set to their default values, exceptCompiler Optimization Level, which is set to Optimizations on (faster runs). Clicking Update Model sets Compiler Optimization Level to its default value,Optimizations off (faster builds), and then upgrades the model. The upgraded model has Build Configuration set toFaster Builds. Saving the model makes the changes permanent. |
Model is not configured to use the toolchain approach. (Parameter values are not the default values and model is configured to generate a Microsoft® Visual Studio® solution) | Model can be automatically upgraded to use the toolchain approach. Click Update Model. | The parameters are set to their default values, exceptCompiler Optimization Level, which is set to Optimizations on (faster runs). Clicking Update Model sets Compiler Optimization Level to its default value,Optimizations off (faster builds), and then upgrades the model. The upgraded model uses a CMake toolchain and Build Configuration is set to: Specify ifCompiler Optimization Level is Optimizations on (faster runs)Debug ifCompiler Optimization Level is Optimizations off (faster builds)Saving the model makes the changes permanent. |
Model is not configured to use the toolchain approach. (Parameter values are not the default values.) | Model cannot be automatically upgraded to use the toolchain approach. | One or more of the following parameters is not set to its default value: Generate makefile (default: Enabled)Template makefile (default: Target-specific default TMF)Compiler optimization level (default: Optimizations off (faster builds))Make command (default:make_rtw without arguments)See Upgrade Model to Use Toolchain Approach |
Action Results
Clicking Update model upgrades the model to use the toolchain approach to build generated code.
See Also
Check whether model might require LCC compiler
Check ID:mathworks.codegen.LCCCheck.check
Check whether LCC is the default compiler.
Description
Check whether LCC is the default compiler for simulation workflows and generated code compilation on the MATLAB® computer.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
LCC is the compiler for model simulation and generated code compilation. | Specify another compiler. For example, by using the**Toolchain** configuration parameter. |
LCC is not the compiler for model simulation and generated code compilation. | No action. |
See Also
- Configure CMake Build Process
- Configure Toolchain (ToolchainInfo) or Template Makefile Build Process
Check and update embedded target model to use ert.tlc system target file
Check ID:mathworks.codegen.codertarget.check
Check and update the embedded target model to use ert.tlc system target file.
Description
Check and update models whose System target file is set to a file other than ert.tlc
and whose target hardware is one of the supported Texas Instruments® C2000™ processors to use ert.tlc
and similar settings.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
System target file is set toert.tlc - Embedded Coder. | No action |
System target file is set to a file other than ert.tlc andHardware board parameter is set to a processor that is supported by the Embedded Coder Support Package for Texas Instruments C2000 Processors. | Run the corresponding check in Upgrade Advisor: In the Modeling tab of Simulink Editor, click Model Advisor.Open the Upgrade Advisor pane and select check Check and update embedded target model to use ert.tlc system target file.Right-click on the check and selectRun This Check.After the check passes, open the Configuration Parameters dialog box, go to Hardware Implementation pane and confirm that the correctHardware board is selected. |
Action Results
Clicking Run This Check automatically sets the following parameters on the Code Generation pane in the model Configuration Parameters dialog box:
- System target file parameter to
ert.tlc
. - Toolchain parameter to match the previous toolchain.
- Build configuration parameter to match the build configuration.
Capabilities and Limitations
The new workflow uses the toolchain approach, which relies on enhanced makefiles to build generated code. It does not provide an equivalent to setting the Build format parameter toProject
in the previous configuration. Therefore, the new workflow cannot automatically generate IDE projects within the CCS 3.3 IDE.
See Also
Code Compilation Customization
Check and update models that are using targets that have changed significantly across different releases of MATLAB
Check ID:mathworks.codegen.realtime2CoderTargetInfoUpgradeAdvisor.check
Check and update models with Simulink targets that have changed significantly across different releases of MATLAB.
Description
Save a model that you have updated to work with the current installation of MATLAB.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
Model uses a target that has changed significantly since the release of MATLAB in which it was originally saved. | Save model |
Model does not use a Simulink target or is using the latest version of the target. | No action |
Model is automatically updated. | Save model |
Invalid external mode configuration. | In the Configuration Parameters > Interface pane, update the external mode parameter settings to match characteristics of your host-target connection. |
Model is corrupted. | Close and reopen the model. If the issue persists, reset Configuration Parameters > Hardware Implementation > Hardware board. |
Action Results
Clicking Save model updates the model to work with the current installation of MATLAB and saves the model.
See Also
Configure Production and Test Hardware
Check for blocks that have constraints on tunable parameters
Check ID:mathworks.codegen.ConstraintsTunableParam
Identify blocks with constraints on tunable parameters.
Description
Lookup Table blocks have strict constraints when they are tunable. If you violate lookup table block restrictions, the generated code produces incorrect answers.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
Lookup Table blocks have tunable parameters. | When tuning parameters during simulation or when running the generated code, you must: Preserve monotonicity of the setting for theVector of input values parameter.Preserve the number and location of zero values that you specify for Vector of input values and Vector of output values parameters if you specify multiple zero values for the Vector of input values parameter. |
Lookup Table (2-D) blocks have tunable parameters. | When tuning parameters during simulation or when running the generated code, you must: Preserve monotonicity of the setting for theRow index input values andColumn index of input values parameters.Preserve the number and location of zero values that you specify for Row index input values, Column index of input values, and Vector of output values parameters if you specify multiple zero values for the Row index input values or Column index of input values parameters. |
Lookup Table (n-D) blocks have tunable parameters. | When tuning parameters during simulation or when running the generated code, you must preserve the increasing monotonicity of the breakpoint values for each table dimensionBreakpoints n. |
Capabilities and Limitations
If you have a Simulink Check license, you can exclude blocks and charts from this check.
See Also
- 1-D Lookup Table
- 2-D Lookup Table
- Model Advisor Exclusion Overview (Simulink Check)
Check for model reference configuration mismatch
Check ID:mathworks.codegen.MdlrefConfigMismatch
Identify referenced model configuration parameter settings that do not match the top model configuration parameter settings.
Description
The code generator cannot create code for top models that contain referenced models with different, incompatible configuration parameter settings.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
The top model and the referenced model have inconsistent model configuration parameter settings. | Modify the specified model configuration settings. |
See Also
Check sample times and tasking mode
Check ID:mathworks.codegen.SampleTimesTaskingMode
Set up the sample time and tasking mode for your system.
Description
Incorrect tasking mode can result in inefficient code execution or incorrect generated code.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
The model represents a multirate system but is not configured for multitasking. | Select model configuration parameter Treat each discrete rate as a separate task. When you select the parameter, multitasking execution is applied for a multirate model. For more information, see Time-Based Scheduling and Code Generation. |
The model is configured for multitasking, but multitasking is not desirable on the target hardware. For example, the operating system does not support multiprocessing or the target hardware is bare metal (is not running an operating system) and the application does not provide for a multitasking execution scheme. | Clear model configuration parameter Treat each discrete rate as a separate task. When you clear the parameter, single-tasking execution is applied. For more information, seeTime-Based Scheduling and Code Generation. |
See Also
Time-Based Scheduling and Code Generation
Check for code generation identifier formats used for model reference
Check ID:mathworks.codegen.ModelRefRTWConfigCompliance
Checks for referenced models in a model referencing hierarchy for which code generation changes configuration parameter settings that involve identifier formats.
Description
In referenced models, if the following > > parameters have settings that do not contain a$R
token (which represents the name of the reference model), code generation prepends the $R
token to the identifier format.
- Global variables
- Global types
- Subsystem methods
- Constant macros
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
A script that operates on generated code uses model names that code generation changes. | Update the script to use the generated name (which includes an appended $R token). |
Check for relative execution order change for Data Store Read and Data Store Write blocks
Check ID:mathworks.design.datastoresimrtwcmp
Checks that the execution order of Data Store Read and Data Store Write blocks does not change when a model is compiled for code generation.
Description
The execution order defines the sequence in which the Data Store Read and Data Store Write blocks access the Data Store Memory block. The Model Advisor check compares the execution order from prior to running the check (normal simulation mode) to the execution order after compiling the check (code generation mode). The check passes when the execution order is the same. When there are differences, the check issues a Warning and identifies the discrepancies in the results.
Available with Simulink Coder.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
The execution order of the Data Store Read and Data Store Write blocks is different between simulation mode and code generation mode. | In the Model Advisor results, underAction, click Modify block priorities. The Model Advisor modifies the blocks so the execution order in simulation mode is the same as that in code generation mode. |
See Also
Available Checks for Code Generation Objectives
Code generation objectives checks facilitate designing and troubleshooting Simulink models and subsystems that you want to use to generate code. For more information about code generation objectives, see Application Objectives Using Code Generation Advisor.
The Code Generation Advisor includes the following checks from Simulink, Simulink Coder, and Embedded Coder for each of the code generation objectives. Two checks unique to the Code Generation Advisor are included below the list.
Note
When the Code Generation Advisor checks your model against the MISRA C:2012 guidelines objective, the tool does not consider all of the configuration parameter settings that are checked by the MISRA C:2012 guidelines checks in the Model Advisor. For a complete check of configuration parameter settings:
- Open the Model Advisor.
- Navigate to > .
- Run the checks in the folder.
For more information on using the Model Advisor, see Check Your Model Using the Model Advisor.
See Also
- Application Objectives Using Code Generation Advisor
- Configure Model for Code Generation Objectives by Using Code Generation Advisor (Embedded Coder)
- Run Model Advisor Checks
- Simulink Checks
- Model Advisor Checks
- Simulink Check Checks (Simulink Check)
Identify questionable blocks within the specified system
Identify blocks not supported by code generation or not recommended for deployment.
Description
The code generator creates code only for the blocks that it supports. Some blocks are not recommended for production code deployment.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
A block is not supported by the code generator. | Remove the specified block from the model or replace the block with the recommended block. |
A block is not recommended for production code deployment. | Remove the specified block from the model or replace the block with the recommended block. |
Check for Gain blocks whose value equals 1. | Replace Gain blocks with Signal Conversion blocks. |
Capabilities and Limitations
You can:
- Run this check on your library models.
- Exclude blocks and charts from this check if you have a Simulink Check license.
See Also
Use Products and Blocks Supported for Code Generation
Model Advisor Exclusion Overview (Simulink Check)
Check model configuration settings against code generation objectives
Check the configuration parameter settings for the model against the code generation objectives.
Description
Each parameter in the Configuration Parameters dialog box might have different recommended settings for code generation based on your objectives. This check helps you identify the recommended setting for each parameter so that you can achieve optimized code based on your objective.
Results and Recommended Actions
Condition | Recommended Action |
---|---|
Parameters are set to values other than the value recommended for the specified objectives. | Set the parameters to the recommended values. NoteA change to one parameter value can impact other parameters. Passing the check might take multiple iterations. |
Action Results
Clicking Modify Parameters under Action in the check window changes the parameter values to the recommended values.