Default Polyspace Options for Code Generated with TargetLink
TargetLink Support
The Windows® version of Polyspace® Bug Finder™ is compatible with dSPACE® Data Dictionary and TargetLink® Code Generator.
Polyspace Bug Finder does support CTO generated code. However, for better results, MathWorks® recommends that you disable the CTO option in TargetLink before generating code. For more information, see the dSPACE documentation.
Because Polyspace Bug Finder extracts information from the dSPACE Data Dictionary, you must regenerate the code before performing an analysis.
Default Options
Polyspace sets the following options by default:
-sources path_to_source_code -results-dir results_folder_name -I path_to_source_code -D PST_ERRNO -I dspaceroot\matlab\TL\SimFiles\Generic -I dspaceroot\matlab\TL\srcfiles\Generic -I matlabroot\polyspace\include -I matlabroot\extern\include -I matlabroot\rtw\c\libsrc -I matlabroot\simulink\include -functions-to-stub=[rtIsNaN,rtIsInf,rtIsNaNF,rtIsInfF] -scalar-overflows-behavior wrap-around -boolean-types Bool
Note
dspaceroot
and
matlabroot
are the dSPACE and MATLAB® tool installation directories respectively.
Lookup Tables
By default, Polyspace provides stubs for the lookup table functions. Supported lookup table
types include TL_Lookup1D
, TL_Lookup2D
,
TL_IndexSearch
, and TL_Interpolation
. The
dSPACE data dictionary is used to define the return value ranges of the
lookup table functions. If a lookup table function uses extrapolation to calculate
output values beyond the specified input values, the range of the return value is
the full range for the type of returned variable. You can disable this behavior from
the Polyspace configuration menu.
Data Range Specification
You can constrain inputs, parameters, and outputs to lie within specified data ranges. See Work with Signal Ranges in Blocks (Simulink).
The software automatically creates a Polyspace constraints file using the dSPACE Data Dictionary for each global variable. The constraint 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 information allows Polyspace software to model real values for the system during analysis. Carefully defining the min-max information in the model allows the analysis to be more precise, because only the range of real values is analyzed.
Note
Boolean types are modeled having a minimum value of 0 and a maximum of 1.
You can also manually define a constraint file in the Polyspace user interface. See Specify External Constraints for Polyspace Analysis. If you define a constraint file, the software appends the automatically generated information to the constraint file you create. Manually defined constraint information overrides automatically generated information for all variables.
Constraints cannot be applied to static variables. Therefore, the compilation
flags -D static=
is set automatically. It has the
effect of removing the static keyword from the code.
If you have a problem with name clashes in the global name space, either rename the
variables or disable this option in Polyspace configuration.
Code Generation Options
From the TargetLink Main Dialog, it is recommended to:
Set the option
Clean code
Unset the option
Enable sections/pragmas/inline/ISR/user attributes
Turn off the compute to overflow (CTO) generation. Polyspace can analyze code generated with CTO, but the results may not be as precise.
When you install Polyspace, the tlcgOptions
variable is updated with
'PolyspaceSupport', 'on'
(see variable in
'C:\dSPACE\Matlab\Tl\config\codegen\tl_pre_codegen_hook.m'
file).