Embedded Coder Checks - MATLAB & Simulink (original) (raw)

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 information 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™.

Condition Recommended 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:

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.

Action Results

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

Capabilities and Limitations

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.

Condition Recommended 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, Direct 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 forRemove protection against out-of-range index in generated code.

Capabilities and Limitations

You can:

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 isboolean:

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

Available with Embedded Coder.

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

Capabilities and Limitations

You can:

See Also

Action Results

Clicking Modify forces logic blocks to useboolean as the output data type. If a logic block usesuint8 for the output type, clickingModify changes the output type toboolean.

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.

Condition Recommended 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

Target Platform Device Customization

Identify questionable software environment specifications

Check ID:mathworks.codegen.SWEnvironmentSpec

Identify questionable software environment settings.

Description

Available with Embedded Coder.

Condition Recommended Action
The maximum identifier length does not conform with industry standards for C. In the Configuration Parameters dialog box, on theCode Generation > Identifiers pane, set the Maximum identifier length parameter to31 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 > pane, clear the following parameters:Support: continuous time Support: non-finite numbersIn 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 toLiterals.
In the Configuration Parameters dialog box, on theCode Generation >Interface pane,Support: variable-size signals is selected. This might lead to inefficient code. If you do not intend to support variable-size 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. You might need to adjust the data types in your model after selecting the property.NoteStarting in R2022a, you cannot disable the chart property Use strong data typing with Simulink I/O. For more information, see Use strong data typing with Simulink I/O chart property has been removed (Stateflow).

Limitations

A Stateflow license is required when using Stateflow charts.

Identify questionable code instrumentation (data I/O)

Check ID:mathworks.codegen.CodeInstrumentation

Identify questionable code instrumentation.

Description

Available with Embedded Coder.

Condition Recommended Action
Interface parameters are not set to recommended values. In the Configuration Parameters dialog box, on the > pane, set the parameters to the recommended values.
Blocks generate assertion code. In the Configuration Parameters dialog box, set Model Verification block enabling toDisable 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.

Condition Recommended 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

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.

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

Capabilities and Limitations

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 parameterAction if any output element is not assigned set toError or Warning.

Description

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

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.

Condition Recommended Action
The model or subsystem might contain Assignment blocks with incomplete array initialization that do not have block parameterAction if any output element is not assigned set to Error orWarning. Set block parameter Action if any output element is not assigned to one of the recommended values: Error, ifAssignment block is not in an Iterator subsystem.Warning, ifAssignment block is in an Iterator subsystem.

Capabilities and Limitations

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:

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.

Condition Recommended 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:

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 Type Flagged by Check?
ImplicitReceive Yes
ExplicitReceive Yes
QueuedExplicitReceive No
ErrorStatus No
ModeReceive No
IsUpdated No
EndToEndRead Yes
ExplicitReceiveByVal No
otherwise No

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.

Condition Recommended 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, orEndToEndRead. Add missing error port and map to the corresponding AUTOSAR receiver interface inport.

Capabilities and Limitations

You can:

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.

Condition Recommended 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.

Condition Recommended Action
Diagnostics
Configuration parameterInf or NaN block output is set toNone orerror and Support non-finite numbers is set toon.Configuration parameter Inf or NaN block output is set toNone and Support non-finite numbers is set tooff. When Support non-finite numbers is: on, set Inf or NaN block output towarning.off, set Inf or NaN block output towarning orerror.
Configuration parameter Model Verification block enabling is set to Use local settings or Enable All. Set Model Verification block enabling toDisable All.
Configuration parameter Undirected event broadcasts is set to none orwarning. Set Undirected event broadcasts toerror.
Configuration parameter Wrap on overflow is set to none. Set Wrap on overflow towarning orerror.
Hardware Implementation
Configuration parameter Production hardware signed integer division rounds to is set toUndefined. Set Production hardware signed integer division rounds to to Zero orFloor.
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.x. Set Code replacement library toNone or AUTOSAR 4.x.
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 parameterSupport continuous time is selected Clear Support continuous time.
For ERT-based target systems, configuration parameterSupport 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.NoteSelect 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

MISRA C

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.

Condition Recommended Action
Lookup Table blocks using cubic spline interpolation or extrapolation methods were found in the model or subsystem. Specific blocks are: 1-D Lookup Table2-D Lookup Tablen-D Lookup Table 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 TableLookup 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 subsystem Consider replacing the From Workspace blocks with blocks recommended for production.
String blocks were found in the model or subsystem. Specific blocks are: Compose StringScan StringString to SingleString to DoubleTo String Consider replacing the String blocks with blocks recommended for production.

Capabilities and Limitations

You can:

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.

Condition Recommended Action
Subsystem blocks have the Subsystem Parameters > Function packaging option set to Nonreusable function. Set the Subsystem Parameters >Function packaging parameter toAuto.
Subsystem blocks have the Subsystem Parameters > Function packaging option set to Reusable function. Set the Subsystem Parameters >Function packaging parameter toAuto.

Capabilities and Limitations

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

See Also

Check usage of 'long long' data type

Check ID:mathworks.codegen.EnableLongLong

Check for usage of long long data type when expensive multi-word types are detected.

Description

This check flags when your Simulink model contains signal or port data types with word lengths larger than the long data type and the configuration parameterSupport long long (ProdLongLongMode or TargetLongLongMode) is not enabled.

Available with Embedded Coder.

Condition Recommended Action
The model contains signals or port data types with word lengths larger than the long data type, theSupport long long parameter is not enabled, and your compiler supports the C long long data type. Enable the Support long long parameter.

Capabilities and Limitations

Edit-Time Checking

This check is supported by edit-time checking. Edit-time checking requires aSimulink Check license.

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.

Condition Recommended 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

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 hasSSArrayLayout property set toSS_UNSET. This setting disables the S-function for row-major code generation. When the configuration parameter Array layout is set toRow-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 ornone.

Available with Embedded Coder.

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

Capabilities and Limitations

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.

Conditions Recommended Action
Blocks generate expensive saturation code. Check whether your application requires settingFunction 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 > parameter to On, orUse 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. NoteThis 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 theOptimization > Remove code that protects against division arithmetic exceptions parameter in the Configuration Parameters dialog box.
The data type range of the inputs ofSum 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. Aint16 (–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 theSum 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 theMinMax block have different data types. Change the data type of the input or output.
The input of theMinMax block has a different slope adjustment factor than the output. Change the scaling of the input or the output.
The initial condition of theDiscrete-Time Integrator block is used to initialize both the state and the output. Set the Function Block Parameters >Initial condition setting parameter toState (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 theConstant value parameter or change theConstant value parameter to match the input data type.

Capabilities and Limitations

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.

Condition Recommended 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.

Conditions Recommended 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

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.

Condition Recommended Action
Generated code is inefficient. Set theFunction 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.

Note

Stateflow license is needed if the model contains Stateflow elements.

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

Capabilities and Limitations

You can:

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.

Note

Stateflow license is needed if the model contains Stateflow elements.

Condition Recommended 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.

Note

Stateflow license is needed if the model contains Stateflow elements.

Condition Recommended 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:

See Also

Check integer word lengths

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.

Note

Stateflow license is needed if the model contains Stateflow elements.

Condition Recommended 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 > pane.

Capabilities and Limitations

You can:

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:

The check verifies that block names comply with these guidelines:

Form:

name:

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 _

Condition Recommended 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

See Also

Check modeling style for component deployment

Check ID:mathworks.codegen.cgsl_0401

Description

Use this check to verify that the modeling style is compatible for deploying a component model that is configured with a service interface.

Available with Embedded Coder.

Condition Recommended Action
Modeling style is not compatible with requirements for deploying a component model configured with a service interface. Update the model to use the export-function or rate-based modeling style. See Periodic and Aperiodic Function Interfaces for more information.

Capabilities and Limitations

There are no specified capabilities or limitations for this Model Advisor check.

Version History

Introduced in R2022b

See Also

cgsl_0401: Modeling styles for component deployment

Periodic and Aperiodic Function Interfaces

Create a Service Interface Configuration

Export-Function Models Overview

Create Export-Function Model

Schedule Components to Avoid Data Dependency Issues

Create Rate-Based Model

Check signal interfaces

Check ID:mathworks.codegen.cgsl_0402

Description

Use this check to verify that signal interfaces are used in a way that supports component model deployment.

Available with Embedded Coder.

Condition Recommended Action
The model uses In Bus Element andInport blocks or Out Bus Element andOutport blocks. Update the model to use In Bus Element andOut Bus Element blocks or Inport and Outport blocks.
Incorrect setting for In Bus Element and Out Bus Element block parameter Bus virtuality. Set block parameter Bus virtuality tononvirtual.
Incorrect settings for Outport andInport blocks. Specify that the outport bus is nonvirtual in the parent model by selecting block parameter Output as nonvirtual bus in parent model.Specify that the output for a top-level Inport block used to load bus data is nonvirtual by selecting Inport block parameterOutput as nonvirtual bus.
Different sample times are used for the nonvirtual bus. Update signals in the nonvirtual bus to have the same sample time.

Capabilities and Limitations

There are no specified capabilities or limitations for this Model Advisor check.

Version History

Introduced in R2022b

See Also

cgsl_0402: Signal interfaces for component deployment

Modify Sample Times for Nonvirtual Buses

Specify Sample Time

View Sample Time Information

Check Startup and Shutdown Event

Check ID:mathworks.codegen.cgsl_0404

Description

The check verifies that the model includes Initialize Function andTerminate Function blocks for modeling startup and shutdown behavior.

This check requires Embedded Coder.

Condition Recommended Action
The model does not use an Initialize Function block for modeling startup behavior. Add an Initialize Function block to the component (top-level) model.
The model does not include a Terminate Function block for modeling shutdown behavior. Use one of these options for shutdown events: Add a Terminate Function block to the component (top-level) model. Clear model configuration parameterTerminate function required.

Capabilities and Limitations

Version History

Introduced in R2023a

See Also

cgsl_0404: Model startup and shutdown events by using Initialize Function and Terminate Function blocks for component deployment

Startup, Reset, and Shutdown Function Interfaces

Periodic and Aperiodic Function Interfaces

Check usage of partial data send

Check ID:mathworks.codegen.cgsl_0408

Description

The check verifies that block usage supports sending partial data.

This check requires Embedded Coder.

Condition Recommended Action
The model does not adhere to the export function modeling guideline Update the model to use the export-function modeling style
The source for a Merge block is anAssignment block that is not inside of a Function-Call Subsystem. Update the model so the source for all Merge blocks is an Assignment block inside a function-call subsystem.
The destination for a Merge block is not a virtual root-level Outport block. Update the model so that the destination of the Merge block is a root-level Outport block inside of a function-call subsystem. Verify that Outport block parameter Ensure outport is virtual is selected.
The Merge block is not configured for Direct Access data communication method. Use the Direct Access data communication method for root-levelOutport blocks that are connected to Merge blocks.

Capabilities and Limitations

Version History

Introduced in R2023a

See Also

cgsl_0408: Partial data send for component deployment

cgsl_0401: Modeling styles for component deployment

Data Communication Methods

Check configuration for component deployment

Check ID:mathworks.codegen.cgsl_0414

Description

The check verifies that the component model is configured using a service interface.

This check requires Embedded Coder.

Condition Recommended Action
Model is not linked to a shared Embedded Coder dictionary that is configured for service interface Use configuration parameter > to select a shared dictionary that is configured as a service interface. To set up a new shared dictionary, in the Embedded Coder app, select > . Use the set up dialog box to create and link the model to a new dictionary and, when prompted, select .
The deployment type of the top-level model is subcomponent. In the Embedded Coder app, use the Deployment Type field to change the deployment type of the top model to Component.
The deployment type of the reference model is component. In the Embedded Coder app, use the Deployment Type field to change the deployment type of the reference model to Subcomponent.

Capabilities and Limitations

Version History

Introduced in R2022b

See Also

cgsl_0414: Configure service interface for component model

Create a Service Interface Configuration

Embedded Coder Dictionary

Develop Deployable Code

Check for variant blocks that do not have a default choice

Check ID:mathworks.misra.DefaultChoiceVariantChecks

Identify variant blocks with startup variant activation time that do not have a default choice when the Casting modes is set to Standards Compliant.

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.

Condition Recommended Action
The variant blocks do not contain default choices but theCasting modes is set toStandards Compliant. Add a default choice as one of the choices for variant blocks.

Capabilities and Limitations

Edit-Time Checking

This check is supported by edit-time checking.