Main Content

Simulink Optimizations and Model Coverage

In the Configuration Parameters dialog box, there are three Simulink® optimization parameters that can affect your model coverage data:

Inlined Parameters

To transform tunable model parameters into constant values for code generation, in the Configuration Parameters dialog box, on the Math and Data Types pane, set Default parameter behavior to Inlined.

When the parameters are transformed into constants, Simulink may eliminate certain decisions in your model. You cannot achieve coverage for eliminated decision, so the coverage report displays 0/0 for those decisions.

Block Reduction

To achieve faster execution during model simulation and in generated code, in the Configuration Parameters dialog box, select the Block reduction parameter. The Simulink software collapses certain groups of blocks into a single, more efficient block, or removes them entirely.

One of the model coverage options, Force block reduction off, allows you to ignore the Block reduction parameter when collecting model coverage.

If you do not select the Block reduction parameter, or if you select Force block reduction off, the Simulink Coverage™ software provides coverage data for every block in the model that collects coverage.

If you select the Block reduction parameter and do not set Force block reduction off, the coverage report lists the reduced blocks that would have collected coverage.

Conditional Input Branch Execution

The Conditional input branch execution parameter can cause lower than expected Simulink Coverage results.

Case 1: Upstream Switch Block Completely Optimized Out

A Constant block set to false connected to the control input on C_Switch2 causes the true case of C_Switch2 to not occur. Conditional input branch execution optimizes C_Switch1 out as a result. Simulink Coverage reports 0% coverage on C_Switch1.

Because the C_Switch1 block is dead logic, the coverage report generates a Blocks Eliminated from Coverage Analysis section.

Case 2: Upstream Switch Block Partially Optimized Out

A Step block converted to the boolean data type outputs false and true before and after the Step time, respectively.

Disabling Conditional input branch execution provides full coverage. Enabling Conditional input branch execution provides partial coverage on A_Switch1 because A_Switch1 does not see a false case at the same time that A_Switch2 sees a true case. In other words, either both Switch blocks are true, or both are false. The false case of A_Switch1 does not affect the model. The coverage report correctly reports 50% coverage on A_Swtch1.

Address Incomplete Coverage

You can address incomplete coverage in models where the Conditional input branch execution parameter is selected by:

  • Revising the model design. Incomplete coverage due to Conditional input branch execution could indicate a model design flaw.

  • Justifying the missing coverage if the inaccessible logic in the model is intentional.

  • Providing a more robust test case that can access all of the switch decisions.

  • Clearing Conditional input branch execution. This eliminates the issue of incomplete Switch coverage, but does not address the inaccessible logic.

For usage details, see Conditional input branch execution.

Limitations

Conditional input branch execution does not apply to Stateflow® charts.