主要内容

针对 MISRA C:2012 编码标准的模型顾问检查

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

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

模型顾问检查检查 ID
Check configuration parameters for MISRA C:2012mathworks.misra.CodeGenSettings
Check for blocks not recommended for C/C++ production code deploymentmathworks.codegen.PCGSupport
Check for blocks not recommended for MISRA C:2012mathworks.misra.BlkSupport
Check for unsupported block namesmathworks.misra.BlockNames
Check usage of Assignment blocksmathworks.misra.AssignmentBlocks
Check for switch case expressions without a default casemathworks.misra.SwitchDefault
Check for missing error ports for AUTOSAR receiver interfacesmathworks.misra.AutosarReceiverInterface
Check for bitwise operations on signed integersmathworks.misra.CompliantCGIRConstructions
Check for recursive function callsmathworks.misra.RecursionCompliance
Check for equality and inequality operations on floating-point valuesmathworks.misra.CompareFloatEquality
Check for missing const qualifiers in model functionsmathworks.misra.ModelFunctionInterface
Check integer word lengthsmathworks.misra.IntegerWordLengths

Check bus object names that are used as bus element names

mathworks.misra.BusElementNames
Check for variant blocks that do not have a default choicemathworks.misra.DefaultChoiceVariantChecks

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

注意

高完整性建模规范旨在确保符合 MISRA C:2012 建模的选定方面。

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

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

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

模型顾问检查检查 ID高完整性系统建模规范
Check switch statements in MATLAB Function blocksmathworks.hism.himl_0007himl_0007: MATLAB code switch / case / otherwise patterns

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

模型顾问检查检查 ID高完整性系统建模规范
Check model object namesmathworks.hism.hisl_0032hisl_0032: Model element names

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

模型顾问检查检查 ID高完整性系统建模规范
Check usage of Abs blocksmathworks.hism.hisl_0001hisl_0001: Usage of Abs block
Check usage of square root operationsmathworks.hism.hisl_0003hisl_0003: Usage of square root operations
Check usage of While Iterator blocksmathworks.hism.hisl_0006hisl_0006: Usage of While Iterator blocks
Check usage of For and While Iterator subsystemsmathworks.hism.hisl_0007hisl_0007: Usage of For Iterator or While Iterator subsystems
Check usage of For Iterator blocksmathworks.hism.hisl_0008hisl_0008: Usage of For Iterator Blocks
Check usage of If blocks and If Action Subsystem blocksmathworks.hism.hisl_0010hisl_0010: Usage of If blocks and If Action Subsystem blocks
Check usage of Switch Case blocks and Switch Case Action Subsystem blocksmathworks.hism.hisl_0011hisl_0011: Usage of Switch Case blocks and Action Subsystem blocks
Check usage of Relational Operator blocksmathworks.hism.hisl_0017hisl_0017: Usage of blocks that compute relational operators (2)
Check usage of Logical Operator blocksmathworks.hism.hisl_0018hisl_0018: Usage of Logical Operator block
Check usage of bit operation blocksmathworks.hism.hisl_0019hisl_0019: Usage of bitwise operations
Check for blocks not recommended for C/C++ production code deploymentmathworks.hism.hisl_0020hisl_0020: Blocks not recommended for MISRA C:2012 compliance
Check usage of Reciprocal Sqrt blocksmathworks.hism.hisl_0028hisl_0028: Usage of Reciprocal Square Root blocks
Check usage of Assignment blocksmathworks.hism.hisl_0029hisl_0029: Usage of Assignment blocks
Check usage of Signal Routing blocksmathworks.hism.hisl_0034hisl_0034: Usage of Signal Routing blocks
Check global variables in graphical functionsmathworks.hism.hisl_0062hisl_0062: Global variables in graphical functions
Check for length of user-defined object namesmathworks.hism.hisl_0063hisl_0063: Length of user-defined object names to improve MISRA C:2012 compliance
Check for divide-by-zero calculationsmathworks.hism.hisl_0067hisl_0067: Protect against divide-by-zero calculations
Check usage of bit-shift operationsmathworks.hism.hisl_0073hisl_0073: Usage of bit-shift operations
Check safety-related diagnostic settings for variantsmathworks.hism.hisl_0074hisl_0074: Configuration Parameters > Diagnostics > Modeling issues related to variants
Check for dead logicmathworks.hism.hisl_0101hisl_0101: Prevent operations that result in dead logic to improve code compliance
Check data type of loop control variablesmathworks.hism.hisl_0102hisl_0102: Data type of loop control variables to improve MISRA C:2012 compliance
Check usage of remainder and reciprocal operationsmathworks.sldv.hism.hisl_0002hisl_0002: Usage of remainder and reciprocal operations
Check usage of log and log10 operationsmathworks.sldv.hism.hisl_0004hisl_0004: Usage of natural logarithm and base 10 logarithm operations

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