Skip to content

Commit b57d45d

Browse files
committed
SVA: sequence() methods for first_match and throughout
This adds convenience accessors for the sequence-typed operand of the SVA first_match and throughout expression classes.
1 parent 8f6b2ee commit b57d45d

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

src/trans-word-level/sequence.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ sequence_matchest instantiate_sequence(
220220
{
221221
auto &first_match = to_sva_sequence_first_match_expr(expr);
222222

223-
const auto lhs_matches =
224-
instantiate_sequence(first_match.lhs(), semantics, t, no_timeframes);
223+
const auto matches =
224+
instantiate_sequence(first_match.sequence(), semantics, t, no_timeframes);
225225

226226
// the match of seq with the earliest ending clock tick is a
227227
// match of first_match (seq)
228228
std::optional<mp_integer> earliest;
229229

230-
for(auto &match : lhs_matches)
230+
for(auto &match : matches)
231231
{
232232
if(!earliest.has_value() || earliest.value() > match.end_time)
233233
earliest = match.end_time;
@@ -238,7 +238,7 @@ sequence_matchest instantiate_sequence(
238238

239239
sequence_matchest result;
240240

241-
for(auto &match : lhs_matches)
241+
for(auto &match : matches)
242242
{
243243
// Earliest?
244244
if(match.end_time == earliest.value())
@@ -257,23 +257,23 @@ sequence_matchest instantiate_sequence(
257257
// - exp evaluates to true at each clock tick of the interval.
258258
auto &throughout = to_sva_sequence_throughout_expr(expr);
259259

260-
const auto rhs_matches =
261-
instantiate_sequence(throughout.rhs(), semantics, t, no_timeframes);
260+
const auto matches =
261+
instantiate_sequence(throughout.sequence(), semantics, t, no_timeframes);
262262

263263
sequence_matchest result;
264264

265-
for(auto &rhs_match : rhs_matches)
265+
for(auto &match : matches)
266266
{
267-
exprt::operandst conjuncts = {rhs_match.condition()};
267+
exprt::operandst conjuncts = {match.condition()};
268268

269-
for(mp_integer new_t = t; new_t <= rhs_match.end_time; ++new_t)
269+
for(mp_integer new_t = t; new_t <= match.end_time; ++new_t)
270270
{
271271
auto obligations =
272272
property_obligations(throughout.lhs(), new_t, no_timeframes);
273273
conjuncts.push_back(obligations.conjunction().second);
274274
}
275275

276-
result.emplace_back(rhs_match.end_time, conjunction(conjuncts));
276+
result.emplace_back(match.end_time, conjunction(conjuncts));
277277
}
278278

279279
return result;

src/verilog/sva_expr.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,16 @@ class sva_sequence_throughout_exprt : public binary_exprt
17461746
: binary_exprt(std::move(op0), ID_sva_sequence_throughout, std::move(op1))
17471747
{
17481748
}
1749+
1750+
const exprt &sequence() const
1751+
{
1752+
return op1();
1753+
}
1754+
1755+
exprt &sequence()
1756+
{
1757+
return op1();
1758+
}
17491759
};
17501760

17511761
static inline const sva_sequence_throughout_exprt &
@@ -1780,6 +1790,16 @@ class sva_sequence_first_match_exprt : public binary_exprt
17801790
std::move(action))
17811791
{
17821792
}
1793+
1794+
const exprt &sequence() const
1795+
{
1796+
return op0();
1797+
}
1798+
1799+
exprt &sequence()
1800+
{
1801+
return op0();
1802+
}
17831803
};
17841804

17851805
static inline const sva_sequence_first_match_exprt &

src/verilog/verilog_typecheck_sva.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ exprt verilog_typecheck_exprt::convert_binary_sva(binary_exprt expr)
264264
{
265265
auto &first_match_expr = to_sva_sequence_first_match_expr(expr);
266266

267-
convert_sva(first_match_expr.lhs());
268-
require_sva_sequence(first_match_expr.lhs());
267+
convert_sva(first_match_expr.sequence());
268+
require_sva_sequence(first_match_expr.sequence());
269269

270270
if(first_match_expr.rhs().is_not_nil())
271271
convert_expr(first_match_expr.rhs());

0 commit comments

Comments
 (0)