Main Content

Debugging Equivalence Test Failures Using Model Slicer

This example shows how to debug Simulink Test equivalence failures by highlighting functional dependencies using Model Slicer. For more information, see Highlight Functional Dependencies (Simulink Check). The example files include a predefined equivalence test to use with the sldemo_fuelsys_dd_controller model. The sample test case compares the model simulation in normal and software-in-the-loop (SIL) mode. The model includes a numerical discrepancy. In this example, you use Model Slicer to trace the faults and identify the discrepancy. For more information about debugging test failures, see the Capabilities and Limitations section of Debugging Test Failures Using Model Slicer.

Setting Up the Artifacts

Run the test case and view the results.

1. Open the sldemo_fuelsys_dd_controller model:


2. Log the output by the signals coming out of airflow_calc and fuel_calc subsystems and the Stateflow chart control_logic to generate a visualization after the analysis. To log signals, click the signal and, in the action bar, click Log Selected Signal.

3. In the Apps tab, in the Model Verification, Validation, and Test section, click Simulink Test to open the Simulink Test toolstrip.

4. In the Tests tab, click Simulink Test Manager to open the Test Manager.

5. To open the test file, click Open and select slTestEquivalenceFailureEx from the example folder.

6. After the test file loads, select New Test Case 1 in the Test Browser pane.

7. Click Run.

8. The new test results appear in the Results and Artifacts pane. Right-click the result and select Expand All Under to see the Equivalence Criteria Result and Verify Statements 1 section.

Observe that only one signal failed: airflow_calc. Consider changing the Device details from 32 bits to 64 bits from Hardware and Implementation pane after clicking on Model Settings from Simulation tab, if you are not able to see the failure.

Entering Debug Session

Set up the Model Slicer to debug the failed airflow_calc signal.

1. To compare the airflow_calc signal in different simulation modes, select the radio button next to the airflow_calc signal. Another way to select a failed signal is from the Signal to Debug dropdown list in the toolbar.

In the plot area, compare the outputs across simulations.

2. In the Tools section, click Debug. Note that you must plot a failed equivalence or verify signal to enable the Debug button.

The Debug tab opens and hides. The debug tab hides multiple Test Manager options.

3. To set up the Model Slicer, click Debug Using Slicer.

Model Slicer prepares the debugging session by:

  1. Rerunning the test case and creating new debugging results. This action ensures that the failure still exists in the current state of the test model.

  2. Launching the Model Slicer on the test model.

  3. Automatically plotting the selected failed signal in the debugging results and setting the failed signal as the starting time point.

  4. Pausing the simulation at the model start time to continue debugging.

Debugging Using Model Slicer

Identify the reason for the failure by using the debugging features of the Model Slicer.

1. Use the Step Back or Step Forward buttons to move one step back or forward in simulation time. The left data cursor moves to the current simulation time. Observe the changes in the data dependencies by noting the changed model highlighting and port value labels for the active signals at every time stamp.

You can also use Run, Continue, or Stop buttons to run, complete, or stop the current simulation, respectively.

2. In the Test Manager, click Continue to Failure to continue the model simulation to the beginning of the next failure region. The data cursors show the bounds of the failure region.

3. Observe these changes at the failure:

  • Simulation pauses at T = 4.81.

  • The data cursors update accordingly.

From the Model Slicer highlighting, you can observe the branch of the model that causes the error.

Notice that the constant, 0 passes through the sldemo_fuelsys_dd_controller/airflow_calc/hold integrator Switch block. To determine why the control port evaluates to false, highlight the control dependencies in the model.

4. Enable Display Control Dependencies from the Simulation Time Window section in the Model Slicer Dialog pane. Observe the chain of blocks that the Model Slicer highlights as the probable cause of the discrepancy. To further visualize the numerical differences between the simulation modes, end the debugging session, log the signals in the active chain, and debug the model again.

Refining the Debugging Results

1. Exit the debugging session by clicking Session > Close Debug.

2. Open the model and log all signals in the observed path before.

3. Save the model.

4. Repeat steps 1 to 3 from the Debug Using Model Slicer section.

Observe that the Enumerated Constant value is being set in the MATLAB function block based on the simulation mode.

Incorporating the Fix

1. Exit the debugging session by clicking SESSION > Close Debug.

2. Open the model and update sldemo_fuelsys_dd_controller/airflow_calc/MATLAB function to return the same value irrespective of the simulation mode.

3. Save the model.

4. Run the test case and view the results.

Observe that the test results test results pass.

See Also