Main Content

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.

For the full list of options to set, see Bug Finder Analysis in Simulink.

Analyze code

To analyze generated code:

  1. 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.

  2. Select Settings > Analyze TargetLink Code. Then, select Run Analysis.

    A snapshot of the Polyspace tab on the Simulink toolstrip. On the Settings menu, you can select Analyze TargetLink Code.

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_ModelName in the current folder. Each new run overwrites previous results.

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.