Main Content

Embedded Coder Checks

Embedded Coder Checks Overview

Use Embedded Coder® Model Advisor checks to configure your model for code generation.

See Also

Check for blocks not recommended for C/C++ production code deployment

Check ID: mathworks.codegen.PCGSupport

Identify blocks not supported by code generation or not recommended for C/C++ production code deployment.

Description

This check partially identifies model constructs that are not recommended for C/C++ production code generation. For Simulink® Coder™ and Embedded Coder, these model construct identities appear in tables of Simulink Block Support.

In some instances, this check flags blocks that are supported for code generation. For these blocks, you should review the footnote information that is provided in the support notes and adhere to the recommended action provided by the Model Advisor.

Following the recommendations of this check increases the likelihood of generating code that complies with the CERT C, CWE, and ISO/IEC TS 17961 standards.

Available with Embedded Coder and Simulink Check™.

Results and Recommended Actions

ConditionRecommended Action
The model or subsystem contains blocks that should not be used for production code deployment.Consider replacing the blocks listed in the results. Click an element from the list of questionable items to locate condition.
The model or subsystem contains blocks that are supported but not recommended for production code generation.Review the support notes and adhere to the recommended action provided by the Model Advisor.

Capabilities and Limitations

You can:

  • Run this check on your library models.

  • Analyze content of library linked blocks.

  • Analyze content in masked subsystems.

  • Exclude blocks and charts if you have a Simulink Check license.

Edit-Time Checking

This check is supported by edit-time checking.

See Also

Check configuration parameters for generation of inefficient saturation code

Check ID: mathworks.codegen.EfficientTunableParamExpr

Check model configuration for optimization settings that can improve code efficiency.

Description

This check identifies model configuration parameters that are recommended for C/C++ production code generation. For Embedded Coder, these model configuration parameters improve code efficiency.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
The optimization suppresses code generation to guard against integer overflow for tunable parameter expression that you select. Select saturation code elimination.If you have Embedded Coder and are using an ERT-based system target file, select Configuration Parameter Remove Code from Tunable Parameter Expressions That Saturate Out-of-Range Values or set the parameter EfficientTunableParamExpr to on.
The optimization suppresses code generation that handles floating-point to integer conversion results for NaN values. Select conversion code elimination.If you have Embedded Coder and are using an ERT-based system target file, select Configuration Parameter Remove code from floating-point to integer conversions with saturation that maps NaN to zero or set the parameter EfficientMapNaN2IntZero to on.

Action Results

Clicking Modify Settings configures model optimization settings can impact the efficiency of code generation. There are no safety concerns for:

  • The Remove code from tunable parameter expressions that saturates out-of-range values parameter if your simulation contains the entire range of values for the parameters that are the terms of tunable expressions and Simulink does not generate a saturation warning.

  • The Remove code from floating-point to integer conversions with saturation that maps NaN to zero parameter if your model simulation does not contain a NaN input value.

Capabilities and Limitations

  • Does not run on library models.

  • Does not allow exclusions of blocks or charts.

See Also

Identify lookup table blocks that generate expensive out-of-range checking code

Check ID: mathworks.codegen.LUTRangeCheckCode

Identify lookup table blocks that generate code to protect against out-of-range inputs for breakpoint or index values.

Description

This check verifies that the following blocks do not generate code to protect against inputs that fall outside the range of valid breakpoint values:

This check also verifies that Interpolation Using Prelookup blocks do not generate code to protect against inputs that fall outside the range of valid index values.

Following the recommended actions increases both execution and ROM efficiency of the generated code.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action

The lookup table block generates out-of-range checking code.

Change the setting on the block dialog box so that out-of-range checking code is not generated.

  • For the 1-D Lookup Table, 2-D Lookup Table, n-D Lookup Table, and Prelookup blocks, select the check box for Remove protection against out-of-range input in generated code.

  • For the Interpolation Using Prelookup block, select the check box for Remove protection against out-of-range index in generated code.

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.

Action Results

Clicking Modify prevents lookup table blocks from generating out-of-range checking code, which makes the generated code more efficient.

Edit-Time Checking

This check is supported by edit-time checking.

See Also

Check output types of logic blocks

Check ID: mathworks.codegen.LogicBlockUseNonBooleanOutput

Identify logic blocks that do not use boolean for the output data type.

Description

This check verifies that the output data type of the following blocks is boolean:

  • Compare To Constant

  • Compare To Zero

  • Detect Change

  • Detect Decrease

  • Detect Fall Negative

  • Detect Fall Nonpositive

  • Detect Increase

  • Detect Rise Nonnegative

  • Detect Rise Positive

  • Interval Test

  • Interval Test Dynamic

  • Logical Operator

  • Relational Operator

Using output data type boolean increases execution efficiency of the generated code.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
The output data type of a logic block is not boolean. In the block dialog box, set Output data type to boolean.

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

Action Results

Clicking Modify forces logic blocks to use boolean as the output data type. If a logic block uses uint8 for the output type, clicking Modify changes the output type to boolean.

Check the hardware implementation

Check ID: mathworks.codegen.HWImplementation

Identify inconsistent or underspecified hardware implementation settings

Description

The Simulink and Simulink Coder software require two sets of target specifications. The first set describes the final intended production target. The second set describes the currently selected target. If the configurations do not match, the code generator creates extra code to emulate the behavior of the production target. Inconsistencies or underspecification of hardware attributes can lead to inefficient or incorrect code generation for the target hardware.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
Hardware implementation parameters are not set to recommended values.

In the Configuration Parameters dialog box, on the Hardware Implementation pane, specify the following parameters:

  • Byte ordering (ProdEndianess)

  • Production hardware signed integer division rounds to (ProdIntDivRoundTo)

In the Configuration Parameters dialog box, specify the following parameters:

  • Byte ordering in test hardware (TargetEndianess)

  • Test hardware signed integer division rounds to (TargetIntDivRoundTo)

Hardware implementation Production hardware settings do not match Test hardware settings.In the Configuration Parameters dialog box, consider selecting the Test hardware is the same as production hardware (ProdEqTarget) check box, or modify the settings to match.

See Also

Run-Time Environment Configuration

Identify questionable software environment specifications

Check ID: mathworks.codegen.SWEnvironmentSpec

Identify questionable software environment settings.

Description

  • Support for some software environment settings can lead to inefficient code generation and nonoptimal results.

  • Industry standards for C, such as ISO® and MISRA®, require identifiers to be unique within the first 31 characters.

  • Stateflow® charts with weak Simulink I/O data types lead to inefficient code.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
The maximum identifier length does not conform with industry standards for C.In the Configuration Parameters dialog box, on the Code Generation > Identifiers pane, set the Maximum identifier length parameter to 31 characters.
In the Configuration Parameters dialog box, the parameters on the Code Generation > Interface pane are not set to recommended values.

In the Configuration Parameters dialog box, on the Code Generation > Interface pane, clear the following parameters:

  • Support: continuous time

  • Support: non-finite numbers

In the Configuration Parameters dialog box, clear Support non-inlined S-functions.

In the Configuration Parameters dialog box, the parameters on the Code Generation > Identifiers pane are not set to recommended values.In the Configuration Parameters dialog box, on the Code Generation > Identifiers pane, set the Generate scalar inlined parameters as parameter to Literals.
In the Configuration Parameters dialog box, on the Code Generation > Interface pane, Support: variable-size signals is selected. This might lead to inefficient code.If you do not intend to support variable-sized signals, in the Configuration Parameters dialog box, on the Code Generation > Interface pane, clear Support: variable-size signals.
The model contains Stateflow charts with weak Simulink I/O data type specifications.Select the Stateflow chart property Use Strong Data Typing with Simulink I/O (Stateflow). You might need to adjust the data types in your model after selecting the property.

Limitations

A Stateflow license is required when using Stateflow charts.

See Also

Strong Data Typing with Simulink Inputs and Outputs (Stateflow)

Identify questionable code instrumentation (data I/O)

Check ID: mathworks.codegen.CodeInstrumentation

Identify questionable code instrumentation.

Description

  • Instrumentation of the generated code can cause nonoptimal results.

  • Test points require global memory and are not optimal for production code generation.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
Interface parameters are not set to recommended values.In the Configuration Parameters dialog box, on the Code Generation > Interface pane, set the parameters to the recommended values.
Blocks generate assertion code.In the Configuration Parameters dialog box, set Model Verification block enabling to Disable All on a block-by-block basis or globally.
Block output signals have one or more test points and, if you have an Embedded Coder license, the Ignore test point signals check box is cleared in the Configuration Parameters dialog box.

Remove test points from the specified block output signals. For each signal, in the Signal Properties dialog box, clear the Test point check box.

Alternatively, if the model is using an ERT-based system target file, select the Ignore test point signals check box in the Configuration Parameters dialog box to ignore test points during code generation.

Capabilities and Limitations

If you have a Simulink Check license, you can exclude blocks and charts from this check.

See Also

Identify blocks generating inefficient algorithms

Check ID: mathworks.codegen.UseRowMajorAlgorithm

Identify blocks generating inefficient algorithms.

Description

This check identifies the blocks that generate inefficient algorithms in the generated code based on the array layout of the model.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
The configuration parameter Array layout is set to Column-major for column-major code generation.Disable the configuration parameter Use algorithms optimized for row-major array layout.
The configuration parameter Array layout is set to Row-major for row-major code generation.Select the configuration parameter Use algorithms optimized for row-major array layout.

Capabilities and Limitations

  • Analyzes content in masked subsystems.

See Also

Check configuration parameters for MISRA C:2012

Check ID: mathworks.misra.CodeGenSettings

Identify configuration parameters that can impact MISRA C:2012 compliant code generation.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action
Math and Data Types
Configuration parameter Use division for fixed-point net slope computation is not set to On or Use division for reciprocals of integers only.Set Use division for fixed-point net slope computation to On or Use division for reciprocals of integers only.

Configuration parameter Inf or NaN block output is set to None or error and Support non-finite numbers is set to on.

Configuration parameter Inf or NaN block output is set to None and Support non-finite numbers is set to off.

When Support non-finite numbers is:

  • on, set Inf or NaN block output to warning

  • off, set Inf or NaN block output to warning or error

Configuration parameter Model Verification block enabling is set to Use local settings or Enable All.Set Model Verification block enabling to Disable All.
Configuration parameter Undirected event broadcasts is set to none or warning.Set Undirected event broadcasts to error.
Configuration parameter Wrap on overflow is set to NoneSet configuration parameter Wrap on overflow to warning or error.
Hardware Implementation
Configuration parameter Production hardware signed integer division rounds to is set to UndefinedSet Production hardware signed integer division rounds to to Zero or Floor.
Configuration parameter Shift right on a signed integer as arithmetic shift is selected.Clear Shift right on a signed integer as arithmetic shift.
Simulation Target
Configuration parameter Compile-time recursion limit for MATLAB functions is set to a value other than 0.Set Compile-time recursion limit for MATLAB functions to 0.
Configuration parameter Dynamic memory allocation in MATLAB functions is selected.Clear Dynamic memory allocation in MATLAB functions.
Configuration parameter Enable run-time recursion for MATLAB functions is selected.Clear Enable run-time recursion for MATLAB functions.
Code Generation

Configuration parameter Bitfield declarator type specifier is set to uchar_T when any of these parameters are selected:

  • Pack Boolean data into bitfields

  • Use bitsets for storing state configuration

  • Use bitsets for storing Boolean data

Set Bitfield declarator type specifier to uint_T.
Configuration parameter Casting Modes is not set to Standards Compliant.Set Casting Modes to Standards Compliant.
Configuration parameter Code replacement library is not set to None or AUTOSAR 4.0.

Set Code replacement library to None or AUTOSAR 4.0

Configuration parameter External mode is selected.Clear External mode.
Configuration parameter Generate shared constants is selected.Clear Generate shared constants.

Configuration parameter Include comments is cleared.

Select Include comments.
Configuration parameter MAT-file logging is selected.

Clear MAT-file logging

For ERT-based target systems, configuration parameter MATLAB user comments is cleared.Select MATLAB user comments.
A value for configuration parameter Maximum identifier length is not provided.Set the value to the implementation-dependent limit. The default is 31.
Configuration parameter Parenthesis level is not set to Maximum (Specify precedence with parentheses).Set Parentheses level to Maximum (Specify precedence with parentheses).

For ERT-based target systems, configuration parameter Preserve static keyword in function declarations is cleared when File packaging format is set to Compact or Compact (with separate data file)

Select Preserve static keyword in function declarations.
Configuration parameter Replace multiplications by powers of two with signed bitwise shifts is selected.Clear Replace multiplications by powers of two with signed bitwise shifts.
Configuration parameter Shared code placement is set to Auto.

Set Shared code placement to Shared location

For ERT-based target systems, configuration parameter Support continuous time is selected Clear Support continuous time.
For ERT-based target systems, configuration parameter Support non-inlined S-functions is selected Clear Support non-inlined S-functions.
Configuration parameter System-generated identifiers is set to Classic.Set System-generated identifiers to Shortened.
Configuration parameter System target file is set to a GRT-based target.Set System target file to an ERT-based target.
Configuration parameter Use dynamic memory allocation for model initialization is selected when Code Interface Packaging is set to Reusable Function.

Clear Use dynamic memory allocation for model initialization.

Note

Select only when Code Interface Packaging is set to Reusable Function.

Action Results

Clicking Modify All changes the parameter values to the recommended values.

Note

When you click Modify All for models with a GRT-based target, the Model Advisor does not update the System target file configuration parameter to an ERT-based system.

Parameter subchecks depend on the results of the parameter noted with D in the results table. When the result is D-Warning, the Current Value column in the results table states Prerequisite constraint not met for the subchecks. After you change the parameter, rerun the check.

Note

Some subchecks are specific to configuration parameters for ERT-based systems. These parameters are not updated when you click Modify All unless you change the model to an ERT-based system.

Capabilities and Limitations

This check does not review referenced models.

See Also

Check for blocks not recommended for MISRA C:2012

Check ID: mathworks.misra.BlkSupport

Identify blocks that are not supported or recommended for MISRA C:2012 compliant code generation.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action

Lookup Table blocks using cubic spline interpolation or extrapolation methods were found in the model or subsystem. Specific blocks are:

Consider other interpolation and extrapolation methods for the Lookup Table blocks.

Deprecated Lookup Table blocks were found in the model or subsystem. Specific blocks are:

  • Lookup Table

  • Lookup Table (2-D)

Consider replacing the deprecated Lookup Table blocks.
S-Function Builder blocks were found in the model or subsystem.Consider replacing the S-Function Builder blocks with blocks recommended for production.
From Workspace blocks were found in the model or subsystemConsider replacing the From Workspace blocks with blocks recommended for production.

String blocks were found in the model or subsystem. Specific blocks are:

Consider replacing the String blocks with blocks recommended for production.

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.

Edit-Time Checking.  This check is supported by edit-time checking.

See Also

Check for unsupported block names

Check ID: mathworks.misra.BlockNames

Identify block names containing /.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action
Block names containing / were found in the model or subsystem.Remove / from the block name.

Capabilities and Limitations

  • Runs on library models.

  • Analyzes content of library linked blocks.

  • Analyzes content in masked subsystems.

  • If you have a Simulink Check license, allows exclusions of blocks and charts.

Edit-Time Checking.  This check is supported by edit-time checking.

See Also

Check usage of Assignment blocks

Check ID: mathworks.misra.AssignmentBlocks

Identify Assignment blocks that do not have block parameter Action if any output element is not assigned set to Error or Warning.

Description

This check applies to the Assignment block that is available in the Simulink block library under Simulink > Math Operations.

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications, as well as code that complies with the CERT C, CWE, ISO/IEC TS 17961 standards.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action
The model or subsystem might contain Assignment blocks with incomplete array initialization that do not have block parameter Action if any output element is not assigned set to Error or Warning.

Set block parameter Action if any output element is not assigned to one of the recommended values:

  • Error, if Assignment block is not in an Iterator subsystem.

  • Warning, if Assignment block is in an Iterator subsystem.

Capabilities and Limitations

  • Runs on library models.

  • Analyzes content of library linked blocks.

  • Analyzes content in masked subsystems.

  • If you have a Simulink Check license, allows exclusions of blocks and charts.

Edit-Time Checking.  This check is supported by edit-time checking. However, the following check condition is not supported because edit-time checking is unable to determine whether the Assignment block is in an Iterator subsystem.

Set block parameter Action if any output element is not assigned to one of the recommended values:

  • Error, if Assignment block is not in an Iterator subsystem.

  • Warning, if Assignment block is in an Iterator subsystem.

See Also

Check for switch case expressions without a default case

Check ID: mathworks.misra.SwitchDefault

Identify switch case expressions that do not have a default case.

Description

The check flags model objects that have switch case expressions without a default case.

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications, as well as code that complies with the CERT C, CWE, ISO/IEC TS 17961 standards.

The check does not flag blocks without default cases if they are justified with a Polyspace® annotation. When you run the check, the Blocks with justification table lists blocks without default cases that have a justification.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action

Model object has a switch case expression without a default case.

For Switch Case blocks, consider selecting block parameter Show default case to explicitly specify a default case.

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.

Edit-Time Checking.  This check is supported by edit-time checking.

See Also

Check for missing error ports for AUTOSAR receiver interfaces

Check ID: mathworks.misra.AutosarReceiverInterface

Identify AUTOSAR receiver interface inports that do not have matching error ports.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications. The check flags AUTOSAR receiver interfaces inports that are missing error ports. The following table identifies the AUTOSAR data access mode types for receiver interface ports that are flagged by the check when the corresponding error port is missing.

AUTOSAR Data Access Mode TypeFlagged by Check?
ImplicitReceiveYes
ExplicitReceiveYes
QueuedExplicitReceiveNo
ErrorStatusNo
ModeReceiveNo
IsUpdatedNo
EndToEndReadYes
ExplicitReceiveByValNo
otherwiseNo

The check does not flag missing error ports when they are justified with a Polyspace annotation. When you run the check, the Blocks with justification table lists the missing error ports that have a justification.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action

AUTOSAR receiver interface inport does not have a matching error port.

Add missing error port and map to the corresponding AUTOSAR receiver interface inport.

AUTOSAR receiver interface ports do not have a matching error port when data access mode is ImplicitReceive, ExplicitReceive, or EndToEndRead.

Add missing error port and map to the corresponding AUTOSAR receiver interface inport.

Capabilities and Limitations

You can:

  • Analyzes top layer/root level models.

  • Exclude blocks and charts from this check if you have a Simulink Check license.

See Also

Check bus object names that are used as bus element names

Check ID: mathworks.misra.BusElementNames

Identify bus object names that are used as bus element names.

Description

Using this check increases the likelihood of generating code for embedded applications that is compliant with MISRA C:2012. The check flags instances where a Simulink.Bus object name is used as the Simulink.Bus element name.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action
A bus object name is being used as a bus element name.Change either the flagged bus object name or the bus element name so that they are not identical.

See Also

Check configuration parameters for secure coding standards

Check ID: mathworks.security.CodeGenSettings

Identify configuration parameters that might impact compliance with secure coding standards.

Description

Following the recommendations of this check increases the likelihood of generating code that complies with CERT C, CWE, ISO/IEC TS 17961 secure coding standards.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action
Diagnostics

Configuration parameter Inf or NaN block output is set to None or error and Support non-finite numbers is set to on.

Configuration parameter Inf or NaN block output is set to None and Support non-finite numbers is set to off.

When Support non-finite numbers is:

  • on, set Inf or NaN block output to warning.

  • off, set Inf or NaN block output to warning or error.

Configuration parameter Model Verification block enabling is set to Use local settings or Enable All.Set Model Verification block enabling to Disable All.
Configuration parameter Undirected event broadcasts is set to none or warning.Set Undirected event broadcasts to error.
Configuration parameter Wrap on overflow is set to none.Set Wrap on overflow to warning or error.
Hardware Implementation
Configuration parameter Production hardware signed integer division rounds to is set to Undefined.Set Production hardware signed integer division rounds to to Zero or Floor.
Configuration parameter Shift right on a signed integer as arithmetic shift is selected.Clear Shift right on a signed integer as arithmetic shift.
Simulation Target
Configuration parameter Compile-time recursion limit for MATLAB functions is set to a value other than 0.Set Compile-time recursion limit for MATLAB functions to 0.
Configuration parameter Dynamic memory allocation in MATLAB functions is selected.Clear Dynamic memory allocation in MATLAB functions.
Configuration parameter Enable run-time recursion for MATLAB functions is selected.Clear Enable run-time recursion for MATLAB functions.
Code Generation
Configuration parameter Code replacement library is not set to None or AUTOSAR 4.0.Set Code replacement library to None or AUTOSAR 4.0.
Configuration parameter External mode is selected.Clear External mode.

Configuration parameter Include comments is cleared.

Select Include comments.
Configuration parameter MAT-file logging is selected.Clear MAT-file logging.
For ERT-based target systems, configuration parameter MATLAB user comments is cleared.Select MATLAB user comments.
Configuration parameter Replace multiplications by powers of two with signed bitwise shifts is selected.Clear Replace multiplications by powers of two with signed bitwise shifts.
For ERT-based target systems, configuration parameter Support continuous time is selected Clear Support continuous time.
For ERT-based target systems, configuration parameter Support non-inlined S-functions is selected Clear Support non-inlined S-functions.
Configuration parameter System target file is set to a GRT-based target.Set System target file to an ERT-based target.
Configuration parameter Use dynamic memory allocation for model initialization is selected.Clear Use dynamic memory allocation for model initialization.

Note

Select only when Code Interface Packaging is set to Reusable Function.

Action Results

Clicking Modify All changes the parameter values to the recommended values.

Note

When you click Modify All for models with a GRT-based target, the Model Advisor does not update the System target file configuration parameter to an ERT-based system.

Parameter subchecks depend on the results of the parameter noted with D in the results table. When the result is D-Warning, the Current Value column in the results table states Prerequisite constraint not met for the subchecks. After you change the parameter, rerun the check.

Note

Some subchecks are specific to configuration parameters for ERT-based systems. These parameters are not updated when you click Modify All unless you change the model to an ERT-based system.

See Also

Secure Coding Standards

Check for blocks not recommended for secure coding standards

Check ID: mathworks.security.BlockSupport

Identify blocks not recommended for compliance with secure coding standards.

Description

Following the recommendations of this check increases the likelihood of generating code that complies with CERT C, CWE, ISO/IEC TS 17961 secure coding standards.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action

Lookup Table blocks using cubic spline interpolation or extrapolation methods were found in the model or subsystem. Specific blocks are:

Consider other interpolation and extrapolation methods for the Lookup Table blocks.

Deprecated Lookup Table blocks were found in the model or subsystem. Specific blocks are:

  • Lookup Table

  • Lookup Table (2-D)

Consider replacing the deprecated Lookup Table blocks.
S-Function Builder blocks were found in the model or subsystem.Consider replacing the S-Function Builder blocks with blocks recommended for production.
From Workspace blocks were found in the model or subsystemConsider replacing the From Workspace blocks with blocks recommended for production.

String blocks were found in the model or subsystem. Specific blocks are:

Consider replacing the String blocks with blocks recommended for production.

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.

Edit-Time Checking.  This check is supported by edit-time checking.

See Also

Identify questionable subsystem settings

Check ID: mathworks.codegen.QuestionableSubsysSetting

Identify questionable subsystem block settings.

Description

Subsystem blocks implemented as void-void functions in the generated code use global memory to store the subsystem I/O.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
Subsystem blocks have the Subsystem Parameters > Function packaging option set to Nonreusable function.Set the Subsystem Parameters > Function packaging parameter to Auto.
Subsystem blocks have the Subsystem Parameters > Function packaging option set to Reusable function.Set the Subsystem Parameters > Function packaging parameter to Auto.

Capabilities and Limitations

If you have a Simulink Check license, you can exclude blocks and charts from this check.

See Also

Check for blocks not supported for row-major code generation

Check ID: mathworks.codegen.RowMajorCodeGenSupport

Check for blocks not supported for row-major code generation.

Description

This check identifies the blocks that are not supported for row-major code generation.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
The model interfaces with external data that is in row-major array layout.Set the configuration parameter Array layout to Row-major.

Capabilities and Limitations

  • Analyzes content in masked subsystems.

See Also

Identify TLC S-Functions with unset array layout

Check ID: mathworks.codegen.RowMajorUnsetSFunction

Identify TLC S-Functions with unset array layout.

Description

This check identifies S-functions that have SSArrayLayout set to SS_UNSET. By default, every S-function has SSArrayLayout property set to SS_UNSET. This setting disables the S-function for row-major code generation. When the configuration parameter Array layout is set to Row-major, the Embedded Coder reports an error. You can turn off the error by changing the External functions compatibility for row-major code generation to warning or none.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
The configuration parameter Array layout is set to Column-major for column-major code generation.Set the SSArrayLayout property to Column-major.
The configuration parameter Array layout is set to Row-major for row-major code generation.Set the SSArrayLayout property to Row-major.

Capabilities and Limitations

  • Analyzes content in all masked subsystems.

See Also

Identify blocks that generate expensive fixed-point and saturation code

Check ID: mathworks.codegen.BlockSpecificQuestionableFxptOperations

Identify fixed-point operations that can lead to nonoptimal results.

Description

Certain block settings can lead to expensive fixed-point and saturation code.

Results and Recommended Actions

ConditionsRecommended Action
Blocks generate expensive saturation code.Check whether your application requires setting Function Block Parameters > Signal Attributes > Saturate on integer overflow. Otherwise, clear the Saturate on integer overflow parameter for the most efficient implementation of the block in the generated code.
Product blocks are multiplying signals with mismatched slope adjustment factors. The net slope computation uses multiplication followed by shifts, which is inefficient for some target hardware.

Set the Optimization > Use division for fixed-point net slope computation parameter to On, or Use division for reciprocals of integers only if the net slope can be approximated by a fraction and division is more efficient than multiplication and shifts on the target hardware.

Note

This optimization takes place only if certain simplicity and accuracy conditions are met. For more information, see Handle Net Slope Computation (Fixed-Point Designer).

Product blocks are configured with a divide operation for the first input and a multiply operation for the second input. Reverse the inputs so the multiply operation occurs first and the division operation occurs second.
Product blocks are configured to do multiple division operations.Multiply all the denominator terms together, and then do a single division using cascading Product blocks.
Product blocks are configured to do many multiplication or division operations.Split the operations across several blocks, with each block performing one multiplication or one division operation.
Protection code generated as part of the division operation is redundant.Verify that your model cannot cause exceptions in division operations and then remove redundant protection code by setting the Optimization > Remove code that protects against division arithmetic exceptions parameter in the Configuration Parameters dialog box.
The data type range of the inputs of Sum blocks exceeds the data type range of the output, which can cause overflow or saturation.

Change the output and accumulator data types so the range equals or exceeds all input ranges.

For example, if the model has two inputs

  • int8 (–128 to 127)

  • uint8 (0 to 255)

The data type range of the output and accumulator must equal or exceed –128 to 255. A int16 (–32768 to 32767) data type meets this condition.

A Sum block has an input with a slope adjustment factor that does not equal the slope adjustment factor of the output.Change the data types so the inputs, outputs, and accumulator have the same slope adjustment factor.
The net sum of the Sum block input biases does not equal the bias of the output. Change the bias of the output scaling, making the net bias adjustment zero.
The input and output of the MinMax block have different data types.Change the data type of the input or output.
The input of the MinMax block has a different slope adjustment factor than the output. Change the scaling of the input or the output.
The initial condition of the Discrete-Time Integrator block is used to initialize both the state and the output. Set the Function Block Parameters > Initial condition setting parameter to State (most efficient).
Parameter overflow occurred for the Compare to Zero block. This block uses the input data type to represent zero. The input data type cannot represent zero exactly, so the input value was compared to the closest representable value of zero.Select an input data type that can represent zero.
Parameter overflow occurred for the following Compare to Constant block. This block uses the input data type to represent its Constant value parameter. The Constant value parameter is outside the range that the input data type can represent. The input signal was compared to the closest representable value of the Constant value parameter.Choose an input data type that can represent the Constant value parameter or change the Constant value parameter to match the input data type.

Capabilities and Limitations

  • A Fixed-Point Designer™ license is required to generate fixed-point code.

  • If you have a Simulink Check license, you can exclude blocks and charts from this check.

See Also

Check for missing const qualifiers in model functions

Check ID: mathworks.misra.ModelFunctionInterface

Identify missing const qualifiers in input data pointers.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications. The check flags input data pointers that do not have a const qualifier.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action
A const qualifier is not defined for the input data pointer.Consider adding a const qualifier to the input data pointer.

See Also

Identify questionable fixed-point operations

Check ID: mathworks.codegen.QuestionableFxptOperations

Identify fixed-point operations that can lead to nonoptimal results.

Description

Less efficient code can result from blocks that generate cumbersome multiplication and division operations, expensive conversion code, inefficiencies in lookup table blocks, and expensive comparison code.

Results and Recommended Actions

ConditionsRecommended Action
Integer division generated code is large.In the Configuration Parameters dialog box, on the Hardware Implementation pane, set the Production hardware signed integer division rounds to parameter to the recommended value.
Lookup Table vector of input values is not evenly spaced.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_look1_func_approx.
Lookup Table vector of input values is not evenly spaced when quantized, but it is very close to being evenly spaced.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_evenspace_cleanup.
Lookup Table vector of input values is evenly spaced, but the spacing is not a power of 2.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_look1_func_approx.
For a Prelookup or n-D Lookup Table block, Index search method is Evenly spaced points. Breakpoint data does not have power of 2 spacing.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. Otherwise, in the block parameter dialog box, specify a different Index search method to avoid the computation-intensive division operation.
n-D Lookup Table breakpoint data is not evenly spaced and Index search method is not Evenly spaced points.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing and then set Index search method to Evenly spaced points.
n-D Lookup Table breakpoint data is evenly spaced and Index search method is Evenly spaced points. But the spacing is not a power of 2.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_look1_func_approx.
n-D Lookup Table breakpoint data is evenly spaced, but the spacing is not a power of 2. Also, Index search method is not Evenly spaced points.Set Index search method to Evenly spaced points. Also, if the data is nontunable, consider an even, power of 2 spacing.
n-D Lookup Table breakpoint data is evenly spaced, and the spacing is a power of 2. But the Index search method is not Evenly spaced points.Set Index search method to Evenly spaced points.
Blocks require multiword operations in generated code.Adjust the word lengths of inputs to operations so that they do not exceed the largest word size of your processor. For more information, see Fixed-Point Multiword Operations In Generated Code (Fixed-Point Designer).
Blocks require cumbersome multiplication.

Restrict multiplication operations:

  • So the product integer size is not larger than the target integer size.

  • To the recommended size.

Product blocks are multiplying signals with mismatched slope adjustment factors.Change the scaling of the output so that its slope adjustment factor is the product of the input slope adjustment factors.
Blocks multiply signals with nonzero bias.Insert a Data Type Conversion block before and after the block containing the multiplication operation.
The inputs of the Relational Operator block have different data types.
  • Change the data type and scaling of the invariant input to match other inputs.

  • Insert Data Type Conversion blocks before the Relational Operator block to convert both inputs to a common data type.

The inputs of the Relational Operator block have different slope adjustment factors.Change the scaling of either input.
The output of the Relational Operator block is constant. This might result in dead code which will be eliminated by Simulink Coder.Review your model design and either remove the Relational Operator block or replace it with the constant.

Capabilities and Limitations

  • A Fixed-Point Designer license is required to generate fixed-point code.

  • If you have a Simulink Check license, you can exclude blocks and charts from this check.

See Also

Identify blocks that generate expensive rounding code

Check ID: mathworks.codegen.ExpensiveSaturationRoundingCode

Check for blocks that generate expensive rounding code.

Description

Generated rounding code is inefficient because of Integer rounding mode parameter setting.

Available with Embedded Coder.

Results and Recommended Actions

ConditionRecommended Action
Generated code is inefficient.Set the Function Block Parameters > Integer rounding mode parameter to the recommended value.

Capabilities and Limitations

If you have a Simulink Check license, you can exclude blocks and charts from this check.

See Also

Check for bitwise operations on signed integers

Check ID: mathworks.misra.CompliantCGIRConstructions

Identify Simulink blocks that contain bitwise operations on signed integers.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications, as well as code that complies with the CERT C and CWE standards.

Available with Embedded Coder and Simulink Check.

This check requires a Stateflow license when Stateflow is used in the model.

Results and Recommended Actions

ConditionRecommended Action
The model has blocks that contain bitwise operations on signed integers.Consider using unsigned integers for bitwise operations.

Capabilities and Limitations

You can:

  • The check assumes that code is generated for the whole model. When code is generated by a subsystem build or export functions, the check can product incorrect results.

  • Exclude blocks and charts from this check if you have a Simulink Check license.

See Also

Check for recursive function calls

Check ID: mathworks.misra.RecursionCompliance

Identify recursive function calls in Stateflow charts.

Description

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications. The check flags charts that have recursive function calls.

Available with Embedded Coder and Simulink Check.

This check requires a Stateflow license.

Results and Recommended Actions

ConditionRecommended Action

Chart has a recursive function call.

Remove recursive function call.

See Also

Check for equality and inequality operations on floating-point values

Check ID: mathworks.misra.CompareFloatEquality

Identify equality and inequality operations on floating-point values.

Description

The check flags sources causing equality or inequality operations on floating-point values.

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications, as well as code that complies with the CERT C and CWE standards.

The check does not flag blocks with equality or inequality operations on floating-point values if they are justified with a Polyspace annotation. When you run the check, the Blocks with justification table lists blocks with equality or inequality operations that have a justification.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action

Model object has an equality or inequality operation on a floating-point value.

Consider using non-floating-point values for equality or inequality operations.

Capabilities and Limitations

You can:

  • Exclude blocks and charts from this check if you have a Simulink Check license.

See Also

Check integer word length

Check ID: mathworks.misra.IntegerWordLengths

Identify integer word lengths that do not comply with hardware implementation settings

Description

The check flags integers whose word lengths exceed the number of bits permitted via the hardware implementation settings.

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications, as well as code that complies with the CERT C and CWE standards.

Available with Embedded Coder and Simulink Check.

Results and Recommended Actions

ConditionRecommended Action

Model object contains integer word lengths that are not compliant with hardware implementation settings.

Update the integer so its length does not exceed the permitted number of bits. You can view the permitted number of bits in the Configuration Parameters dialog box, on the Hardware Implementation > Device details pane.

Capabilities and Limitations

You can:

  • Exclude blocks and charts from this check if you have a Simulink Check license.

See Also

Check block names

Check ID: mathworks.codegen.BlockNames

Checks whether block names in the Code Perspective pane include invalid characters.

Description

This edit-time check evaluates the block names in the Code Perspective pane. The check reports invalid characters in block names, except for:

  • Blocks that are ignored or not recommended for code generation

  • Virtual Subsystem blocks

The check verifies that block names comply with these guidelines:

Form:

name:

  • Does not start with a number

  • Does not include spaces at the beginning of a block name

  • Does not use double byte characters

  • Carriage returns are allowed

Allowed Characters:

name:

a b c d e f g h i j k l m n o p q r s t u v w x y z

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

0 1 2 3 4 5 6 7 8 9 _

Results and Recommended Actions

ConditionRecommended Action

The block name in the Code Perspective pane does not conform to the guidelines.

Update the block name to comply with the guidelines.

Capabilities and Limitations

  • Runs on library models.

  • Analyzes content of library-linked blocks.

  • Analyzes content in masked subsystems.

  • Allows exclusions of blocks and charts.

See Also