| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink Design Verifier |
| Contents | Index |
| Learn more about Simulink Design Verifier |
| On this page… |
|---|
Constructing the Example Model Parameterizing the Constant Block |
The next five tasks describe how to create and analyze a simple Simulink model, for which you generate test cases that achieve decision coverage. However, in this example, achieving complete decision coverage is possible only when the Simulink Design Verifier software treats a particular block parameter as a variable during its analysis. Toward that end, this example explains how to specify parameter configurations for use with the Simulink Design Verifier software.
The following workflow guides you through the process of completing this example:
| Task | Description | See... |
|---|---|---|
| 1 | Construct the example model. | |
| 2 | Specify a variable as the value of a Constant block parameter. | |
| 3 | Constrain the value of the variable that the Constant block specifies. | |
| 4 | Generate test cases for your model and interpret the results. | |
| 5 | Simulate the test cases and measure the resulting decision coverage. |
In this task, you construct a simple Simulink model that you use throughout the remaining tasks.
Create an empty Simulink model (see Creating an Empty Model in Simulink User's Guide for help with this step).
Copy the following blocks into your empty model window (see Adding Blocks to Your Model in the Simulink documentation for help with this step):
Two Inport blocks to initiate the input signals, from the Sources library
A Multiport Switch block to provide simple logic, from the Signal Routing library
A Constant block to control the switch, from the Sources library
An Outport block to receive the output signal, from the Sinks library
In your model window, double-click the Multiport Switch block to access its dialog box and specify its Number of inputs option as 2.
In your model window, connect the blocks so that your model looks like this (see Connecting Blocks in Simulink User's Guide for help with this step):

In your model window, select Simulation > Configuration Parameters.
The Configuration Parameters dialog box appears.
In the Select tree on the left side of the Configuration Parameters dialog box, click the Solver category. Under Solver options on the right side, set the Type option to Fixed-step, and then set the Solver option to Discrete (no continuous states).
The Configuration Parameters dialog box looks as follows:

Click Apply and OK to apply your changes and close the Configuration Parameters dialog box.
Save your model as param_example.mdl for use in the next step.
In this task, you parameterize the Constant block in your model. In particular, you specify a variable as the value of the Constant block's Constant value parameter.
In your model window, double-click the Constant block.
The Constant block parameter dialog box appears.
In the Constant value box, enter A.
The Constant block parameter dialog box should look as follows.

Click OK to apply your change and close the Constant block parameter dialog box.
In the MATLAB Command Window, enter
A = 1;
This command defines in the MATLAB workspace a variable named A whose value is 1. The Simulink software resolves the Constant value parameter to this variable, initializing its value for simulation.
Save your model for use in the next step.
In this task, you customize the parameter configuration file template so that it constrains the variable A.
In your Simulink model window, select Tools > Design Verifier > Options.
The Simulink Design Verifier software displays its options in the Configuration Parameters dialog box.
In the Select tree on the left side of the Configuration Parameters dialog box, click the Design Verifier > Parameters category. In the Parameters pane on the right side, ensure that the Apply parameters option is enabled.
Enabling the Apply parameters option provides access to the Parameter configuration file option.
Click Edit next to the Parameter configuration file option.
The Simulink Design Verifier software opens sldv_params_template.m in an editor.
Edit the template's text so that it appears as follows:
function params = params_example_function
% This function defines a parameter configuration for the
% example model that the documentation discusses.
params.A = [1 2];The preceding code renames the function as params_example_function and constrains parameter A to the closed interval [1 2].
Save your changes to the template as params_example_function.m in the same folder as the example model.
Close the MATLAB Editor.
In the Configuration Parameters dialog box, click Browse next to the Parameter configuration file option, and then select your parameter configuration file, params_example_function.m.
Click Apply and OK to apply your change and close the Configuration Parameters dialog box.
Save your model for use in the next step.
In this task, you execute the Simulink Design Verifier analysis using the parameter configuration file you just created. The software generates test cases and produces results for you to interpret.
In your Simulink model window, select Tools > Design Verifier > Generate Tests.
The Simulink Design Verifier software begins analyzing your model to generate test cases. When the software completes its analysis, it generates the following items:
Simulink Design Verifier report — The Simulink Design Verifier software displays an HTML report named param_example_report.html.
Test harness — The Simulink Design Verifier software displays a harness model named param_example_harness.mdl.
In the Simulink Design Verifier report Table of Contents, click Test Cases.
Click Test Case 1 to display the subsection for that test case.

This section provides details about Test Case 1 that the Simulink Design Verifier software generated to satisfy a coverage objective in the model. In this test case, a value of 1 for parameter A satisfies the objective.
Scroll down to the Test Case 2 section in the Test Cases chapter.

This section provides details about Test Case 2, which satisfies another coverage objective in the model. In this test case, a value of 2 for parameter A satisfies the objective.
In this final task, you simulate the test cases that the Simulink Design Verifier software generated in Simulating the Test Cases. In addition, you review the coverage report that results from the simulation.
Open the test harness model named param_example_harness.mdl (if it is not already open).

The block labeled Inputs in the test harness model is a Signal Builder block that contains the test case signals. Double-click the Inputs block to view the test case signals.

In the Signal Builder dialog box, click the Run
all button
.
The Simulink software simulates each of the test cases in succession, collects coverage data for each simulation, and displays an HTML report of the combined coverage results at the end of the last simulation.
In the model coverage report, review the Summary section:

This section summarizes the coverage results for the harness model and its Test Unit subsystem. Observe that the subsystem achieves 100% decision coverage.
In the Summary section, click the Test Unit subsystem.
The report displays detailed coverage results for the Test Unit subsystem.

This section reveals that the Multiport Switch block achieves complete decision coverage because the test cases exercise each of its switch pathways.
![]() | Defining Parameter Configurations | Configuring Simulink Design Verifier Options | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |