Model Advisor Checks
Simulink Coder Checks Overview
Use Simulink® Coder™ Model Advisor checks to configure your model for code generation.
See Also
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 a Simulink 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 the
Solver pane, set Type to
|
Multitasking diagnostic options are not set to
error . | In the Configuration Parameters dialog box, on the Diagnostics pane, set
|
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 C/C++ Code
> Build This Subsystem or C/C++
Code > Generate S-Function 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 a Simulink Check license.
See Also
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. Set
System target file to a
toolchain-compliant target, such as ert.tlc ,
ert_shrlib.tlc , or
grt.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, except
Compiler 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 to
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 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, except
Compiler Optimization Level, which
is set to
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:
|
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
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 to
ert.tlc - Embedded Coder . | No action |
System target file is set to a
file other than | Run the corresponding check in Upgrade Advisor:
|
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 to
Project
in the previous configuration. Therefore,
the new workflow cannot automatically generate IDE projects within the CCS 3.3
IDE.
See Also
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
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:
|
Lookup Table (2-D) blocks have tunable parameters. | When tuning parameters during simulation or when running the generated code, you must:
|
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 dimension Breakpoints n. |
Capabilities and Limitations
If you have a Simulink Check license, you can exclude blocks and charts from this check.
See Also
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, see Time-Based Scheduling and Code Generation. |
See Also
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 Configuration Parameters > Code Generation > Identifiers 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 |
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, under Action, 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.
Check | Execution efficiency
(all targets) | ROM
efficiency (ERT-based targets) | RAM
efficiency (ERT-based targets) | Safety
precaution (ERT-based targets) | Traceability (ERT-based targets) | Debugging (all targets) | MISRA C:2012
guidelines (ERT-based targets) | Polyspace®
(ERT-based targets) |
---|---|---|---|---|---|---|---|---|
Check model configuration settings against code generation objectives | Included | Included | Included | Included | Included | Included | Included (see Note below) | Included |
Check for optimal bus virtuality | Included | Included | Included | N/A | N/A | N/A | N/A | N/A |
Identify questionable blocks within the specified system | Included | Included | Included | N/A | N/A | N/A | N/A | N/A |
Check the hardware implementation (Embedded Coder) | Included if Embedded Coder is available | Included if Embedded Coder is available | N/A | N/A | N/A | N/A | N/A | N/A |
Identify questionable software environment specifications (Embedded Coder) | Included when Traceability is not a higher priority and Embedded Coder is available | Included when Traceability is not a higher priority and Embedded Coder is available | N/A | N/A | N/A | N/A | N/A | N/A |
Identify questionable code instrumentation (data I/O) (Embedded Coder) | Included when Traceability or Debugging are not higher priorities and Embedded Coder is available | Included when Traceability or Debugging are not higher priorities and Embedded Coder is available | Included when Traceability or Debugging are not higher priorities and Embedded Coder is available | N/A | N/A | N/A | N/A | N/A |
Identify questionable subsystem settings (Embedded Coder) | N/A | Included if Embedded Coder is available | Included if Embedded Coder is available | N/A | N/A | N/A | N/A | N/A |
Identify blocks that generate expensive rounding code (Embedded Coder) | Included if Embedded Coder is available | Included if Embedded Coder is available | N/A | N/A | N/A | N/A | N/A | N/A |
Identify questionable fixed-point operations (Embedded Coder) | Included if Embedded Coder or Fixed-Point Designer™ is available | Included if Embedded Coder or Fixed-Point Designer is available | N/A | N/A | N/A | N/A | N/A | N/A |
Identify lookup table blocks that generate expensive out-of-range checking code (Embedded Coder) | Included if Embedded Coder is available | Included if Embedded Coder is available | N/A | N/A | N/A | N/A | N/A | N/A |
Check output types of logic blocks (Embedded Coder) | Included if Embedded Coder is available | N/A | N/A | N/A | N/A | N/A | N/A | N/A |
N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A | |
Check Data Store Memory blocks for multitasking, strong typing, and shadowing issues | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Identify block output signals with continuous sample time and non-floating point data type | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Check for blocks that have constraints on tunable parameters | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Check if read/write diagnostics are enabled for data store blocks | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Check structure parameter usage with bus signals | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Check data store block sample times for modeling errors | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Check for potential ordering issues involving data store access | N/A | N/A | N/A | Included | N/A | N/A | N/A | N/A |
Check for blocks not recommended for C/C++ production code deployment (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check for blocks not recommended for MISRA C:2012 (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check for unsupported block names (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check usage of Assignment blocks (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check for bitwise operations on signed integers (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check for recursive function calls (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check for equality and inequality operations on floating-point values (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check for switch case expressions without a default case (Embedded Coder) | N/A | N/A | N/A | N/A | N/A | N/A | Included if Embedded Coder is available | N/A |
Check configuration parameters for generation of inefficient saturation code (Embedded Coder) | Included if Embedded Coder is available | Included if Embedded Coder is available | N/A | Included if Embedded Coder is available | N/A | N/A | N/A | N/A |
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 By Task > Modeling Guidelines for MISRA C:2012.
Run the checks in the folder.
For more information on using the Model Advisor, see Check Your Model Using the Model Advisor.
See Also
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. Note A 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.