Why does Simulink Design Verifier only find dead logic when I swap the order of my logical operands?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 7 Avr 2020
Modifié(e) : MathWorks Support Team
le 13 Oct 2022
I have the following Stateflow charts:
Chart 1:
Chart 2:
The only difference in these two charts, is that the order of the operands at the second transition are swapped. Simulink Design Verifier finds dead logic in Chart 2, but not in Chart 1.
Réponse acceptée
MathWorks Support Team
le 13 Oct 2022
Modifié(e) : MathWorks Support Team
le 13 Oct 2022
The reason you are seeing this behaviour is due to logical short-circuiting. See the following documentation page on logical short-circuiting for more details:
There are only two ways by which we can reach the second transition: if
Input1 != SomeNumber
, or if Inputs 2, 3 and 4 are
all false
.
Case 1: Input1 == SomeNumber
In the case that Input1 == SomeNumber, then Inputs 2, 3 and 4 must all be false. In this case, the second transition has to be true. In this specific case, the logic could be considered 'dead' in both charts.
Case 2: Input1 != SomeNumber
This is the case that sets the two charts apart. In this case, Inputs 2, 3 and 4 can be any combination of true and false.
In Chart 1, we first check whether Inputs 2, 3 and 4 are true, and since they can be in any combination of true and false, it is possible for us to reach of all the logic in this transition. For this reason, the logic is not considered 'dead'.
In Chart 2, however, logical short-circuiting kicks in because we check whether
Input1 == SomeNumber
, which is false. We therefore will never reach the logic that follows and the logic is considered 'dead'.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!