This is not a bug. The model coverage tool interprets structural coverage for a model based design. As the name implies, structural information about the design is used to determine when each coverage metric is satisfied.
The fundamental definition of MCDC, as defined in DO-178B is that each condition that makes up a decision will independently change the outcome of the decision while the other conditions are held constant. In Stateflow each conditional transition is treated as a separate decision.
In your case, you are looking at the equivalent of the following two code fragments:
if (in1 == 1 && in2 == 1) {
do_something();
} else if (in1 == 0 && in2 == 0) {
do_something();
}
and its functional equivalent with a different structure:
if ((in1 == 1 && in2 == 1) || (in1 == 0 && in2 == 0)) {
do_something();
}
Given the same inputs to the code fragments above you should see the same MCDC coverage results from a code coverage tool.
However, the coverage tool considers each condition in a transition to be independent so it will not be able to recognize that setting in1==1 to True will make it impossible to set in1==0 to True. The tool simply interprets the expression above to be in the form:
if ( (A && B) || (C && D))
While the relationship between conditions is straightforward in this example in the general case of arbitrary expression and side-effect functions it is very difficult to determine the inter-relationships of conditions.
This could be interpreted as a short coming of the metric itself, but depending on the application, it may also be a feature. Thus, the results that you are receiving are to be expected.
If you wish for a slightly different interpretation of the coverage that would only require each condition to be tested as true and false, then you can obtain this by only enabling decision and condition coverage from the coverage settings dialog.
Best Answer