Main Content

Simulink 中进行 Code Prover 分析

验证导入到 Simulink® 模型中的代码以及从中生成的代码

cp

使用 Polyspace® 标识 Simulink 模型中潜在的 Bug、运行时错误以及编码标准违规。在验证和确认过程的两个不同步骤中使用 Polyspace。

在生成代码之前,请检测并解决模型中的自定义代码可能引入的问题。C function 块、C caller 块和 S function 块中包含自定义代码。请参阅Run Polyspace Analysis on Custom Code in Simulink Models

在生成代码后,分析生成的代码,找出模型中可能没有发现的特定于代码的问题,例如,由于模型的未测试部分或不正确的代码生成选项而导致的错误。请参阅对通过 Embedded Coder 生成的代码运行 Polyspace 分析

在集成 Polyspace 和 MATLAB® 后,您可以直接从 Simulink 工具条运行 Polyspace 分析,也可以使用 MATLAB 脚本自动执行 Polyspace 分析。请参阅将 Polyspace 与 MATLAB 和 Simulink 集成使用 MATLAB 脚本运行 Polyspace 分析。另外,还可以从 Simulink 模型生成选项文件,并在系统命令行中使用这些选项文件对生成的代码运行 Polyspace 分析。请参阅使用打包的选项文件对生成的代码运行 Polyspace 分析

函数

polyspacesetupPolyspace 安装与 Simulink 集成
pslinkrunCrossReleaseAnalyze C/C++ code generated by R2020b or newer Embedded Coder versions by using a different version of Polyspace that is more recent than the Simulink version (自 R2021a 起)
pslinkoptionsCreate an options object to customize configuration of a Simulink model, generated code or a S-Function block. Use the object to specify configuration options for these Simulink objects in a Polyspace run from the MATLAB command line
pslinkrunRun Polyspace analysis on model, system, or S-Function
pslinkfunManage model analysis at the command line
polyspacePackNGoGenerate and package options files to run Polyspace analysis on code generated from Simulink model (自 R2020b 起)
polyspaceArtifactGenerate artifacts to run Polyspace analysis on code generated from Simulink model (自 R2024a 起)

polyspace.ModelLinkOptionsCreate a project configuration object for running Polyspace analysis on generated code

属性

pslinkoptions 属性pslinkoptions 对象的属性
polyspace.ModelLinkOptions PropertiesCustomize Polyspace analysis of generated code with options object properties

模型设置

全部展开

设置来源 (C)Settings to use for the Polyspace analysis of C code
设置来源 (C++)Settings to use for the Polyspace analysis
工程配置Set advanced configuration options to customize analysis
输入Option to choose whether to constrain Inport block variables
可调参数Option to specify the assumed value of tunable parameter values during the analysis
输出Option to verify whether output variables are within expected bounds
模型引用验证深度Depth of model reference hierarchy for Polyspace analysis
逐模型验证Option to analyze each model or referenced model individually
忽略模型引用Option to ignore specified model references (自 R2023b 起)
模型引用输入/输出范围验证Option to verify that input and output of model references are within specified values (自 R2024a 起)
输出文件夹Path and folder name for your analysis results
通过添加后缀使输出文件夹名称唯一Option to add a unique suffix to the results folder for every Polyspace run
验证后自动打开结果Option to open analysis results in Polyspace user interface after analysis completes
将结果添加到当前 Simulink 工程Option to add your Polyspace results to current Simulink project
产品模式Choice between Polyspace Bug Finder and Polyspace Code Prover (自 R2021b 起)
使用自定义工程文件Option to use custom configuration from a Polyspace project (.psprj) file
启用其他文件列表Option to add additional supporting code files to analysis
为查找表插桩Option to stub autogenerated functions that use lookup tables with linear interpolation
验证所有的 S-Function 实例Option to analyze all instances of selected S-Function block
验证前检查配置Option to check model and code configurations for errors before code analysis

主题

设置

分析生成的代码

分析自定义代码

高级配置

如何分析生成的代码