@@ -1325,10 +1325,22 @@ inline sva_case_exprt &to_sva_case_expr(exprt &expr)
13251325}
13261326
13271327// / Base class for [->...], [*...], [=...]
1328- // / The ... constraint may be x, x:y, x:$
1328+ // / The ... constraint may be blank, x, x:y, x:$
13291329class sva_sequence_repetition_exprt : public ternary_exprt
13301330{
13311331public:
1332+ // / number of repetitions not given, e.g., [*] or [+]
1333+ sva_sequence_repetition_exprt (exprt __op, irep_idt __id)
1334+ : ternary_exprt{
1335+ __id,
1336+ std::move (__op),
1337+ nil_exprt{},
1338+ nil_exprt{},
1339+ verilog_sva_sequence_typet{}}
1340+ {
1341+ }
1342+
1343+ // / fixed number of repetitions
13321344 sva_sequence_repetition_exprt (
13331345 exprt __op,
13341346 irep_idt __id,
@@ -1342,6 +1354,7 @@ class sva_sequence_repetition_exprt : public ternary_exprt
13421354 {
13431355 }
13441356
1357+ // / bounded range for the number of repetitions
13451358 sva_sequence_repetition_exprt (
13461359 exprt __op,
13471360 irep_idt __id,
@@ -1356,6 +1369,21 @@ class sva_sequence_repetition_exprt : public ternary_exprt
13561369 {
13571370 }
13581371
1372+ // / unbounded range for the number of repetitions
1373+ sva_sequence_repetition_exprt (
1374+ exprt __op,
1375+ irep_idt __id,
1376+ constant_exprt __from,
1377+ infinity_exprt __to)
1378+ : ternary_exprt{
1379+ __id,
1380+ std::move (__op),
1381+ std::move (__from),
1382+ std::move (__to),
1383+ verilog_sva_sequence_typet{}}
1384+ {
1385+ }
1386+
13591387 // May be a sequence for [*...], Boolean otherwise
13601388 const exprt &op () const
13611389 {
@@ -1367,16 +1395,22 @@ class sva_sequence_repetition_exprt : public ternary_exprt
13671395 return op0 ();
13681396 }
13691397
1398+ // / true if number of repetitions is given
1399+ bool repetitions_given () const
1400+ {
1401+ return op1 ().is_not_nil ();
1402+ }
1403+
13701404 // The number of repetitions must be a constant after elaboration.
13711405 const constant_exprt &repetitions () const
13721406 {
1373- PRECONDITION (!is_range ());
1407+ PRECONDITION (repetitions_given () && !is_range ());
13741408 return static_cast <const constant_exprt &>(op1 ());
13751409 }
13761410
13771411 constant_exprt &repetitions ()
13781412 {
1379- PRECONDITION (!is_range ());
1413+ PRECONDITION (repetitions_given () && !is_range ());
13801414 return static_cast <constant_exprt &>(op1 ());
13811415 }
13821416
@@ -1434,10 +1468,52 @@ to_sva_sequence_repetition_expr(exprt &expr)
14341468 return static_cast <sva_sequence_repetition_exprt &>(expr);
14351469}
14361470
1471+ // / op[+]
1472+ class sva_sequence_repetition_plus_exprt : public sva_sequence_repetition_exprt
1473+ {
1474+ public:
1475+ // / The operand is a sequence
1476+ explicit sva_sequence_repetition_plus_exprt (exprt op)
1477+ : sva_sequence_repetition_exprt{
1478+ std::move (op),
1479+ ID_sva_sequence_repetition_plus}
1480+ {
1481+ }
1482+
1483+ // op[*1:$]
1484+ exprt lower () const ;
1485+ };
1486+
1487+ static inline const sva_sequence_repetition_plus_exprt &
1488+ to_sva_sequence_repetition_plus_expr (const exprt &expr)
1489+ {
1490+ PRECONDITION (expr.id () == ID_sva_sequence_repetition_plus);
1491+ sva_sequence_repetition_plus_exprt::check (expr);
1492+ return static_cast <const sva_sequence_repetition_plus_exprt &>(expr);
1493+ }
1494+
1495+ static inline sva_sequence_repetition_plus_exprt &
1496+ to_sva_sequence_repetition_plus_expr (exprt &expr)
1497+ {
1498+ PRECONDITION (expr.id () == ID_sva_sequence_repetition_plus);
1499+ sva_sequence_repetition_plus_exprt::check (expr);
1500+ return static_cast <sva_sequence_repetition_plus_exprt &>(expr);
1501+ }
1502+
1503+ // / [*] or [*n] or [*x:y] or [*x:$]
14371504class sva_sequence_consecutive_repetition_exprt
14381505 : public sva_sequence_repetition_exprt
14391506{
14401507public:
1508+ // / op[*]
1509+ explicit sva_sequence_consecutive_repetition_exprt (exprt __op)
1510+ : sva_sequence_repetition_exprt{
1511+ std::move (__op),
1512+ ID_sva_sequence_consecutive_repetition}
1513+ {
1514+ }
1515+
1516+ // / op[*n]
14411517 sva_sequence_consecutive_repetition_exprt (
14421518 exprt __op,
14431519 constant_exprt __repetitions)
@@ -1448,6 +1524,7 @@ class sva_sequence_consecutive_repetition_exprt
14481524 {
14491525 }
14501526
1527+ // / op[*x:y]
14511528 sva_sequence_consecutive_repetition_exprt (
14521529 exprt __op,
14531530 constant_exprt __from,
@@ -1460,6 +1537,22 @@ class sva_sequence_consecutive_repetition_exprt
14601537 {
14611538 }
14621539
1540+ // / op[*x:$]
1541+ sva_sequence_consecutive_repetition_exprt (
1542+ exprt __op,
1543+ constant_exprt __from,
1544+ infinity_exprt __to)
1545+ : sva_sequence_repetition_exprt{
1546+ std::move (__op),
1547+ ID_sva_sequence_consecutive_repetition,
1548+ std::move (__from),
1549+ std::move (__to)}
1550+ {
1551+ }
1552+
1553+ // / [*] --> [0:$]
1554+ // / [*n] --> op ##1 op ##1 op ...
1555+ // / [*x:y] --> op[*x] or op[*x+1] or ... or op[*y]
14631556 exprt lower () const ;
14641557};
14651558
0 commit comments