在 Simulink 中进行 Code Prover 分析
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 分析。
函数
polyspacesetup | 将 Polyspace 安装与 Simulink 集成 |
pslinkrunCrossRelease | Analyze 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 起) |
pslinkoptions | Create 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 |
pslinkrun | Run Polyspace analysis on model, system, or S-Function |
pslinkfun | Manage model analysis at the command line |
polyspacePackNGo | Generate and package options files to run Polyspace analysis on code generated from Simulink model (自 R2020b 起) |
polyspaceArtifact | Generate artifacts to run Polyspace analysis on code generated from Simulink model (自 R2024a 起) |
类
polyspace.ModelLinkOptions | Create a project configuration object for running Polyspace analysis on generated code |
属性
pslinkoptions 属性 | pslinkoptions 对象的属性 |
polyspace.ModelLinkOptions Properties | Customize Polyspace analysis of generated code with options object properties |
模型设置
主题
设置
- 将 Polyspace 与 MATLAB 和 Simulink 集成
将 Polyspace 与 MATLAB 和 Simulink 集成,以标识模型和代码中潜在的 Bug、运行时错误以及编码标准违规。 - Polyspace 对不同 MATLAB 和 Simulink 版本的支持
检查 Polyspace 对您的 MATLAB 或 Simulink 版本的支持情况。 - Fix Issues When Integrating Polyspace with MATLAB and Simulink
Troubleshoot why Polyspace fails to integrate with MATLAB and Simulink.
分析生成的代码
- 对通过 Embedded Coder 生成的代码运行 Polyspace 分析
检查通过 Embedded Coder® 生成的代码是否存在 Bug、运行时错误或编码违规情况。
- Address Polyspace Results by Annotating Simulink Blocks
Justify Polyspace results by directly annotating blocks in your Simulink model. - Verify if Input and Output of Referenced Model Are Within Bounds
Check if the input and output of a referenced model remain within specified bounds. - Run Polyspace on Code Generated by Using Previous Releases of Simulink
Analyze C/C++ code generated by using previous releases of Simulink with newer releases of Polyspace. - Run Polyspace Analysis on Code Generated with TargetLink
Check code generated from Simulink models for bugs, run-time errors or coding rule violations. - 使用打包的选项文件对生成的代码运行 Polyspace 分析
从 Simulink 模型生成 Polyspace 选项文件,并使用这些选项文件通过 Polyspace 分析生成的代码。 - Analyze Code Generated as Standalone Code in a Distributed Workflow (Simulink)
Tutorial showing Polyspace analysis of standalone generated code by using packaged options files in a distributed workflow.
分析自定义代码
- Run Polyspace Analysis on Custom Code in Simulink Models
Analyze manually written C/C++ code to detect issues that might introduce run-time errors or bugs in the simulation. - 对 S-Function 代码运行 Polyspace 分析
教程展示了在 Simulink 中对 S-Function 代码运行 Polyspace 分析。 - Run Polyspace Analysis on Custom Code in C Caller Blocks and Stateflow Charts
Tutorial showing Polyspace analysis of custom code in Simulink model. - Run Polyspace Analysis on Custom Code in C Function Block
Tutorial showing Polyspace analysis of custom code in C Function block in Simulink.
高级配置
- 推荐用于 Polyspace 分析的模型配置参数
为获得更好的 Polyspace 结果,请在生成代码之前设置推荐的参数。 - Configure Polyspace Options in Simulink
Configure advanced Polyspace analysis options such as code metric calculations or compiler options. - Reduce Polyspace Analysis Time by Ignoring Specific Referenced Models
Ignore specific model in the reference hierarchy to decrease the time required for a Polyspace analysis.
如何分析生成的代码
- How Polyspace Analysis of Generated Code Works
Polyspace extracts function names from generated code to create amain
function for the analysis. - Default Polyspace Options for Code Generated with Embedded Coder
Some Polyspace options such as macro definitions and paths to include folders are set by default.
- Default Polyspace Options for Code Generated with TargetLink
Some Polyspace options such as macro definitions and paths to include folders are set by default.