4. QGen Model Verifier¶
The QGen Model Verifier performs checks for MISRA violations, and verifies that the code generated for the model does not suffer from one of the following possible run-time issues:
- Possible run-time errors, including:
- Integer overflow
- Signal out of range
- Division by zero
- Logic errors, including:
- Conditions that are always true, or always false
- Expressions that always return the same value
- Other functional or safety property violations, including:
- Simulink Assertion blocks that might fail
4.1. Using qgenv¶
Similarly to code generation, model verification is performed by the executable
qgenv which can be invoked in three methods:
- From the Simulink GUI
- From the MATLAB Command Line
- From the System Command Line
4.2. From the Simulink GUI¶
QGen model verification can be invoked from the Simulink user interface. This requires QGen to be correctly setup in MATLAB following the instructions in Setting up QGen in MATLAB.
Model verification is invoked from the window of a Simulink model by clicking on the QGen menu and then Verify.
4.3. From the MATLAB Command Line¶
QGen model verification can be invoked from the MATLAB command line using the
qgen_verify function. This requires QGen to be correctly setup in MATLAB
following the instructions in Setting up QGen in MATLAB.
qgen_verify has two required inputs and a number of optional parameters:
qgen_verify (<mdl_path>, <mode> [, <options>]);
mdl_pathName of the mdl or slx file optionally with path (absolute or relative).
modeVerification mode. The accepted values are
--bug-finderExecutes a faster but less complete verification.
--proofExecutes a slower but more complete verification.
<options> are all string values. Each option is either a single boolean
switch or a switch followed by a value. Options can be passed in an arbitrary
order.
Note
Several options correspond to identical or similar options of the
qgenv executable. As a result, more details on options will be
provided in From the System Command Line.
Note
Options can be passed either as function arguments, or as a cell array of length 1 where the value of the first element is also a cell array containing the list of options.
The accepted boolean switches are:
--wmisraTreat violations to MISRA Simulink as warnings.
--no-misraAllow violations to MISRA Simulink.
--export-ws, -wExport workspace contents to m-file and ignore any MATLAB files passed in the function input.
-vPrint verbose output when exporting the decoration file
--clean, -cInstructs QGen to delete all the content of the output directory before starting the code generation.
--incremental, -iInstructs QGen to leave the content of the output directory as is. Generated files will overwrite existing files with the same name, but other existing files will remain untouched.
Switch-value pairs shall be passed as two arguments. First is the key and the
second is value. It is assumed that the value does not start with '-' to
distinguish it from other switches
--subsysGenerate code for the subsystem identified by the name in argument (the name is a /-separated path of subsystem names starting from the model root)
--output, -oSpecify the code generation target directory. By default the files are placed in
<modelname>_generated.--matlab, -mProvide a MATLAB file containing the constant, Bus and Signal definitions.
Example command:
qgen_verify ('test.mdl', '--proof', '-m', 'test_def.m')
4.4. From the System Command Line¶
qgenv is invoked on the system command line as follows:
qgenv FILE [switches]
The arguments of the qgenv executable are:
FILEAn slx or mdl Simulink model.
--bug-finderExecutes
qgenvin bug-finding mode, which perform a faster but less complete verification using Codepeer. This switch cannot be passed simultaneously with the--proofswitch.--proofFormally verify the model. This implies a slower but more complete verification. Cannot be passed together with
--bug-finderswitch.--version, -VOutput version and exit.
--from-simulinkDisplay error messages as hyperlinks in the Simulink console.
--help, -hDisplay the list of supported switches.
--matlab, -m FILEProvide MATLAB file containing the definitions of variables used by the Simulink model.
--wmisraTreat violations to MISRA Simulink as warnings.
--no-misraAllow violations to MISRA Simulink.
--subsys PATHProvide the path to the subsystem to verify.
--typing, -t FILEProvide the decoration file.
--lib, -b FILESpecifies directories where library models can be found. The switch can be used multiple times to specify multiple directories.
Note
The
--libswitch is required only in case the relative location of the libraries is different than at the time of generating the decoration file. The new location given with the--libswitch will override the original location which is stored in the decoration file.