Documentation Center

  • Trial Software
  • Product Updates

Model Coverage for Multiple Instances of a Referenced Model

About Coverage for Model Blocks

Model blocks do not receive coverage directly; if you set the simulation mode of the Model block to Normal, the Simulink® Verification and Validation™ software records coverage for the model referenced from the Model block. If the simulation mode for the Model block is anything other than Normal, the software does not record coverage for the referenced model.

Your Simulink model can contain multiple Model blocks with Normal simulation mode that reference the same model. When the software records coverage, each instance of the referenced model can be exercised with different inputs or parameters, possibly resulting in additional coverage for the referenced model.

The Simulink Verification and Validation software records coverage for all instances of the referenced model with Normal simulation mode and combines the coverage data for that referenced model in the final results.

Record Coverage for Multiple Instances of a Referenced Model

To see how this works, simulate a model twice. The first time, you record coverage for one Model block in Normal simulation mode. The second time, you record coverage for two Model blocks in Normal simulation mode. Both Model blocks reference the same model.

Record Coverage for the First Instance of the Referenced Model

Record coverage for one Model block.

  1. Open your top-level model. This example uses the following model:

    This model contains three Model blocks that reference the sldemo_mdlref_counter_datamngt example model. The corners of each Model block indicate the value of their Simulation mode parameter:

    • Counter1 — Simulation mode: Normal

    • Counter2 — Simulation mode: Accelerator

    • Counter3 — Simulation mode: Accelerator

  2. Configure your model to record coverage during simulation:

    1. In the model window, select Analysis > Coverage > Settings.

    2. On the Coverage tab, select:

      • Coverage for this model

      • Coverage for referenced models

    3. Under Coverage for referenced models, click Select Models. In the Select Models for Coverage Analysis dialog box, you can select only those referenced models whose simulation mode is Normal. In this example, only the first Model block that references sldemo_mdlref_counter_datamngt is available for recording coverage.

    4. Click OK to exit the Select Models for Coverage Analysis dialog box.

    5. In the Coverage Settings dialog box, on the Reporting tab, select Last Run so that you can compare coverage data from individual simulations, not accumulated coverage for successive simulations.

  3. Click OK to save your coverage settings and exit the Coverage Settings dialog box.

  4. Simulate your model.

    When the simulation is complete, the HTML coverage report opens. In this example, the coverage data for the referenced model, sldemo_mdlref_counter_datamngt, shows that the model achieved 69% coverage.

  5. Click the hyperlink in the report for the referenced model.

    The detailed coverage report for the referenced model opens, and the referenced model appears with highlighting to show coverage results.

    Note the following about the coverage for the Range Check subsystem in this example:

    • The Saturate Count block executed 100 times. This block has four Boolean decisions. Decision coverage was 50%, because two of the four decisions were never recorded:

      • The decision input > lower limit was never false.

      • The decision input >= upper limit was never true.

    • The DetectOverflow function executed 50 times. This script has five decisions. The DetectOverflow script achieved 60% coverage because two of the five decisions were never recorded:

      • The expression count >= CounterParams.UpperLimit was never true.

      • The expression count > CounterParams.LowerLimit was never false.

Record Coverage for the Second Instance of the Referenced Model

Record coverage for two Model blocks. Set the simulation mode of a second Model block to Normal and simulate the model. In this example, the Counter2 block adds to the coverage for the model referenced from both Model blocks.

  1. In the Simulink Editor for your top-level model, right-click a second Model block and select Block Parameters (ModelReference).

    The Function Block Parameters dialog box opens.

  2. Set the Simulation mode parameter to Normal.

  3. Click OK to save your change and exit the Function Block Parameters dialog box.

    The corners of the Model block change to indicate that the simulation mode for this block is Normal, as in the example below.

  4. To make sure that the software records coverage for both instances of this model:

    1. Select Analysis > Coverage > Settings.

    2. On the Coverage pane, under Coverage for referenced models, click Select Models.

      In the Select Models for Coverage Analysis dialog box, verify that both instances of the referenced model are selected. In this example, the list now looks like the following.

      If you have multiple instances of a referenced model in Normal mode, you can choose to record coverage for all of them or none of them.

    3. Click OK to close the Select Models for Coverage Analysis dialog box.

  5. Simulate your model again.

  6. When the simulation is complete, open the HTML coverage report.

    In this example, the referenced model achieved 85% coverage. Note the following about the coverage data for the Range Check subsystem:

    • The Saturate Count block executed 179 times. The simulation of the Counter2 block executed the Saturate Count block an additional 79 times, for a total of 179 executions.

      The decision input >= upper limit was true 21 times during this simulation, compared to 0 during the first simulation. The fourth decision input > lower limit was still never false. Three out of four decisions were recorded during simulation, so this block achieved 75% coverage.

    • The DetectOverflow function executed 100 times. The simulation of the Counter2 block executed the DetectOverflow function an additional 50 times.

      The DetectOverflow function has five decisions. The expression count >= CounterParams.UpperLimit was true 21 times during this simulation, compared to 0 during the first simulation. The expression count > CounterParams.LowerLimit was never false. Four out of five decisions were recorded during simulation, so the DetectOverflow function achieved 80% coverage.

Was this topic helpful?