Main Content

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

Description

example

opts = pslinkoptions(codegen) returns an options object with the configuration options for code generated by codegen.

example

opts = pslinkoptions(model) returns an options object with the configuration options for the Simulink® model.

opts = pslinkoptions(sfunc) returns an options object with the configuration options for the S-Function.

Note

Before you run Polyspace® from MATLAB®, you must link your Polyspace and MATLAB installations. See Integrate Polyspace with MATLAB and Simulink (Polyspace Bug Finder).

Examples

collapse all

This example shows how you can create a generic Polyspace options object that is suitable for analyzing code generated by using Embedded Coder. This options object is prepopulated with appropriate Embedded Coder parameters. Edit the options object to modify the generic analysis.

Create a new Polyspace configuration object new_opt by calling the function pslinkoptions and specify 'ec' as the input argument.

new_opt = pslinkoptions('ec')
new_opt =

                    ResultDir: 'results_$ModelName$'
         VerificationSettings: 'PrjConfig'
           OpenProjectManager: 0
         AddSuffixToResultDir: 0
     EnableAdditionalFileList: 0
           AdditionalFileList: {}
             VerificationMode: 'CodeProver'
          EnablePrjConfigFile: 0
                PrjConfigFile: ''
         AddToSimulinkProject: 0
               InputRangeMode: 'DesignMinMax'
               ParamRangeMode: 'None'
              OutputRangeMode: 'None'
           ModelRefVerifDepth: 'Current model only'
      ModelRefByModelRefVerif: 0
                  AutoStubLUT: 1
      CxxVerificationSettings: 'PrjConfig'
    CheckConfigBeforeAnalysis: 'OnWarn'
        VerifAllSFcnInstances: 0

By default, this options object uses the same verification settings that you specify in the Polyspace project. To check MISRA C® 2012 coding rule violations in addition to the existing verifications specified in the project, run this code at the MATLAB command line:

new_opt.VerificationSettings = 'PrjConfigAndMisraC2012'
new_opt =

                    ResultDir: 'results_$ModelName$'
         VerificationSettings: 'PrjConfigAndMisraC2012'
           OpenProjectManager: 0
         AddSuffixToResultDir: 0
     EnableAdditionalFileList: 0
           AdditionalFileList: {}
             VerificationMode: 'CodeProver'
          EnablePrjConfigFile: 0
                PrjConfigFile: ''
         AddToSimulinkProject: 0
               InputRangeMode: 'DesignMinMax'
               ParamRangeMode: 'None'
              OutputRangeMode: 'None'
           ModelRefVerifDepth: 'Current model only'
      ModelRefByModelRefVerif: 0
                  AutoStubLUT: 1
      CxxVerificationSettings: 'PrjConfig'
    CheckConfigBeforeAnalysis: 'OnWarn'
        VerifAllSFcnInstances: 0

When you start the Polyspace analysis of the generated code, you might want to open the Polyspace User Interface to follow the progress of the and to review the results afterwards. To open the Polyspace interface when you start the analysis, run this code:

new_opt.OpenProjectManager = true
new_opt =

                    ResultDir: 'results_$ModelName$'
         VerificationSettings: 'PrjConfigAndMisraC2012'
           OpenProjectManager: 1
         AddSuffixToResultDir: 0
     EnableAdditionalFileList: 0
           AdditionalFileList: {}
             VerificationMode: 'CodeProver'
          EnablePrjConfigFile: 0
                PrjConfigFile: ''
         AddToSimulinkProject: 0
               InputRangeMode: 'DesignMinMax'
               ParamRangeMode: 'None'
              OutputRangeMode: 'None'
           ModelRefVerifDepth: 'Current model only'
      ModelRefByModelRefVerif: 0
                  AutoStubLUT: 1
      CxxVerificationSettings: 'PrjConfig'
    CheckConfigBeforeAnalysis: 'OnWarn'
        VerifAllSFcnInstances: 0

This example shows how you can store the Polyspace configurations of a Simulink model in to an object, and use the object to edit the configuration options.

Load the model closed_loop_control.

load_system('closed_loop_control');

To create an object containing the Polyspace configurations of the model, call pslinkoptions.

model_opt = pslinkoptions('closed_loop_control')
model_opt =

                    ResultDir: 'results_$ModelName$'
         VerificationSettings: 'PrjConfig'
           OpenProjectManager: 0
         AddSuffixToResultDir: 0
     EnableAdditionalFileList: 0
           AdditionalFileList: {}
             VerificationMode: 'BugFinder'
          EnablePrjConfigFile: 0
                PrjConfigFile: ''
         AddToSimulinkProject: 0
               InputRangeMode: 'DesignMinMax'
               ParamRangeMode: 'None'
              OutputRangeMode: 'None'
           ModelRefVerifDepth: 'Current model only'
      ModelRefByModelRefVerif: 0
                  AutoStubLUT: 1
      CxxVerificationSettings: 'PrjConfig'
    CheckConfigBeforeAnalysis: 'OnWarn'
        VerifAllSFcnInstances: 0
           ModelRefIgnoreList: []
     EnableModelRefIgnoreList: 0
          ModelRefMinMaxVerif: 'CheckAndConstrain'

The model is already configured for Embedded Coder®, so only the Embedded Coder configuration options appear as the fields of the object model_opt.

To modify a Polyspace configuration option, set the corresponding field of model_opt. For instance, change the results directory and set the verification mode to CodeProver by modifying fields : model_opt.ResultDir and model_opt.VerificationMode, respectively.

model_opt.ResultDir = 'results_v1_$ModelName$';
model_opt.VerificationMode = 'CodeProver'
model_opt =

                    ResultDir: 'results_v1_$ModelName$'
         VerificationSettings: 'PrjConfig'
           OpenProjectManager: 0
         AddSuffixToResultDir: 0
     EnableAdditionalFileList: 0
           AdditionalFileList: {}
             VerificationMode: 'CodeProver'
          EnablePrjConfigFile: 0
                PrjConfigFile: ''
         AddToSimulinkProject: 0
               InputRangeMode: 'DesignMinMax'
               ParamRangeMode: 'None'
              OutputRangeMode: 'None'
           ModelRefVerifDepth: 'Current model only'
      ModelRefByModelRefVerif: 0
                  AutoStubLUT: 1
      CxxVerificationSettings: 'PrjConfig'
    CheckConfigBeforeAnalysis: 'OnWarn'
        VerifAllSFcnInstances: 0
           ModelRefIgnoreList: []
     EnableModelRefIgnoreList: 0
          ModelRefMinMaxVerif: 'CheckAndConstrain'

Create a Polyspace® options object called new_opt with TargetLink® parameters:

new_opt = pslinkoptions('tl')
new_opt =

                   ResultDir: 'results_$ModelName$'
        VerificationSettings: 'PrjConfig'
          OpenProjectManager: 0
        AddSuffixToResultDir: 0
    EnableAdditionalFileList: 0
          AdditionalFileList: {}
            VerificationMode: 'CodeProver'
         EnablePrjConfigFile: 0
               PrjConfigFile: ''
        AddToSimulinkProject: 0
              InputRangeMode: 'DesignMinMax'
              ParamRangeMode: 'None'
             OutputRangeMode: 'None'
                 AutoStubLUT: 1

Set the OpenProjectManager option to true to follow the progress in the Polyspace interface. Also change the configuration to check for both run-time errors and MISRA C® coding rule violations:

new_opt.OpenProjectManager = true;
new_opt.VerificationSettings = 'PrjConfigAndMisra'
new_opt =

                   ResultDir: 'results_$ModelName$'
        VerificationSettings: 'PrjConfigAndMisra'
          OpenProjectManager: 1
        AddSuffixToResultDir: 0
    EnableAdditionalFileList: 0
          AdditionalFileList: {}
            VerificationMode: 'CodeProver'
         EnablePrjConfigFile: 0
               PrjConfigFile: ''
        AddToSimulinkProject: 0
              InputRangeMode: 'DesignMinMax'
              ParamRangeMode: 'None'
             OutputRangeMode: 'None'
                 AutoStubLUT: 1

Input Arguments

collapse all

Code generator, specified as either 'ec' for Embedded Coder® or 'tl' for TargetLink®. Each argument creates a Polyspace options object with properties specific to that code generator.

For a description of all configuration options and their values, see pslinkoptions Properties (Polyspace Bug Finder).

Example: ec_opt = pslinkoptions('ec')

Example: tl_opt = pslinkoptions('tl')

Data Types: char

Simulink model, specified by the model name. Creates a Polyspace options object with the configuration options of that model. If you have not set any options, the object has the default configuration options. If you have set a code generator, the object has the default options for that code generator.

For a description of all configuration options and their values, see pslinkoptions Properties (Polyspace Bug Finder).

Example: model_opt = pslinkoptions('my_model')

Data Types: char

Path to S-Function, specified as a character vector. Creates a Polyspace options object with the configuration options for the S-function. If you have not set any options, the object has the default configuration options.

For a description of all configuration options and their values, see pslinkoptions Properties (Polyspace Bug Finder).

Example: sfunc_opt = pslinkoptions('path/to/sfunction')

Data Types: char

Output Arguments

collapse all

Polyspace configuration options, returned as an options object. The object is used with pslinkrun to run Polyspace from the MATLAB command line.

You can specify many properties of a Polyspace analysis using a pslinkoptions object. For the list of object properties, see pslinkoptions Properties (Polyspace Bug Finder).

The properties you specify using a pslinkoption object is a subset of Polyspace analysis options. Additional properties can be specified using the class . This class allows you to specify properties a object to run analysis on generated code. If you have a pslinkoptions object, you can create a object using the pslinkoptions object.

Example: opts= pslinkoptions('ec')
opts.VerificationSettings = 'Misra'

Version History

Introduced in R2012a

See Also

(Polyspace Bug Finder)