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
Since R2021a
Syntax
Description
[
runs a Polyspace® analysis of the code generated from
polyspaceFolder
, resultsFolder
] = pslinkrunCrossRelease(ModelOrSubsystem
)ModelOrSubsystem
by using Embedded Coder® from an earlier release of Simulink®.
[
runs a Polyspace analysis of the code generated from
polyspaceFolder
, resultsFolder
] = pslinkrunCrossRelease(ModelOrSubsystem
,psOpt
)ModelOrSubsystem
through an earlier release of Simulink. The analysis uses the model configuration options that are specified
in the pslinkoptions
object psOpt
.
[
runs a Polyspace analysis of the code generated as a model reference from
polyspaceFolder
, resultsFolder
] = pslinkrunCrossRelease(ModelOrSubsystem
,psOpt
,asModelRef
)ModelOrSubsystem
through an earlier release of Simulink.The analysis uses asModelRef
to specify which
type of generated code to analyze—standalone code or model reference code.
[
runs a Polyspace analysis of the code generated from
polyspaceFolder
, resultsFolder
] = pslinkrunCrossRelease(ModelOrSubsystem
,psOpt
,asModelRef
,OptionsFile
)ModelOrSubsystem
through an earlier release of Simulink. The analysis uses the Polyspace analysis options specified in the options file
OptionsFile
.
Examples
Analyze Code Generated by Using Earlier Simulink Release
To run a Polyspace analysis on code generated by using an earlier release of
Simulink, use the function pslinkrunCrossRelease
. The
analysis uses the configuration options associated with
ModelOrSubsystem
. The Simulink release must be R2020b
or later. Before you run an analysis, you must integrate Polyspace with Simulink. See MATLAB Release Earlier Than Polyspace.
Open the Simulink model
polyspace_controller_demo
and configure the model for code generation.cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample', ... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir; configSet = getActiveConfigSet(model); set_param(configSet,'Solver','FixedStepDiscrete'); set_param(configSet, 'SystemTargetFile', 'ert.tlc');
To enable packing the generated code in an archive, set the option
PackageGeneratedCodeAndArtifacts
totrue
.set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true)
Generate code from the model.
slbuild(model);
Start a Polyspace analysis.
The character vector% Run Polyspace analysis [~,resultsFolder] = pslinkrunCrossRelease(model); bdclose(model);
resultsFolder
contains the full path to the results folder.
Run Polyspace Analysis with Modified Configuration While Analyzing Code Generated by Using Earlier Simulink Release
To run a Polyspace analysis with modified model configurations, use a
pslinkoptions
object. For a list of model configurations
related to Polyspace analysis that you can modify, see the table Polyspace Configuration Parameters Supported by
pslinkrunCrossRelease
on this page.
Before you run an analysis, you must integrate Polyspace with Simulink. See MATLAB Release Earlier Than Polyspace.
Open the Simulink model
polyspace_controller_demo
and configure the model for code generation.cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample', ... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir; configSet = getActiveConfigSet(model); set_param(configSet,'Solver','FixedStepDiscrete'); set_param(configSet, 'SystemTargetFile', 'ert.tlc');
To enable packing the generated code in an archive, set the option
PackageGeneratedCodeAndArtifacts
totrue
.set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true)
Generate code from the model.
slbuild(model);
To specify the model configurations for the Polyspace analysis, use a
pslinkoptions
object. Create this object by using the functionpslinkoptions
. To run a Bug Finder analysis, setpsOpt.VerificationMode
to'BugFinder'
. To assert the range defined in a block on its input variables, specifypsOpts.InputRangeMode
as'DesignMinMax'
.% Create a Polyspace options object from the model. psOpts = pslinkoptions(model); % Set model configurtion for the Polyspace analysis. psOpts.VerificationMode = 'BugFinder'; psOpts.InputRangeMode = 'DesignMinMax';
Start a Polyspace analysis. To specify model configuration for the Polyspace analysis, set the object
psOpt
as the optional second argument inpslinkrunCrossRelease
.The character vector% Run Polyspace analysis [~,resultsFolder] = pslinkrunCrossRelease(model,psOpt); bdclose(model);
resultsFolder
contains the full path to the results folder.
Analyze Code Generated as Model Reference by Using an Earlier Simulink Release
To accelerate model simulations, invoke referenced
Simulink models as simulation targets. To generate model reference simulation targets
from a Simulink model, generate code from the ModelOrSubsystem
by using
slbuild
with the build process specified as
ModelReferenceCoderTarget
. Package the generated code by using
packNGo
(Embedded Coder). Then, analyze the generated code
by running a cross-release Polyspace analysis. Before you run an analysis, you must integrate Polyspace with Simulink. See MATLAB Release Earlier Than Polyspace.
Open the Simulink model
polyspace_controller_demo
and configure the model for code generation.cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample', ... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir; configSet = getActiveConfigSet(model); set_param(configSet,'Solver','FixedStepDiscrete'); set_param(configSet, 'SystemTargetFile', 'ert.tlc'); set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true)
Generate code from the model. Specify the option
ModelReferenceCoderTarget
. Seeslbuild
(Simulink).The generated code is stored in the folderslbuild(model,'ModelReferenceCoderTarget');
slprj
To package the code that is generated as a model reference, use the function
packNGo
. Locate the filebuildinfo.mat
in
and use the full path to it as the input to<working folder>
/slprj/ert/polyspace_controller_demopackNGo
. This command generates an archive containing the generated code and the objectbuildinfo.mat
. SeepackNGo
(Embedded Coder).% Locate buildinfo and generate code archive buildinfo = fullfile(pwd,'slprj','ert',model,'buildinfo.mat'); packNGo(buildinfo)
To specify the Polyspace analysis options, use a
pslinkoptions
object. Create this object by using the functionpslinkoptions
. To run a Bug Finder analysis, setpsOpt.VerificationMode
to'BugFinder'
.% Create a Polyspace options object from the model. psOpts = pslinkoptions(model); % Set properties that define the Polyspace analysis. psOpts.VerificationMode = 'BugFinder'; psOpts.InputRangeMode = 'DesignMinMax';
Start a Polyspace analysis. To specify Polyspace analysis options, set the object
psOpt
as the optional second argument inpslinkrunCrossRelease
. To analyze the code as a model reference, set the optional third argumentasModelRef
to true.The character vector% Run Polyspace analysis [~,resultsFolder] = pslinkrunCrossRelease(model,psOpt,true); bdclose(model);
resultsFolder
contains the full path to the results folder.
Specify Polyspace Analysis Options While Analyzing Code Generated by Using an Earlier Simulink Release
Open the Simulink model
polyspace_controller_demo
and configure the model for code generation.cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample', ... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir; configSet = getActiveConfigSet(model); set_param(configSet,'Solver','FixedStepDiscrete'); set_param(configSet, 'SystemTargetFile', 'ert.tlc');
To enable packing the generated code in an archive, set the option
PackageGeneratedCodeAndArtifacts
totrue
.set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true)
Generate code from the model.
slbuild(model);
To specify the model configuration for the Polyspace analysis, use a
pslinkoptions
object. Create this object by using the functionpslinkoptions
. To run a Bug Finder analysis, setpsOpt.VerificationMode
to'BugFinder'
.% Create a Polyspace options object from the model. psOpts = pslinkoptions(model); % Set properties that define the Polyspace analysis. psOpts.VerificationMode = 'BugFinder'; psOpts.InputRangeMode = 'DesignMinMax';
To specify Polyspace analysis options, create an options file. An options file is a text file that contains Polyspace options in a flat list, one line for each option. For instance, to enable all Bug Finder checkers and AUTOSAR C++14 coding rules, create a text file named
OptionFile.txt
. In the text file, enter:Save the options file. You can save the preceding options in an options file named-checkers all -autosarcpp14 all
Options.txt
in the default work folder.See Complete List of Polyspace Code Prover Analysis Options.
Start a Polyspace analysis.
To specify the model configurations for the Polyspace analysis run, set the object
psOpt
as the optional second argument inpslinkrunCrossRelease
.Because the code is generated as standalone code, set the third argument
asModelRef
tofalse
.To specify the Polyspace analysis options, specify the relative path to the created options file as the fourth argument.
The character vector% Locate options file optionsPath = fullfile(userpath,'Options.txt'); % Run Polyspace analysis [~,resultsFolder] = pslinkrunCrossRelease(model,psOpts,false,optionsPath); bdclose(model);
resultsFolder
contains the full path to the results folder.
Input Arguments
ModelOrSubsystem
— Target of the analysis
bdroot
(default) | model or system name
Target of the analysis specified as a character vector with the model or
system in single quotes. The default value is the system returned by
bdroot
(Simulink).
Example: resultsDir =
pslinkrunCrossRelease('polyspace_controller_demo')
where
polyspace_controller_demo
is the name of a
model.
Data Types: char
psOpt
— Options object
configuration options associated with
ModelOrSubsystem
(default) | configuration object created by using
pslinkoptions
Specifies the model configuration for the Polyspace analysis by using a
pslinkoptions
object. You can modify certain analysis
options by modifying psOpt
, which is an object where
individual fields represent model configuration options. For a full list of
options that you can modify, see this table.
Polyspace Configuration Parameters Supported by
pslinkrunCrossRelease
Property | Description | Value | Description |
---|---|---|---|
EnableAdditionalFileList | Enable an additional file list to be
analyzed, specified as true or
false . Use with the
AdditionalFileList option. | true | Polyspace verifies additional files specified in the
AdditionalFileList option. |
false (default) | Polyspace does not verify additional files. | ||
AdditionalFileList | List of additional files to be analyzed, specified as a
cell array of files. To add these files to the analysis, use
the EnableAdditionalFileList
option. | cell array | Polyspace considers the listed files for verification. |
VerificationMode | Polyspace analysis mode specified as
'BugFinder' , for a Bug Finder
analysis, or 'CodeProver' , for a Code
Prover verification. | 'BugFinder' | Polyspace runs a Bug Finder analysis. |
'CodeProver' (default) | Polyspace runs a Code Prover analysis. | ||
InputRangeMode | Specifies the range of the input variables. | 'DesignMinMax' (default) | Polyspace uses the input range defined in the workspace or a block. |
'Fullrange' | Polyspace uses full range inputs. | ||
ParamRangeMode | Specifies the range of the constant parameters. | 'DesignMinmax' | Polyspace uses the constant parameter range defined in the workspace or in a block. |
'None' (default) | Polyspace uses the value of parameters specified in the code. | ||
OutputRangeMode | Specifies the output assertions. | 'DesignMinMax' | Polyspace applies assertions to outputs by using a range defined in a block or the workspace. |
'None' (default) | Polyspace does not apply assertions to the output variables. | ||
ModelRefVerifDepth | Specify the depth for analyzing the models that are referenced by the current model. | 'Current model Only' (default) | Polyspace analyzes only the top model without analyzing the referenced models. Use this option when you refer to models that do not need to be analyzed, such as library models. |
'1'|'2'|'3' | Polyspace analyzes referenced models up to the specified
depth in the reference hierarchy. To analyze the models that
are referenced by the top model, specify the property
ModelRefVerifDepth as
'1' . To analyze models that are
referenced by the first level of references, specify this
property as '2' . | ||
'All' | Polyspace verifies all referenced models. | ||
ModelRefByModelRefVerif | Specify whether you want to analyze all referenced models together or individually. | true | Polyspace analyzes the top model and the referenced models together. Use this option to check for integration or scaling issues. |
false (default) | Polyspace analyzes the top model and the referenced models individually. | ||
AutoStubLUT | Specifies how lookup tables are used. | true (default) | Polyspace stubs the lookup tables and verifies the model without analyzing the lookup table code. |
false | Polyspace includes the lookup table code in the analysis. | ||
CheckConfigBeforeAnalysis | Specifies the level of configuration checking done before the Polyspace analysis starts. | 'Off' | Polyspace checks only for errors. The analysis stops if errors are found. |
'OnWarn' (default) | Polyspace stops the analysis when errors are found and displays a message when warnings are found. | ||
'OnHalt' | Polyspace stops the analysis when either errors or warnings are found. |
Example: pslinkrunCrossRelease('polyspace_controller_demo',
psOpt)
, where psOpt
is an options object
created by calling pslinkoptions
asModelRef
— Indicator for model reference analysis
false
(default) | true
Indicator for model reference analysis, specified as
true
or false
.
If
asModelRef
isfalse
(default), the function generates options files so that Polyspace analyzes the generated code as standalone code.If
asModelRef
istrue
, the function generates options files so that Polyspace analyzes the generated code as model reference code.
Example: pslinkrunCrossRelease('polyspace_controller_demo',
psOpt,true)
Data Types: logical
OptionsFile
— Relative path to a Polyspace options file
default Polyspace analysis options (default) | relative path to a custom options file
Relative path to a text file that contains a list of Polyspace analysis options. The options file must have each option in a separate line.
Example: pslinkrunCrossRelease('polyspace_controller_demo',
psOpt,true,'OptionsFile.txt')
Data Types: char
Output Arguments
polyspaceFolder
— Folder containing Polyspace project and results
character vector
Name of the folder containing Polyspace projects and results, specified as a character vector. The
default value of this variable is
results_$ModelName$
.
To change this value, see Output folder.
resultsFolder
— Full path to subfolder containing Polyspace results
character vector
Full path to subfolder containing Polyspace results, specified as a character vector.
The folder results_$ModelName$
contains your
Polyspace project and a subfolder $ModelName$
containing the analysis results. This variable provides the full path to the
subfolder.
To change the parent folder results_$ModelName$
, see
Output folder.
Version History
Introduced in R2021a
See Also
slbuild
(Simulink) | pslinkoptions
| polyspacePackNGo
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)