@@ -38,24 +38,39 @@ exprt trivial_sva(exprt expr)
38
38
auto rhs = is_state_predicate (sva_implication.rhs ());
39
39
40
40
if (lhs.has_value () && rhs.has_value ())
41
- expr = implies_exprt{*lhs, *rhs};
41
+ expr = sva_boolean_exprt{
42
+ implies_exprt{*lhs, *rhs}, expr.type ()};
42
43
}
43
44
else if (expr.id () == ID_sva_iff)
44
45
{
46
+ // same as boolean iff when both lhs/rhs are state predicates
45
47
auto &sva_iff = to_sva_iff_expr (expr);
46
- expr = equal_exprt{sva_iff.lhs (), sva_iff.rhs ()};
48
+
49
+ auto lhs = is_state_predicate (sva_iff.lhs ());
50
+ auto rhs = is_state_predicate (sva_iff.rhs ());
51
+
52
+ if (lhs.has_value () && rhs.has_value ())
53
+ expr = sva_boolean_exprt{
54
+ equal_exprt{*lhs, *rhs}, expr.type ()};
47
55
}
48
56
else if (expr.id () == ID_sva_implies)
49
57
{
58
+ // same as boolean implication when both lhs/rhs are state predicates
50
59
auto &sva_implies = to_sva_implies_expr (expr);
51
- expr = implies_exprt{sva_implies.lhs (), sva_implies.rhs ()};
60
+
61
+ auto lhs = is_state_predicate (sva_implies.lhs ());
62
+ auto rhs = is_state_predicate (sva_implies.rhs ());
63
+
64
+ if (lhs.has_value () && rhs.has_value ())
65
+ expr = sva_boolean_exprt{
66
+ implies_exprt{*lhs, *rhs}, expr.type ()};
52
67
}
53
68
else if (expr.id () == ID_sva_and)
54
69
{
55
70
auto &sva_and = to_sva_and_expr (expr);
56
71
57
72
// can be sequence or property
58
- if (expr.type ().id () == ID_verilog_sva_sequence)
73
+ if (expr.type ().id () == ID_verilog_sva_sequence || expr. type (). id () == ID_verilog_sva_property )
59
74
{
60
75
// Same as a ∧ b if the expression is not a sequence.
61
76
auto lhs = is_state_predicate (sva_and.lhs ());
@@ -64,37 +79,34 @@ exprt trivial_sva(exprt expr)
64
79
if (lhs.has_value () && rhs.has_value ())
65
80
expr = sva_boolean_exprt{and_exprt{*lhs, *rhs}, expr.type ()};
66
81
}
67
- else
68
- {
69
- expr = and_exprt{sva_and.lhs (), sva_and.rhs ()};
70
- }
71
82
}
72
83
else if (expr.id () == ID_sva_or)
73
84
{
74
85
auto &sva_or = to_sva_or_expr (expr);
75
86
76
87
// can be sequence or property
77
- if (expr.type ().id () == ID_verilog_sva_sequence)
88
+ if (expr.type ().id () == ID_verilog_sva_sequence || expr. type (). id () == ID_verilog_sva_property )
78
89
{
79
- // Same as a ∨ b if the expression is not a sequence .
90
+ // Same as a ∨ b if the expression is a state predicate .
80
91
auto lhs = is_state_predicate (sva_or.lhs ());
81
92
auto rhs = is_state_predicate (sva_or.rhs ());
82
93
83
94
if (lhs.has_value () && rhs.has_value ())
84
95
expr = sva_boolean_exprt{or_exprt{*lhs, *rhs}, expr.type ()};
85
96
}
86
- else
87
- {
88
- expr = or_exprt{sva_or.lhs (), sva_or.rhs ()};
89
- }
90
97
}
91
98
else if (expr.id () == ID_sva_not)
92
99
{
93
- // Same as regular 'not'. These do not apply to sequences.
94
- expr = not_exprt{to_sva_not_expr (expr).op ()};
100
+ // Same as boolean 'not' when applied to a state predicate.
101
+ auto &op = to_sva_not_expr (expr).op ();
102
+ auto predicate = is_state_predicate (op);
103
+ if (predicate.has_value ())
104
+ expr =
105
+ sva_boolean_exprt{not_exprt{*predicate}, verilog_sva_property_typet{}};
95
106
}
96
107
else if (expr.id () == ID_sva_if)
97
108
{
109
+ // same as boolean 'if' when both cases are state predicates.
98
110
auto &sva_if_expr = to_sva_if_expr (expr);
99
111
auto false_case = sva_if_expr.false_case ().is_nil ()
100
112
? true_exprt{}
0 commit comments