|
13 | 13 |
|
14 | 14 | #include <verilog/sva_expr.h>
|
15 | 15 |
|
| 16 | +#include "temporal_logic.h" |
| 17 | + |
16 | 18 | sva_sequence_matcht sva_sequence_matcht::true_match(const mp_integer &n)
|
17 | 19 | {
|
18 | 20 | sva_sequence_matcht result;
|
@@ -214,3 +216,57 @@ std::vector<sva_sequence_matcht> LTL_sequence_matches(const exprt &sequence)
|
214 | 216 | throw sva_sequence_match_unsupportedt{sequence}; // not supported
|
215 | 217 | }
|
216 | 218 | }
|
| 219 | + |
| 220 | +bool admits_empty(const exprt &expr) |
| 221 | +{ |
| 222 | + PRECONDITION(expr.type().id() == ID_verilog_sva_sequence); |
| 223 | + PRECONDITION(is_SVA_sequence_operator(expr)); |
| 224 | + |
| 225 | + if(expr.id() == ID_sva_boolean) |
| 226 | + return false; // admits_empty(b) = 0 |
| 227 | + else if(expr.id() == ID_sva_cycle_delay) |
| 228 | + { |
| 229 | + auto &cycle_delay = to_sva_cycle_delay_expr(expr); |
| 230 | + if(cycle_delay.from().is_zero() && !cycle_delay.is_range()) |
| 231 | + { |
| 232 | + // admits_empty((r1 ##0 r2)) = 0 |
| 233 | + return false; |
| 234 | + } |
| 235 | + else |
| 236 | + { |
| 237 | + // admits_empty((r1 ##1 r2)) = admits_empty(r1) && admits_empty(r2) |
| 238 | + return cycle_delay.lhs().is_not_nil() && |
| 239 | + admits_empty(cycle_delay.lhs()) && admits_empty(cycle_delay.rhs()); |
| 240 | + } |
| 241 | + } |
| 242 | + else if(expr.id() == ID_sva_or) |
| 243 | + { |
| 244 | + // admits_empty((r1 or r2)) = admits_empty(r1) || admits_empty(r2) |
| 245 | + auto &or_expr = to_sva_or_expr(expr); |
| 246 | + return admits_empty(or_expr.lhs()) || admits_empty(or_expr.rhs()); |
| 247 | + } |
| 248 | + else if(expr.id() == ID_sva_sequence_intersect) |
| 249 | + { |
| 250 | + // admits_empty((r1 intersect r2)) = admits_empty(r1) && admits_empty(r2) |
| 251 | + auto &intersect_expr = to_sva_sequence_intersect_expr(expr); |
| 252 | + return admits_empty(intersect_expr.lhs()) && |
| 253 | + admits_empty(intersect_expr.rhs()); |
| 254 | + } |
| 255 | + else if(expr.id() == ID_sva_sequence_first_match) |
| 256 | + { |
| 257 | + // admits_empty(first_match(r)) = admits_empty(r) |
| 258 | + auto &first_match_expr = to_sva_sequence_first_match_expr(expr); |
| 259 | + return admits_empty(first_match_expr.lhs()) && |
| 260 | + admits_empty(first_match_expr.rhs()); |
| 261 | + } |
| 262 | + else if(expr.id() == ID_sva_sequence_repetition_star) |
| 263 | + { |
| 264 | + // admits_empty(r[*0]) = 1 |
| 265 | + // admits_empty(r[*1:$]) = admits_empty(r) |
| 266 | + auto &repetition_expr = to_sva_sequence_repetition_star_expr(expr); |
| 267 | + } |
| 268 | + else |
| 269 | + { |
| 270 | + DATA_INVARIANT(false, "unexpected SVA sequence: " + expr.id_string()); |
| 271 | + } |
| 272 | +} |
0 commit comments