Skip to Main Content Skip to Search
Product Documentation

Analyzing a Model

About This Demo

The following sections describe a demo model, Cruise Control Test Generation. This demo illustrates how to use the Simulink Design Verifier software to generate test cases that achieve complete model coverage. Through this demo, you learn how to analyze models with the Simulink Design Verifier software and interpret the results.

Opening the Model

To open the Cruise Control Test Generation model, at the MATLAB prompt, enter:

sldvdemo_cruise_control

Generating Test Cases

Running the Analysis

To generate test cases for the Cruise Control Test Generation model, open the model window and double-click the block labeled Run.

The Simulink Design Verifier software begins analyzing the model to generate test cases. During its analysis, the software displays a log window.

The log window shows you the progress of the Simulink Design Verifier analysis.

If you need to terminate an analysis while it is running, click Stop. The software asks if you want to produce results. If you click Yes, the software creates a data file based on the results achieved so far. The path name of the data file appears in the log window.

The data file is a MAT-file that contains a structure named sldvData. This structure stores all the data that the software gathers and produces during the analysis.

For more information, see Simulink Design Verifier Data Files.

Generating Analysis Results

When the Simulink Design Verifier software completes its analysis of the sldvdemo_cruise_control model, the log window displays several options:

The sections that follow describe these options in detail.

Highlighting Analysis Results on Model

In the Simulink Design Verifier log window, if you click Highlight analysis results on model, the software highlights objects in the model in three different colors, depending on the analysis results:

When you highlight the analysis results on a model, the Simulink Design Verifier Results window opens. When you click an object in the model that has analysis results, that window displays the results summary for that object.

Green: Objectives Satisfied.  Green outline indicates that the analysis generated test cases for all the objectives for that block. If the block is a subsystem or Stateflow atomic subchart, the green outline indicates that the analysis generated test cases for all objectives associated with the child objects.

For example, in the sldvdemo_cruise_control model, the green outline shows that the PI controller subsystem satisfied all test objectives. The Informer lists the two satisfied test objectives for the PI controller subsystem.

Orange: Objectives Undecided.  Orange outline indicates that the analysis was not able to determine if an objective was satisfiable or not. This situation might occur when:

In the following example, the analysis timed out before it could determine if one of the objectives for the Discrete-Time Integrator block was satisfiable.

Red: Objectives Unsatisfiable.  Red outline indicates that the analysis found some objectives for which it could not generate test cases, most likely due to unreachable design elements in your model.

In the following example, the input 2 always satisfies the criterion for the Switch block, so the Switch block never passes through the value of input 3.

Generating a Detailed Analysis Report

In the Simulink Design Verifier log window, if you click Generate detailed analysis report, the software saves and then opens a detailed report of the analysis. The path to the report is:

<current_folder>/sldv_output/...
     sldvdemo_cruise_control/sldvdemo_cruise_control_report.html

The HTML report includes the following chapters.

For a description of each report chapter, see:

Summary.  In the Table of Contents, click Summary to display the Summary chapter, which includes the following information:

Analysis Information.  In the Table of Contents, click Analysis Information to display information about the analyzed model and the analysis options.

Test Objectives Status.  In the Table of Contents, click Test Objectives Status to display a table of satisfied objectives. The following figure shows a partial list of the objectives satisfied in the Cruise Control Test Generation model.

The Objectives Satisfied table lists the following information for the model:

In the row for objective 30, click the test case number (8) to display more information about test case 8 in the report's Test Cases chapter.

In this example, Test Case 8 satisfies one objective, that the integration result be greater than or equal to the upper limit T in the Discrete-Time Integrator block. The table lists the values of the six signals from time 0 through time 0.06.

Model Items.  In the Table of Contents, click Model Items to see detailed information about each item in the model that defines coverage objectives. This table includes the status of the objective at the end of the analysis. Click the links in the table for detailed information about the satisfied objectives.

Test Cases.  In the Table of Contents, click Test Cases to display detailed information about each generated test case, including:

For an example, see the section for Test Case 8 in Test Objectives Status.

Creating a Harness Model

In the Simulink Design Verifier log window, if you click Create harness model, the software creates and opens a harness model named sldvdemo_cruise_control_harness.

The harness model contains the following blocks:

The Signal Builder dialog box contains nine test cases. To look at Test Case 8:

  1. Click the right-facing arrow next to the test case tabs to find the Test Case 8 tab.

  2. Click the Test Case 8 tab to display the signal values for Test Case 8.

    In Test Case 8 at 0.01 seconds:

    • The enable and inc signals remain 1.

    • The brake and dec signals remain 0.

    • The set signal transitions from 1 to 0.

    • The speed signal transitions from 100 to 0.

    In the Signal Builder block, the signal group satisfies the test objectives described in the Test Case Explanation block.

  3. To confirm that the Simulink Design Verifier software achieved complete model coverage, simulate the harness model using all the test cases. In the Signal Builder dialog box, click the Run all and produce coverage button .

    The Simulink software simulates all the test cases. The Simulink Verification and Validation software collects coverage data for the harness model and displays a coverage report. The report summary shows that the sldvdemo_cruise_control_harness model achieves 100% coverage.

Simulating Tests and Producing a Model Coverage Report

In the Simulink Design Verifier log window, if you click Simulate tests and produce a model coverage report, the software simulates the model and produces a coverage report for the sldvdemo_cruise_control model. The software stores the report with the following name:

<current_MATLAB_folder/sldv_output/sldvdemo_cruise_control/sldvdemo_cruise_control_report.html

When you click Run all and produce coverage to simulate tests in the harness model, you may see the following differences between this coverage report and the report you generated for the model itself:

Combining Test Cases

If you prefer to review results that are combined into a smaller number of test cases, set the Test suite optimization parameter to LongTestcases. When you use the LongTestcases optimization, the analysis generates fewer, but longer, test cases that each satisfy multiple test objectives. This optimization creates a more efficient analysis and easier-to-review results.

Open the sldvdemo_cruise_control model and rerun the analysis with the Long test cases optimization:

  1. Select Tools > Design Verifier > Options.

  2. In the Configuration Parameters dialog box, in the Select tree on the left side, under the Design Verifier category, select Test Generation.

  3. Set the Test suite optimization parameter to LongTestcases.

  4. Click Apply and OK to close the Configuration Parameters dialog box.

  5. In the sldvdemo_cruise_control model, double-click the block labeled Run.

  6. In the log window, click Create harness model.

    In the harness model, the Signal Builder dialog box now contains two longer test cases instead of the nine shorter test cases created in Analyzing a Model.

  7. Click Run all and produce coverage to collect coverage.

    The analysis still satisfies all 34 objectives.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS