主要内容

本页采用了机器翻译。点击此处可查看英文原文。

模型顾问检查是否符合 MISRA C 编码标准

要检查您的模型或子系统是否能够生成符合 MISRA C:2012 和 MISRA C:2023 标准的代码,请打开模型顾问并运行 按任务 > MISRA C:2023 建模标准 中的检查。

注意

符合 MISRA C:2012 的高完整性系统建模规范及其相关检查也符合 MISRA C:2023。从 R2026a 开始,模型顾问将包含专门引用 MISRA C:2023 的文件夹和检查,同时保持与 MISRA C:2012 的合规性。

执行以下检查需要使用 Embedded Coder®Simulink® Check™

模型顾问检查检查 ID
检查 MISRA C:2023 的配置参数mathworks.misra.CodeGenSettings
检查是否存在不建议用于 C/C++ 生产代码部署的模块mathworks.codegen.PCGSupport
检查 MISRA C:2023 中不推荐使用的块mathworks.misra.BlkSupport
检查不支持的模块名称mathworks.misra.BlockNames
检查 Assignment 模块的使用mathworks.misra.AssignmentBlocks
检查没有默认情况的 switch case 表达式mathworks.misra.SwitchDefault
检查 AUTOSAR 接收器接口是否存在缺失的错误端口mathworks.misra.AutosarReceiverInterface
检查有符号整数的按位运算mathworks.misra.CompliantCGIRConstructions
检查递归函数调用mathworks.misra.RecursionCompliance
检查浮点数值的相等性和不等性运算mathworks.misra.CompareFloatEquality
检查模型函数中是否缺失常量限定符mathworks.misra.ModelFunctionInterface
检查整数字长mathworks.misra.IntegerWordLengths

检查用作总线元素名称的总线对象名称

mathworks.misra.BusElementNames
检查没有默认选择项的变体模块mathworks.misra.DefaultChoiceVariantChecks

要访问 MISRA C:2012 和 MISRA C:2023 标准支持的高完整性检查,请转到 按任务 > MISRA C:2023 建模标准 > 高完整性系统 文件夹。

注意

高完整性建模规范旨在确保符合 MISRA C:2012 和 MISRA C:2023 建模的某些方面。

此外,高完整性系统还包括含有基于其功能的高完整性检查的子文件夹,列举如下:

按任务 > MISRA C:2023 建模标准 > 高完整性系统 > 配置

按任务 > MISRA C:2023 建模标准 > 高完整性系统 > MATLAB

模型顾问检查检查 ID高完整性系统建模规范
检查 MATLAB Function 模块中的 switch 语句mathworks.hism.himl_0007himl_0007: MATLAB code switch / case / otherwise patterns

按任务 > MISRA C:2023 建模标准 > 高完整性系统 > 命名

模型顾问检查检查 ID高完整性系统建模规范
检查模型对象名称mathworks.hism.hisl_0032hisl_0032: Model element names

按任务 > MISRA C:2023 建模标准 > 高完整性系统 > Simulink

模型顾问检查检查 ID高完整性系统建模规范
检查 Abs 模块的使用mathworks.hism.hisl_0001hisl_0001: Usage of Abs block
检查平方根运算的使用mathworks.hism.hisl_0003hisl_0003: Usage of square root operations
检查 While Iterator 模块的使用mathworks.hism.hisl_0006hisl_0006: Usage of While Iterator blocks
检查 For Iterator 和 While Iterator 子系统的使用mathworks.hism.hisl_0007hisl_0007: Usage of For Iterator or While Iterator subsystems
检查 For Iterator 模块的使用mathworks.hism.hisl_0008hisl_0008: Usage of For Iterator Blocks
检查 If blocks 和 If Action Subsystem 模块的使用mathworks.hism.hisl_0010hisl_0010: Usage of If blocks and If Action Subsystem blocks
检查 Switch Case 块和 Switch Case Action Subsystem 块的使用情况mathworks.hism.hisl_0011hisl_0011: Usage of Switch Case blocks and Action Subsystem blocks
检查 Relational Operator 模块的使用mathworks.hism.hisl_0017hisl_0017: Usage of blocks that compute relational operators (2)
检查 Logical Operator 模块的使用mathworks.hism.hisl_0018hisl_0018: Usage of Logical Operator block
检查位运算块的使用情况mathworks.hism.hisl_0019hisl_0019: Usage of bitwise operations
检查是否存在不建议用于 C/C++ 生产代码部署的模块mathworks.hism.hisl_0020hisl_0020: Blocks not recommended for MISRA C compliance
检查 Reciprocal Sqrt 模块的使用mathworks.hism.hisl_0028hisl_0028: Usage of Reciprocal Square Root blocks
检查 Assignment 模块的使用mathworks.hism.hisl_0029hisl_0029: Usage of Assignment blocks
检查 Signal Routing 模块的使用mathworks.hism.hisl_0034hisl_0034: Usage of Signal Routing blocks
检查图形函数中的全局变量mathworks.hism.hisl_0062hisl_0062: Global variables in graphical functions
检查用户自定义对象名称的长度mathworks.hism.hisl_0063hisl_0063: Length of user-defined object names to improve MISRA C compliance
检查除以零计算mathworks.hism.hisl_0067hisl_0067: Protect against divide-by-zero calculations
检查位移操作的使用情况mathworks.hism.hisl_0073hisl_0073: Usage of bit-shift operations
检查与安全相关的诊断设置是否存在变体mathworks.hism.hisl_0074hisl_0074: Configuration Parameters > Diagnostics > Modeling issues related to variants
检查死逻辑mathworks.hism.hisl_0101hisl_0101: Prevent operations that result in dead logic to improve code compliance
检查循环控制变量的数据类型mathworks.hism.hisl_0102hisl_0102: Data type of loop control variables to improve MISRA C compliance
检查余数和倒数运算的使用mathworks.sldv.hism.hisl_0002hisl_0002: Usage of remainder and reciprocal operations
检查 log 和 log10 运算的使用mathworks.sldv.hism.hisl_0004hisl_0004: Usage of natural logarithm and base 10 logarithm operations

按任务 > MISRA C:2023 建模标准 > 高完整性系统 > Stateflow