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