@@ -307,44 +307,54 @@ sequence_matchest instantiate_sequence(
307
307
308
308
return result;
309
309
}
310
- else if (expr.id () == ID_sva_sequence_consecutive_repetition )
310
+ else if (expr.id () == ID_sva_sequence_repetition_star )
311
311
{
312
- // x[*n] is syntactic sugar for x ##1 ... ##1 x, with n repetitions
313
- auto &repetition = to_sva_sequence_consecutive_repetition_expr (expr);
314
- return instantiate_sequence (
315
- repetition.lower (), semantics, t, no_timeframes);
316
- }
317
- else if (
318
- expr.id () == ID_sva_sequence_repetition_plus ||
319
- expr.id () == ID_sva_sequence_repetition_star)
320
- {
321
- // x[+] and x[*]
322
- auto &op = to_unary_expr (expr).op ();
312
+ auto &repetition = to_sva_sequence_repetition_star_expr (expr);
313
+ if (repetition.is_unbounded () && repetition.repetitions_given ())
314
+ {
315
+ // [*x:$]
316
+ auto from = numeric_cast_v<mp_integer>(repetition.from ());
317
+ auto &op = repetition.op ();
323
318
324
- // Is x a sequence or a state predicate?
325
- if (is_SVA_sequence_operator (op))
326
- PRECONDITION (false ); // no support
319
+ // Is op a sequence or a state predicate?
320
+ if (is_SVA_sequence_operator (op))
321
+ PRECONDITION (false ); // no support
327
322
328
- sequence_matchest result;
323
+ sequence_matchest result;
329
324
330
- // we incrementally add conjuncts to the condition
331
- exprt::operandst conjuncts;
325
+ // we incrementally add conjuncts to the condition
326
+ exprt::operandst conjuncts;
332
327
333
- for (mp_integer u = t; u < no_timeframes; ++u)
334
- {
335
- // does x hold in state u?
336
- auto cond_u = instantiate (op, u, no_timeframes);
337
- conjuncts.push_back (cond_u);
338
- result.push_back ({u, conjunction (conjuncts)});
339
- }
328
+ for (mp_integer u = t; u < no_timeframes; ++u)
329
+ {
330
+ // does op hold in timeframe u?
331
+ auto cond_u = instantiate (op, u, no_timeframes);
332
+ conjuncts.push_back (cond_u);
340
333
341
- // In addition to the above, x[*] allows an empty match.
342
- if (expr. id () == ID_sva_sequence_repetition_star)
343
- result. push_back ({t, true_exprt{}});
334
+ if (conjuncts. size () >= from)
335
+ result. push_back ({u, conjunction (conjuncts)});
336
+ }
344
337
345
- return result;
338
+ // Empty match allowed?
339
+ if (from == 0 )
340
+ result.push_back ({t, true_exprt{}});
341
+
342
+ return result;
343
+ }
344
+ else
345
+ {
346
+ // [*], [*n], [*x:y]
347
+ return instantiate_sequence (
348
+ repetition.lower (), semantics, t, no_timeframes);
349
+ }
350
+ }
351
+ else if (expr.id () == ID_sva_sequence_repetition_plus) // [+]
352
+ {
353
+ auto &repetition = to_sva_sequence_repetition_plus_expr (expr);
354
+ return instantiate_sequence (
355
+ repetition.lower (), semantics, t, no_timeframes);
346
356
}
347
- else if (expr.id () == ID_sva_sequence_goto_repetition)
357
+ else if (expr.id () == ID_sva_sequence_goto_repetition) // [->...]
348
358
{
349
359
// The 'op' is a Boolean condition, not a sequence.
350
360
auto &op = to_sva_sequence_goto_repetition_expr (expr).op ();
0 commit comments