Run Polyspace Analysis on Code Generated with TargetLink
To detect bugs and runtime errors, run a Polyspace® analysis after generating code from Simulink® models by using TargetLink®. Run the analysis from the Simulink Editor window. Manually setting up a Polyspace project is not necessary. If you use Embedded Coder® to generate code, see Run Polyspace Analysis on Code Generated from Simulink Model.
Configure and Run Analysis
Configure code analysis
On the Apps tab, select Polyspace Code Verifier. Then, on the Polyspace tab:
Select the product to run: Bug Finder or Code Prover. A Code Prover analysis detects run-time errors while a Bug Finder analysis detects coding defects and coding rule violations.
Select Settings. Change default values of these options if needed.
Settings from (C): Enable checking of MISRA™ or JSF® coding rules in addition to the default checks.
Output folder: Specify a dedicated folder for results. The default analysis runs Code Prover on generated code and saves the results in a folder
results_
in the current working folder.modelName
Enable additional file list: Add C files that are not part of the generated code.
For the full list of options to set, see Code Prover Analysis in Simulink.
Analyze code
To analyze generated code:
Choose to analyze code generated from a TargetLink Subsystem. You cannot analyze code generated from the entire model.
The Analyze Code from field shows the top model. Unpin the content of this field and then select the TargetLink Subsystem.
Select Settings > Analyze TargetLink Code. Then, select Run Analysis.
You can follow the progress of the analysis in the MATLAB® command window.
The results open automatically unless explicitly disabled. By default, the results
are saved in a folder
results_
in the current
folder. Each new run overwrites previous results.ModelName
Note
Verification of a 3,000 block model takes approximately one hour to verify, or about 15 minutes per 2,000 lines of generated code.
Review Analysis Results
Review result in code
The results appear on the Results List pane. Click each result to see the source code and details on the Result Details pane.
Navigate from code to model
Links in code comments show blocks that generate the subsequent lines of code. To see the blocks in the model, click the block names.
Fix issue
Investigate whether the issues in your code are related to design flaws in the model.
For instance, you might need to constrain the range of signal from Inport blocks. See Work with Signal Ranges in Blocks (Simulink). If a flagged issue is known or justified, then annotate that information in the relevant blocks. To annotate a block in Simulink Editor, right-click the block and use the contextual menu.