99#include " normalize_property.h"
1010
1111#include < util/arith_tools.h>
12+ #include < util/mathematical_types.h>
1213#include < util/std_expr.h>
1314
1415#include < verilog/sva_expr.h>
@@ -75,9 +76,8 @@ exprt normalize_pre_implies(implies_exprt expr)
7576exprt normalize_pre_sva_overlapped_implication (
7677 sva_overlapped_implication_exprt expr)
7778{
78- // Same as regular implication if lhs and rhs are not
79- // sequences.
80- if (!is_SVA_sequence (expr.lhs ()) && !is_SVA_sequence (expr.rhs ()))
79+ // Same as regular implication if the lhs is not a sequence.
80+ if (!is_SVA_sequence (expr.lhs ()))
8181 return or_exprt{not_exprt{expr.lhs ()}, expr.rhs ()};
8282 else
8383 return std::move (expr);
@@ -86,9 +86,13 @@ exprt normalize_pre_sva_overlapped_implication(
8686exprt normalize_pre_sva_non_overlapped_implication (
8787 sva_non_overlapped_implication_exprt expr)
8888{
89- // Same as a->Xb if lhs and rhs are not sequences.
90- if (!is_SVA_sequence (expr.lhs ()) && !is_SVA_sequence (expr.rhs ()))
91- return or_exprt{not_exprt{expr.lhs ()}, X_exprt{expr.rhs ()}};
89+ // Same as a->always[1:1] b if lhs is not a sequence.
90+ if (!is_SVA_sequence (expr.lhs ()))
91+ {
92+ auto one = from_integer (1 , natural_typet{});
93+ return or_exprt{
94+ not_exprt{expr.lhs ()}, sva_ranged_always_exprt{one, one, expr.rhs ()}};
95+ }
9296 else
9397 return std::move (expr);
9498}
@@ -125,13 +129,14 @@ exprt normalize_pre_sva_cycle_delay(sva_cycle_delay_exprt expr)
125129 expr.from ().is_constant () &&
126130 numeric_cast_v<mp_integer>(to_constant_expr (expr.from ())) == 0 )
127131 {
128- // ##[0:$] φ --> F φ
129- return F_exprt {expr.op ()};
132+ // ##[0:$] φ --> s_eventually φ
133+ return sva_s_eventually_exprt {expr.op ()};
130134 }
131135 else
132136 {
133- // ##[i:$] φ --> ##i F φ
134- return sva_cycle_delay_exprt{expr.from (), F_exprt{expr.op ()}};
137+ // ##[i:$] φ --> always[i:i] s_eventually φ
138+ return sva_ranged_always_exprt{
139+ expr.from (), expr.from (), sva_s_eventually_exprt{expr.op ()}};
135140 }
136141 }
137142 else
@@ -171,11 +176,13 @@ exprt normalize_property(exprt expr)
171176 expr = normalize_pre_sva_or (to_sva_or_expr (expr));
172177 else if (expr.id () == ID_sva_nexttime)
173178 {
174- expr = X_exprt{to_sva_nexttime_expr (expr).op ()};
179+ auto one = from_integer (1 , natural_typet{});
180+ expr = sva_ranged_always_exprt{one, one, to_sva_nexttime_expr (expr).op ()};
175181 }
176182 else if (expr.id () == ID_sva_s_nexttime)
177183 {
178- expr = X_exprt{to_sva_s_nexttime_expr (expr).op ()};
184+ auto one = from_integer (1 , natural_typet{});
185+ expr = sva_s_always_exprt{one, one, to_sva_s_nexttime_expr (expr).op ()};
179186 }
180187 else if (expr.id () == ID_sva_indexed_nexttime)
181188 {
@@ -190,11 +197,18 @@ exprt normalize_property(exprt expr)
190197 nexttime_expr.index (), nexttime_expr.index (), nexttime_expr.op ()};
191198 }
192199 else if (expr.id () == ID_sva_cycle_delay)
200+ {
193201 expr = normalize_pre_sva_cycle_delay (to_sva_cycle_delay_expr (expr));
202+ }
194203 else if (expr.id () == ID_sva_cycle_delay_plus)
195- expr = F_exprt{X_exprt{to_sva_cycle_delay_plus_expr (expr).op ()}};
204+ {
205+ expr = sva_s_eventually_exprt{
206+ sva_s_nexttime_exprt{to_sva_cycle_delay_plus_expr (expr).op ()}};
207+ }
196208 else if (expr.id () == ID_sva_cycle_delay_star)
197- expr = F_exprt{to_sva_cycle_delay_star_expr (expr).op ()};
209+ {
210+ expr = sva_s_eventually_exprt{to_sva_cycle_delay_star_expr (expr).op ()};
211+ }
198212 else if (expr.id () == ID_sva_if)
199213 {
200214 auto &sva_if_expr = to_sva_if_expr (expr);
0 commit comments