polyspacePackNGo
Generate and package options files to run Polyspace analysis on code generated from Simulink model
Since R2020b
Syntax
Description
examines the Simulink® model archivePath
= polyspacePackNGo(mdlName
)mdlName
, extracts Polyspace® options files from it, and packages the options files in the zip file located
at archivePath
. Before using polyspacePackNGo
,
generate code from your Simulink model. Then archive the generated code, for instance, by using
packNGo
. Generate the Polyspace options files from the Simulink model and include them in the code archive by using
polyspacePackNGo
. In a different development environment, when
running a Polyspace analysis of the generated code, use the options files included in the code
archive to preserve model-specific information, such as design range specifications. You
must have Embedded Coder® to use slbuild
.
generates and packages the Polyspace options files that are generated according to the specification in
archivePath
= polyspacePackNGo(mdlName
,psOpt
)psOpt
. The object psOpt
must be a Polyspace options object that is generated by using pslinkoptions
. Using psOpt
, modify
the options for the Polyspace analysis.
generates and packages the Polyspace options files by using archivePath
= polyspacePackNGo(mdlName
,psOpt
,asModelRef
)asModelRef
to specify whether to
generate option files for model reference code or standalone code.
Examples
Generate and Package Polyspace Options Files
To generate and package Polyspace options files for a Simulink model, use polyspacePacknGo
.
Open the Simulink model polyspace_controller_demo
and specify a folder
for storing the generated code.
cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample',... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir;
To enable packing the generated code in an archive, set the option
PackageGeneratedCodeAndArtifacts
to true
.
Specify the name of the generated code archive as
genCodeArchive.zip
.
configSet = getActiveConfigSet(mdlName); set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true); set_param(configSet, 'PackageName', 'genCodeArchive.zip');
To make the model compatible with Polyspace, set SystemTargetFile
to
ert.tlc
.
set_param(configSet, 'SystemTargetFile', 'ert.tlc');
After configuring the model, generate code.
slbuild(mdlName)
Because PackageGeneratedCodeAndArtifacts
is set to
true
, the generated code is packed into the archive
genCodeArchive.zip
.
Generate and package Polyspace options files.
zipFile = polyspacePackNGo(mdlName);
genCodeArchive.zip
, the Polyspace options files are
packaged in the TempDir\polyspace
folder.Package Polyspace Options Files That Have Specific Polyspace Analysis Options
To specify the Polyspace analysis options when packaging and generating options files, use
pslinktoptions
.
Open the Simulink model polyspace_controller_demo
and configure the model
for generating a code archive that is compatible with Polyspace.
cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample', ... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir; configSet = getActiveConfigSet(mdlName); % Enable packing the generated code into an archive set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true); % Specify a name for the code archive set_param(configSet, 'PackageName', 'genCodeArchive.zip'); % Configure the model to be Polyspace Compatible set_param(configSet, 'SystemTargetFile', 'ert.tlc');
After configuring the model, generate code.
slbuild(mdlName)
Because PackageGeneratedCodeAndArtifacts
is set to
true
, the generated code is packed into the archive
genCodeArchive.zip
.
To specify the model configuration for the Polyspace analysis, use a pslinkoptions
object. Create this object by
using the function
pslinkoptions
.
psOpt = pslinkoptions(mdlName);
psopt
is a structure where the fields are model configurations
that you can specify.Specify the model configuration by using psOpt
object. For
instance, set InputRangeMode
to full range. For a full options list,
see the input argument psOpt
.
psOpt.InputRangeMode = 'FullRange';
Generate and package Polyspace options files. Use the psOpt
object as the second
argument in
polyspacePacknGo
.
zipFile = polyspacePackNGo(mdlName,psOpt);
genCodeArchive.zip
, the Polyspace options files are
packaged in the TempDir\polyspace
folder. The file
optionsFile.txt
contains the specified Polyspace analysis options.Package Polyspace Options Files for Code Generated as a Model Reference
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 model by using slbuild
with the build process specified as ModelReferenceCoderTarget
. Then,
package the generated code by using packNGo
. To generate and package
Polyspace options files for analyzing such code, use the function
polyspacePacknGo
with the optional argument
asModelRef
set to true
.
Open the Simulink model polyspace_controller_demo
and configure the model
for generating a code archive that is compatible with Polyspace.
cd(matlabroot); mdlName = 'polyspace_controller_demo'; openExample('polyspace_code_prover/OpenSimulinkModelForPolyspaceAnalysisExample', ... 'supportingFile',mdlName); mkdir TempDir; load_system(mdlName); cd TempDir; configSet = getActiveConfigSet(mdlName); % Enable packing the generated code into an archive set_param(configSet, 'PackageGeneratedCodeAndArtifacts', true); % Specify a name for the code archive set_param(configSet, 'PackageName', 'genCodeArchive.zip'); % Configure the model to be Polyspace Compatible set_param(configSet, 'SystemTargetFile', 'ert.tlc');
After configuring the model, generate a model reference simulation target from it by
using the function slbuild
. Specify the option
ModelReferenceCoderTarget
. See slbuild
.
slbuild(mdlName,'ModelReferenceCoderTarget');
slprj
.To package the code that is generated as a model reference, use the function
packNGo
. Locate the file buildinfo.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 object buildinfo.mat
.
See packNGo
(Embedded Coder).
% Locate buildinfo and generate code archive buildinfo = fullfile(pwd,'slprj','ert',mdlName,'buildinfo.mat'); packNGo(buildinfo)
Generate and package Polyspace options files. Omit the optional second argument. Set the third argument
asModelRef
to
true
.
zipFile = polyspacePackNGo(mdlName,[],true);
polyspace
folder.Input Arguments
mdlName
— Name of Simulink model for which to generate Polyspace options files
model name
A character array containing the name of the model for which you want to generate and package the Polyspace options files.
Example: polyspacePackNGo('
modelName
')
Data Types: char
psOpt
— Polyspace options object
options associated with model
(default) | 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 a structure where
individual fields represent analysis options. For a fill list of options that you can
modify, see the table Polyspace Analysis Options Supported by
polyspacePacknGo
.
Polyspace Analysis Options Supported by
polyspacePacknGo
Property | 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. |
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: polyspacePackNGo('
, where modelName
',
psOpt)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.Note
If you set
asModelRef
totrue
, useslbuild
to generate code.
Example: polyspacePackNGo('
modelName
',
psOpt,true)
Data Types: logical
Output Arguments
archivePath
— The full path to the archive containing the generated options files
path to archive
A character array containing the path to the generated archive. The options files
are located in the polyspace
folder in the archive. The
polyspace
folder contains these options files:
optionsFile.txt
: a text file containing the Polyspace options required to run a Polyspace analysis on the generated code without losing model-specific information, such as design range specification.
: A file containing the design range specification of the model.model
_drs.xmllinksData.xml
: A file that links the generated code to the components of the model.
To run a Polyspace analysis on the generated code in an environment that is different than the environment where the code was generated from the Simulink model, use these files.
Data Types: char
Version History
Introduced in R2020b
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
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)