The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
March 2009Online OnlyRevised for Version 5.3 (Release 2009a)
September 2009 O nline OnlyRevised for Version 5.4 (Release 2009b)
March 2010Online OnlyRevised for Version 5.5 (Release 2010a)
Model Link Products User’s Guide
Getting Started with PolySpace Model Link
Products
1
Overview of PolySpace M odel Link Products .........1-2
Contents
Getting Started with Model Link Products
Overview
Creating a Simulink Model and Generating Production
Code
Starting the PolySpace Verification
Fixing an Error in the Design and the Simulink Model
Base Workspace vs. PolySpace Data Ranges
Overview of PolySpace Utilities Library
Open Po ly Space Results
PolySpace Enable COM Server
PolySpace Menu
PolySpace Project Configuration
..................................3-4
............................3-3
......................3-3
.....................3-5
...............3-2
iii
PolySpace Utilities Menu ...........................3-8
PolySpace Commands Available in Batch Mode as
M-Functions
Archives Files Produced for the PolySpace
Verification
Template files located in MATLAB installation
directory\polyspace\
Files used in the model directory
Auto-generated files in the model directory
....................................3-10
.....................................3-12
............................ 3-12
.....................3-13
............3-13
Code Generator Specific Information
4
PolySpace Model Link SL Product ..................4-2
Overview
Subsystems
Default Options
Data Range Specification
Code Generation Options
PolySpace Analysis Option s
........................................4-2
......................................4-2
...................................4-2
...........................4-3
...........................4-3
.........................4-4
ivContents
PolySpace Model Link TL Product
Overview
Subsystems
Data Range Specification
Lookup Tables
Code Generation Options
........................................4-15
......................................4-15
........................... 4-15
....................................4-16
........................... 4-17
..................4-15
Glossary
GettingStartedwith
PolySpaceModelLink
Products
• “Overview of P o lySpa ce Model Link Products” on page 1-2
• “Getting Started with Model Link Products” on page 1-3
1
1 Getting Started with PolySpace
®
Model Link Products
Overview of PolySpace Model Link Products
This manual describes how to use PolySpace®for Model-Based Design. The
PolySpace Model Link™ SL and PolySpace Model Link TL products allow you
to launch a PolySpace C verification from a Simulink
Real-Time Workshop
software.
PolySpace Model Link SL and PolySpace Model Link TL products provide
automatic error detection for code generated from Simulink models. It
consists of two principal components:
• A Simulink PolySpace library with associated blocks.
• A “Back to Mode l” extension in the Po ly Space Viewer th at allows direct
navigation from a runtime error in the auto-generated code to the
corresponding Simulink block or Stateflow
®
Embedded Coder™ software, or dSPACE®TargetLink
®
model associated with
®
chart in the Simulink model.
®
1-2
Getting Started with Model Link Products
In this section...
“Overview” on page 1-3
“Creating a Simulink Model and Generating Production Code” on page 1-3
“Starting the PolySpace Verification” on page 1-9
“Fixing an Error in the Design and the Simulink Model” on page 1-11
“Base Workspace vs. PolySpace Data Ranges” on page 1-14
Overview
In this section, you will:
• Create a Simulink model and generate production code (For more
information, see the Real-Time Workshop Embedded Coder Getting StartedGuide)
Getting Started with Model Link Products
• Start the PolySpace verification
Creating a Simulink Model and Generating
Production Code
To create a Simulink model and generate production code:
1 Open MATLAB
2 Create a simple Simulink model, similar to the one below.
rtwdemo_examplemain.c ok (c:\MatLAB704\toolbox\rtw\rtwdemos
\rtwdemo_examplemain_ert_rtw)
### Generating DRS table
### Get Parameters
Getting Started with Model Link Products
### Get Signals
### Starting verification
The exact messages depend on the code generator you use. However, the
messages always have the same format:
• Name of code generator
• Version number of the plug-in
• List of source files
• DRS (Data Range Specification) information.
3 You can follow the progress of the verification in the MATLAB Command
window, and later using the PolySpace Spooler if you are performing a
server verification.
Note Verification of this model takes about 7 minutes. A 3,000 block model
will take approximately one hour to verify, or about 15 minutes for each 2,000
lines of generated code.
Fixing an Error i n the Design and the Simulink Model
After the verification completes, you can view the results using PolySpace
Viewer.
Note If you perform a server verification, you must download your results
from the server before you can view them. For more information, see
“Downloading Results from Server to Client” in the PolySpace Products forC User’s Guide.
To view your results:
1 In the Simulink model window select Tools > PolySpace > PolySpace
Utilities > Open results.
Afterafewseconds,thePolySpaceVieweropens.
1-11
1 Getting Started with PolySpace
®
Model Link Products
Coding review progress view
Procedural
Variables
entities view
view
Selected check view
Source code
Call tree
view
view
1-12
2 Type CTRL-N to go to the next error.
Getting Started with Model Link Products
Overflow in the code
Orange Check in PolySpace®Viewer
3 Click on the orange check.
The check shows an overflow of the two entries. PolySpace software
assumes that the values for entries are full range, and their multiplication
can overflow.
1-13
1 Getting Started with PolySpace
4 Now, you must get back to the model to understand what needs to be fixed.
Click the first underlined blue HTML link near the check in the Source
Code.
The Simulink model opens, highlighting the block with the error.
®
Model Link Products
1-14
Model with Highlighted Block
5 You now must fix the defect in the model. For example, you may come
to one of the following conclusions:
• It is a bug in the design— The developer should saturate the output,
providing this functionally makes sense bound the entries in the model,
by adding blocks which will test the input values, and bound them
accordingly.
• It is a bug in the specifications — The developer should bound the
entries, by giving them a range in Simulink software that PolySpace
verification can take the ranges into account and turns the code green.
Base Workspace vs. PolySpace Data Ranges
After y ou examine the model, you can see a block whose signal range s are not
in the expected range.
Getting Started with Model Link Products
• If its block is supposed to be robust against this range, it is a design bug.
Should the previous block be saturated? Should the signal be bounded
with a “switch” block? It is up to the developer to decide the a ppropriate
change in the model
• If the range is an input range of the model, the developer may wish to
give this informa t ion to the Simulink model, so that PolySpace tools ca n
use that range as an entry.
Prerequisites
Have signals as ExportedGlobal.
Details of a signal
Update Range of Signals
To update your signal ranges:
1 Open model explorer, and go into the Base Workspace tab.
2 Create a signal “my_entry1”&“my_entry2.”
3 Bound it to -15 to 15. Specify its storage class to ExportedGlobal.
1-15
1 Getting Started with PolySpace
Signal in the “Base Workspace”
®
Model Link Products
1-16
4 Model with signals on entries:
Getting Started with Model Link Products
Model with signals my_entry1 and my_entry2 as “ExportedGlobal”.
Re-Generate Code and Launch the PolySpace Verification
Again
To regenerate the code and relaunch the PolySpace verification:
1 Regenerate the code
Theentriesarenolongerpartofastructure, they are separated global each.
This configuration file can now be used as a template for all subsequent
verification.
2-7
2 Advanced Setup Options
2-8
PolySpace Utilities
• “PolySpace Utilities Library” on page 3-2
• “PolySpace Commands Available in Batch Mode as M-Functions” on page
3-10
• “Archives Files Produced for the PolySpace Verification” on page 3-12
3
3 PolySpace
®
Utilities
PolySpace Utilities Library
In this section...
“Overview of PolySpace Utilities Library” on page 3-2
“Open PolySpace Results” on page 3-3
“PolySpace Enable COM Server” on page 3-3
“PolySpace Menu” on page 3-4
“PolySpace Project Configuration” on page 3-5
“PolySpace Utilities Menu” on page 3-8
Overview of PolySpace Utilities Library
The PolySpace Utilities Library consists of four blocks:
• Open PolySpace Results
3-2
• PolySpaceEnableCOMServer
• PolySpace Menu
• PolySpace Project Configuratio n
They can either be run directly from the Simulink library browser or dragged
into a Simulink model (see next figure).
PolySpace®Utilities Library
PolySpace®Utilities
Open PolySpace Results
This option allows the results of the PolySpace verification to be viewed and
easy nav igation with a right click from the PolySpace results to an element in
the Simulink model.
PolySpace Enable COM Server
This block is called by default with the “Open PolySpace Results” block. This
block is mandatory when The PolySpace Viewer is opened outside a Simulink
session to enable the Back to Model feature inside the Viewer.
3-3
3 PolySpace
®
Utilities
Note If you do not have administrator rights to your system, you may receive
an error when using the Back to Model feature in the Viewer. This occurs
because the PolySpace Viewer cannot call the
not have administrator rights to your system, ask your system administrator
to run the command
use with PolySpace software.
matlab /regserver on the version of MATLAB you
regserver command. If you do
PolySpace Menu
The menu consists of two sections, the first for managing the verification and
the second for configuring the tools and documentation.
3-4
PolySpace®Menu
Analysis Management
Analysis management contains the following options:
• Configure project – Opens the PolySpace configuration dialog, for more
information see next section.
• Launch spooler – Opens the PolySpace spooler. For more information,
see “Running Verifications o n PolySpace Server”in the PolySpace Productsfor C User’s Guide .
PolySpace®Utilities Library
• Open results – Opens the PolySpace Viewer with the last available
results. If the verification has been done on the server, download in g them
first is required before clicking on this button. It is recommended to not
change the proposed directory during download.
• Stop local verification – Stops a verification running on the local
machine. If the verification has been remotely spooled this option will only
work during the compilation phase before the verification is sent to the
server. However, you can click the Launch spooler button and stop the
verification from the spooler dialog.
General Options
Tools & Documen t ati o n contains the following option s:
• Don’t use automatic stubs – Enables/disables PolySpace automatic
stubbing of certain blocks behavior. This behavior depends on the code
generator being used and is describedinthedocumentationspecificto
your code generator below.
• Don’t check solver – Disables the check of the solver used with Re al-Time
Workshop Embedded Coder software.
3-5
3 PolySpace
®
Utilities
PolySpace Project Configuration
Clicking on “Project configuration” starts a cut-down PolySpace launcher
(see next figure).
Next figure allows the configuration of the PolySpace project. For example
setting items such as the processor type the code has been generated for,
Compilation flags etc. The first time the tool is run a template configuration
is created with the following options set:
-continue-with-existing-host
-ignore-float-rounding
-OS-target no-predefined-OS
-allow-ptr-arith-on-struct
-results-dir results
Other options are automatically set depending on the code generator being
used. See the docume ntation for specific code generators below for more
information.
3-6
PolySpace®Utilities Library
Project Configuration Interface
3-7
3 PolySpace
®
Utilities
PolySpace Utili
The PolySpace ut
Library directl
To access the ut
Utilities fro
The Utilities menu contains the following options:
• Open results – Opens the PolySpace Viewer with the last available results.
Configure project – Opens the PolySpace configuration dialog, for more
information see next section.
y from the Simulink model window.
m the model window.
ties Menu
ilities menu allows you to access the options in the PolySpace
• Stop local verification – Stops a verification running on the local
machine. If the verification is run on the server, this option only works
during the compilation phase before the verification is sent to the
server. However, you can click the Launch spooler button and stop the
verification from the spooler dialog.
• Launch spooler – Opens the PolySpace spooler. For more information,
see “Running Verifications o n PolySpace Server”in the PolySpace Productsfor C User’s Guide .
• Don’t use automatic stubs – Specifies that the verification will not
generate stubs. By default, PolySpace verification stubs all functions.
Using this option allows you to use manual stubbing. For more information,
see “Stubbing”in the PolySpace Products for C User’s Guide.
PolySpace®Utilities Library
• Don’t check solver – Specifies that the model be verified regardless of the
type of solver selected. To ensure o ptimal precision and performance, the
software checks that the model uses a fixed-step discrete solver. Selecting
this option disables this check.
• Enable initialization function – S pecifies that the
is called before the
_step function. This can reduce orange checks because
_initialize function
the f unctions are called in a more realistic order. When this option is not
enabled (default), functions are called in random order.
• Help – Opens the PolySpace documentation.
3-9
3 PolySpace
®
Utilities
PolySpace Commands Available in Batch Mode as
M-Functions
You can also run
Command
PolySpaceForEmbeddedCoder
PolySpac
PolySpaceSpooler
PolySpaceViewer
eForTargetLink
the following commands from the command line.
Description
Launch PolySpace
verification on code
generated by Real-Time
Workshop Embedded Coder
software
Launch Pol
generate
Inspect the queue of the
remotely sent verification
over the server
Launch PolySpace Viewer
ySpace on code
dbyTargetLink
Icon
PolySpaceSetTemplateCFGFile
PolySpaceGetTemplateCFGFile
3-10
Selectatemplatefilein
batch mode
Get the currently selected
template file (empty by
default)
PolySpace®Commands Available in Batch Mode as M-Functions
Command
PolySpaceReconfigure
ver
Example with EmbeddedCoder:
Suppose that you open a Simulink model with the name
Enter
window.
The verification starts.
Description
Icon
In case of a PolySpace
release update without
enabling the MATLAB
plug-in
Displays the PolySpace
For Model-Link Version
number along with other
MathWorks product
information
example.mdl.
PolySpaceForEmbeddedCoder('example') in the MATLAB Command
3-11
3 PolySpace
®
Utilities
Archives Files Produced for the PolySpace Verification
In this section...
“Template files located in MATLAB installation directory\polyspace\” on
page 3-12
“Files used in the model directory” on page 3-13
“Auto-generated files in the model directory” on page 3-13
Template files located in MATLAB installation
directory\polyspace\
When a verification is first performed the tool copies the following two files
into the local model directory. On subsequent verifications the files are not
copied again meaning it is OK to mo del the copies in the model directory.
model_directory/model_name-polyspace.cfg at the start of the first
verification of the model. It contains the template PolySpace
configuration settings to support the TargetLink code generator. The
templateTargetLink.cfg file can be updated with site specific settings, to
ease verification of new models.
3-12
A MATLAB command exists to change the name/location of the file which
contains the template configuration:
PolySpaceSetTemplateCFGFile(config_filename)
This is most useful when the PolySpace verification is started as part of an
automated process. Here the process would set the template configuration
file to use, erase the local copy in the model directory and then start the
PolySpace verification.
•
stub\ppcom_ec.sh — This file is copied to the model_directory/ppco m_ec.sh
at the start of the first verification of a model. The file is not recopied
for subsequent verifications. It is used to stub lookup table types ( only
interpolation, not extrapolation) to improve the accuracy of verification
results.
Archives Files Produced for the PolySpace®Verif i c a ti on
Files used in the
• model-name-pol
this file is cop
directory\pol
a verificatio
Project Confi
PolySpace Ana
the current m
•
ppcom_ec.sh
command.
polyspace_
•
Advanced op
box. This o
together w
lookup tab
additiona
list of ex
Auto-ge
These fi
started
l file list option needs to be set together with configuring the
tra files to analyze.
nerated files in the model director y
les are generated from the model for each verification when it is
, and do not need archiving:
yspace.cfg
ied from the MATLAB installation
yspace\cfg\templateEmbeddedCoder.cfg file the first time
n is run on a m odel. It is subsequently mo dified by the
guration block, or the Configure button in the option in the
lyzer dialog. It contains the PolySpace settings for verifying
odel.
— The PolySpace Embedded Coder post preprocessing
additional_file_list.txt
tion, Select Files is used in the PolySpace Analyzer dialog
ption allows files that are not part of the model to be analyzed
ith the model. Fo r example these files could con tain custom
le code, custom stubs, device driver code etc. The Enable
model directory
— As mentioned above
— This file i s created if the
•
model n
from th
•
polysp
direc
•
polys
•
mode
the P
ame_drs.txt
e model.
ace_include_dir_list.txt
tories extracted from the mode.
pace_file_list.txt
l name_last_parameter.txt
olySpace Analyzer dialog box.
— The DRS information extracted automatically
— List of file contained in the model to analyze
— List of compilation include
— The last set of parameters used in
3-13
3 PolySpace
®
Utilities
3-14
CodeGeneratorSpecific
Information
• “PolySpace Model Link SL Product” on page 4-2
• “PolySpace Model Link TL Product” on page 4-15
4
4 Code Generator Specific Information
PolySpace Model Link SL Product
In this section...
“Overview” on page 4-2
“Subsystems” on page 4-2
“Default Options” on page 4-2
“Data Range Specification” on page 4-3
“Code Generation Options” on page 4-3
“PolySpace Analysis Options” on page 4-4
Overview
The PolySpace Model Link SL product has been tested with Real-Time
Workshop Embedded Coder software — see the Installation Guide for more
information.
4-2
Subsystems
A dialog will be presented after clicking on the PolySpace for Embedded Coder
block if multiple subsystems are present in a diagram. Simply select the
subsystem to analyze from the list. The subsystem list is generated from the
directory structure from the code that has been generated.
Default Options
The following default options are set by the tool:
Note matlabroot is the MATLAB tool installation directory.
Data Range Specification
The software automatically creates a PolySpace Data RangeSpecification
(DRS) file using information from the MATLAB workspace. This DRS
information is used to initialize each global variable to the range of valid
values, as defined by the min-max information in the workspace.
The main sources o f information are Simulink. sig nals and
Simulink.parameters.
You can also manually define a DRS file using the PolySpace Launcher. If
youdefineaDRSfile,thesoftwareappendstheautomaticallygenerated
information to the DRS file you create. Manually defined DRS information
overrides automatically generatedinformationforallvariables.
Code Generation Options
This section describes recommended configuration parameter settings for
Real-Time Workshop
options for optimum use of PolySpace verification.
In the Real Time Workshop tab:
1 Select Generate HTML report.
2 Select Include hyperlinks to model.
Note If you do not set this option, navigation from PolySpace results to
the model will not work.
3 Set the system target file to be an appropriate ert.tlc (use the b row s e
button to locate).
®
software. The MathWorks recommends using these
4-3
4 Code Generator Specific Information
This is an indication that the code generator is Real-Time Workshop
Embedded Coder software (and not just Real-Time Workshop software,
used for rapid prototyping).
In the Solver tab:
1 Set the solver Type to Fixed-step,
2 Set the Solver to discrete (no continuous state).
This specifies that the code is generated for a target, and not for a
simulation based on continuous timing.
In the Interface panel tab:
1 Ensure that Generate reusable code is not selected.
Setting this option will generate more warnings in the PolySpace results.
PolySpace Analysis Options
This section describes reco mmended Analysis options for verifying code
generated with Real-Time Workshop Embedded Coder software. The
MathWorks recommends setting these options in your PolySpace project
before verifying generated code.
If y ou have PolySpace Model Link SL software, you can specify the Analysis
options for your PolySpace Project by selecting Tools > PolySpace> PolySpace Utilities > Configure P roject in the Simulink model window.
Option
General Options
-author<your name>
4-4
Recommended Value
Comments
Specifies the name of the
author of the verification
PolySpace®Model Link™ SL Product
Option
-date<date stamp>
-desktop
Recommended Value
Selected – When checking
MISRA Compliance (code
analysis).
Not Selected –When
checking runtime errors (code
verification)
-I
-prog<session identifier>
See CommentsSpecifies the name of a folder
Comments
Specifies a date stamp for the
verification in
dd/mm/yyyy
format. This information is
labelled in the GUI as Date.
You can specify alternate
date formats using Edit >Preferences.
Specifies whether verification
occurs on the PolySpace Client
or PolySpace Server. The
MathWorks recommends
using the Client to perform
MISRA analysis and the
Server for code verification.
to include when compiling C
sources. You can specify only
one folder for each
I,butcan
use the option multiple times.
A script to automatically
determine
buildInfo is available
-I based on
Specifies the application name.
Use characters valid for Unix
file names.
This information is labelled in
the GUI as Session identifier.
For example,
New_Project.
4-5
4 Code Generator Specific Information
Option
-results-dir<results dir>
-sources
-sources-list-file
Recommended Value
See CommentsSpecifies a list of source files
Comments
Specifies the directory in
which PolySpace software
saves verification results. You
can specify a relative path.
However, be careful if you
plan to launch verification
remotely over a network, or if
you plan to copy the project
configuration file using the
"Save as" option.
to be verified. You must
enclose the list of source files
in double-quotes, separated by
commas.
•
-sources "file1[ file2[
...]]"
(Linux and
Solaris™) -
•
-sources
"file1[,file2[, ...]]"
(Windows®, Linux and
Solaris)
4-6
•
-sources-list-file
file_name
(not a graphical
option)
You can specify multiple
files using UNIX® standard
wildcards.
The software compiles the
source files in the order in
which you specify them.
If you do not specify any files,
the software verifies all files
PolySpace®Model Link™ SL Product
Option
-verif-version
Recommended Value
1.0
Target/Compilation Options
-d
-OS-targetVisual
See CommentsDefines macro compiler flags
Comments
in the source directory in
alphabetical order.
Note The specified files
must have valid extensions:
*.(c|C|cc|cpp|CPP|cxx|CXX)
A script to automatically
determine
buildInfo is available.
-sources based on
Specifies the version identifier
of the verification. You can
use this option to identify
multiple verifications of the
same project. This information
is identified in the GUI as the
Version.
used during compilation.
Specifies the operating system
Useone
target for PolySpace stubs.
RTWgeneratedfile.
This information allows the
verification to use appropriate
PolySpaceModelLinkSLdoes
system definitions during
notdothisbydefault.
preprocessing in order to
dforeachlineofthe
defines.txt
analyze the included files
properly.
4-7
4 Code Generator Specific Information
Option
-targeti386
Compliance with standards Options
-dos
Recommended Value
Selected
Comments
Specifies the target processor
type. Thisallowsthe
verification to consider the
size of fundamental data types
and the endianess of the target
machine.
You can configure and specify
generic targets. For more
information, see Setting Up
Project for Generic Target
Processors in the PolySpace
Products for C User’s Guide.
You must select this option
if the contents of the include
or source directory comes
from a DOS or Windows file
system. The option allows
the verification to deal with
upper/lower case sensitivity
and control characters issues.
Concerned files are:
4-8
• Header files – All include
folders specified (
• Source files – All source
files selected for the
verification (
option)
-I option)
-sources
PolySpace®Model Link™ SL Product
Option
-misra2
-includes-to-ignore<MSVC dir>\VC\include
Recommended Value
[all-rules | file_name]
Comments
Specifies that the software
checks coding rules in
conformity to MISRA-C:2004.
All MISRA checks are
included in the log file of
the verification. Options:
•
all-rules –Checksall
available MISRA C® rules.
Any violation of MISRA
C rules is considered a
warning.
•
filename –Specifiesan
ASCII file containing a list
of MISRA® rules to check.
Specifies files or folders that
are excluded from MISRA
rules checking (all files and
subfolders within the selected
folder). This option is useful
when you have non-MISRA C
conforming include headers.
PolySpace inner settings Options
-main-generator-writes-variablespublic
Specifies how the generated
main initializes global
variables.
By selecting public, every
variable except
const variables are assigned a
static and
"random" value, representing
the full range of possible
values
4-9
4 Code Generator Specific Information
Option
-main-generator-callsunused
-ignore-float-rounding
Recommended Value
SelectedSpecifies how the verification
Comments
Specifies how the generated
main calls functions.
By selecting unused, e very
function is called by the
generated main unless it is
called elsewhere by the code
undergoing verification.
rounds floats.
If this option is not selected,
the verification rounds fl oats
according to the IEEE® 754
standard – simple precision
on 32-bits targets and double
precision on targets that define
double as 64-bits.
When you select this option,
the verif ica tion perform s exact
computation.
Selecting this option can lead
to results that differ from "real
life," depending on the actual
compiler and target. Some
paths may be reachable (or not
reachable) for the verification
while they are not reachable
(or are reachable) for the
actual compiler and target.
Precision/Scaling Options
4-10
However, this option reduces
the number of unproven checks
caused by float approximation.
PolySpace®Model Link™ SL Product
Option
-O2
Recommended Value
Comments
Specifies the precision level for
the verification.
Higher precision levels provide
higher selectivity at the
expense of longer verificat ion
time.
The MathWorks recommends
you begin with the lowest
precision level. You can
then address red errors and
gray code before relaunching
PolySpace verification using
higher precision levels.
Benefits:
A higher precision level
contributes to a higher
selectivity rate, making
results review more efficient
and hence making bugs in the
code easier to isolate.
The precision level specifies
the algorithms used to model
the program state space during
verification:
•
-O0 corresponds to static
interval verification.
•
-O1 corresponds to complex
polyhedron model of domain
values.
•
-O2 corresponds to more
complex algorithms to
closely model domain values
(a mixed approach with
4-11
4 Code Generator Specific Information
Option
-fromscratch
Recommended Value
Comments
integer lattices and complex
polyhedrons).
•
-O3 is suitable only for
units smaller than 1,000
lines of code. For such code,
selectivity may reach as
high as 98%, but verification
maytakeuptoanhourper
1,000 lines of code.
Specifies the phase from which
verification starts.
You can use this option on
an existing verification to
elaborate on the results that
you have already obtained.
For example, if a verification
ran
-to pass1, you can restart
the verification
-from pass1
to reduce verification tim e.
Note the following:
4-12
-to
c-compile
– When checking
MISRA compliance only.
pass0
• This option can be used only
for client verifications. All
server verifications start
from
scratch.
• All options other than
scratch can be used only
if the previous verification
was launched using the
option
-keep-all-files.
• You cannot use this option if
you modify the source code
between verifications.
Specifies the phase after which
the verification stops. Each
PolySpace®Model Link™ SL Product
Option
Recommended Value
– When verifying code for the
first time.
pass4 –Whenperforming
subsequent verifications of
code.
Comments
verification phase improves
the selectivity of your results,
but increases the overall
verification time.
Improved selectiv ity can make
results review more efficient,
and hence make bugs in the
code easier to isolate.
The MathWorks recommends
you begin by running
pass0
Analysis level 0
(Software Safety
-to
)Youcan
then address red errors and
gray code before relaunching
verification using higher
integration levels.
Default P olySpace Analysis Options
When using the PolySpace Model Link SL product, the software sets the
following Analysis options by default:
-sources path_to_source_code
-desktop
-D PST_ERRNO
-I matlabroot\polyspace\include
-I matlabroot\extern\include
-I matlabroot\rtw\c\libsrc
-I matlabroot\simulink\include
-I matlabroot\sys\lcc\include
-ignore-float-rounding
-OS-target no-predefined-OS
-allow-ptr-arith-on-struct
-results-dir results
4-13
4 Code Generator Specific Information
Note matlabroot is the MA TLAB installation directory.
4-14
PolySpace Model Link TL Product
In this section...
“Overview” on page 4-15
“Subsystems” on page 4-15
“Data Range Specification” on page 4-15
“Lookup Tables” o n page 4-16
“Code Generation Options” on page 4-17
Overview
The PolySpace Model Link TL product has been tested with the some release
of the dSPACE Data Dictionary version and TargetLink Code Generator - see
the Installation Guide for more information.
As the PolySpace Model Link TL product extracts information from the
dSPACE D ata Dictionary remember to regeneratethecodebeforeperforming
a PolySpace verification. This ensures that the Data Dictionary has been
correctly updated.
PolySpace®Model Link™ TL Product
Subsystems
A dialog will be presented after clicking on the PolySpace for TargetLink
block if multiple subsystems are present in a diagram. Simply select the
subsystem to analyze from the list.
Data Range Specification
The tool a uto m atically creates PolySpace Data RangeSpecification (DRS)
information using the dSPACE Data Dictionary for each global variable. This
DRS information is used to initialize each global variable to the range of valid
values as defined by the min-max information in the data dictionary. This
allows PolySpace software to model every value that is legal for the system
during its verification. Further the Boolean types are modeled having a
minimum value of 0 and a maximum of 1. Defining the min-max information
carefully in the model can help PolySpace verification to be more precise
significantly because only range of reels values are analyzed.
4-15
4 Code Generator Specific Information
You can also manually define a DRS file using the PolySpace Launcher. If
youdefineaDRSfile,thesoftwareappendstheautomaticallygenerated
information to the DRS file you create. Manually defined DRS information
overrides automatically generatedinformationforallvariables.
DRS cannot be applied to static variables. Therefore, the compilation flag s
static=
is set automatically. It has the effect of removing the static keyword
-D
from the code. If you hav e a problem with name clashes in the global name
space you may need to either rename one of or variables or disable this option
in PolySpace configuration.
Lookup Tables
The tool by default provides stubs for the lookup table functions. This
behavior can be disabled from the PolySpace menu — see “PolySpace Menu”
on page 3-4 for more information. The dSPACE data dictionary is used to
define the range of their return values. Note that a lookup table that uses
extrapolation will return full range for the type of variable that it returns.
Default Options
The following default options are set by the tool:
-I path to source code
-desktop
-D PST_ERRNO
-I dspaceroot\matlab\TL\SimFiles\Generic
-I dspaceroot\matlab\TL\srcfiles\Generic
-I dspaceroot/matlab\TL\srcfiles\i86\LCC
-I matlabroot\polyspace\include
-I matlabroot\extern\include
-I matlabroot\rtw\c\libsrc
-I matlabroot\simulink\include
-I matlabroot\sys\lcc\include
4-16
Note dspaceroot and matlabroot are the dSPACE and MATLAB tool
installation directories respectively.
PolySpace®Model Link™ TL Product
Code Generation
From the TargetL
code” and desele
attributes”.
When installi
variable has b
’C:\dSPACE\M
ink Main D ia log, it is recomm ended to set the option “Cl ean
ct the option “Enable sections/pragmas/inline/ISR/user
ng the PolySpace Model Link TL product, the tlcgOptions
een updated with ’PolyspaceSuppo rt’, ’on’ (see variable in
In computer programming, atomic describes a unitary action or object
that is essentially indivisible, unchangeable, whole, and irreducible.
Atomicity
In a transaction involving two or more discrete pieces of information,
either all of the pieces are committed or none are.
Batch mode
Execution of PolySpace from the command line, rather than via the
launcher Graphical User Interface.
Category
One of four types of orange check: potential bug, inconclusive check,
data set issue and basic imprecision.
Certain error
See ”red check.”
Check
A test performed by PolySpace during a verification and subsequently
colored red, orange, green or gray in the viewer.
Code verification
The PolySpace process through which code is tested to reveal definite
and potential runtime errors and a set of results is generated for review.
Dead Code
Code which is inaccessible at execution time under all circumstances
due to the logic of the software executed prior to it.
Development Process
The process used within a company to progress through the software
development lifecycle.
Green check
Code has been proven to be free of runtime errors.
Glossary-1
Glossary
Gray check
Unreachable code; dead code.
Imprecision
Approximations are made during a PolySpace verification, so data
values possible at execution time are represented by supersets including
those values.
mcpu
Micro Controller/Processor Unit
Orange check
A warning that represents a possible error which may be revealed upon
further investigation.
PolySpace Approach
The manner of use of Po lySpace to achieve a particular goal, with
reference to a collection of techniques and guiding principles.
Glossary-2
Precision
An verification which includes few inconclusive orange checks is said
to be precise
Progress text
Output from PolySpac e during verification to indicate what p roportion
of the verification has been completed. Could be considered as a “textual
progress bar”.