验证
证明 MATLAB® 代码与生成的代码之间的数值等效性
通过执行软件在环 (SIL) 和处理器在环 (PIL) 仿真,检查从 MATLAB 函数中生成的代码的数值行为。软件在环 (SIL) 仿真在开发计算机上编译生成的源代码并将其作为单独的进程执行。PIL 仿真(需要目标连接配置)交叉编译生成的源代码,然后在目标硬件上下载并运行目标代码。通过将 SIL 或 PIL 仿真的结果与原始 MATLAB 函数的结果进行比较,可以验证代码的数值行为。
您可以生成可追溯的代码,帮助您检查是否存在不需要的功能、了解生成的代码如何实现您的算法,并评估生成的代码质量。
对象
函数
主题
SIL 和 PIL 测试
- Code Verification Through Software-in-the-Loop and Processor-in-the-Loop Execution
A workflow that uses SIL and PIL execution to verify the numerical behavior of generated MATLAB code. - 使用 MATLAB Coder 的软件在环执行
使用 MATLAB Coder 验证生成的 C/C++ 代码的数值行为。 - Software-in-the-Loop Execution from Command Line
Use MATLAB commands to verify the numerical behavior of generated C/C++ code. - Software-in-the-Loop Execution for MATLAB Function with Multiple Signatures
Generate a SIL MEX file for multiple signatures. - Debug Generated Code During SIL or PIL Execution
Use a debugger to understand the behavior of generated code. - Create PIL Target Connectivity Configuration for MATLAB
Customize PIL execution for your target environment. - Host-Target Communication for MATLAB PIL Execution
Use thertiostream
API for communication between your development computer and target during PIL execution. - Specify Hardware Timer for MATLAB
Specify a hardware timer using the Code Replacement Tool. - Custom Toolchain Directives Required for Code Execution Profiling
Specify compiler directives for building PIL application that supports code execution profiling. - Processor-in-the-Loop Execution with the MATLAB Coder App
Use the MATLAB Coder app to verify the numerical behavior of cross-compiled object code. - Processor-in-the-Loop Execution from Command Line
Use MATLAB commands to verify the numerical behavior of cross-compiled object code. - PIL Execution with ARM Cortex-A at the Command Line
This example shows how to set up a PIL execution to verify generated code at the command line. - PIL Execution with ARM Cortex-A by Using the MATLAB Coder App
PIL Execution with App. - Verification of Code Generation Assumptions
PIL execution checks Hardware tab settings. - Speed Up SIL/PIL Execution by Disabling Constant Input Checking and Global Data Synchronization
Configure code generation parameters to turn off constant input checking or global data synchronization for SIL or PIL executions. - SIL/PIL Execution Support and Limitations
SIL and PIL execution support for code generation features.
代码追溯
- Interactively Trace Between MATLAB Code and Generated C/C++ Code
Visualize the mapping between the MATLAB code and the generated C/C++ code. - 在生成的 C/C++ 代码中包含注释
在生成的代码中包含 MATLAB 源代码作为注释。在函数前注中包含函数帮助文本和函数签名。
Polyspace 验证
- 由 MATLAB Coder 生成的 C/C++ 代码的 Polyspace 验证
检查生成的 C/C++ 代码中的运行时错误或缺陷。
生成报告
- Highlight Potential Data Type Issues in a Report
Highlight MATLAB code that results in double-precision, single-precision, or expensive fixed-point operations. - Find Potential Data Type Issues in Generated Code
Highlight potential data type issues in report.