Skip to content

Commit d23207a

Browse files
committed
BMC world-level: empty matches
SVA empty matches do not evaluate to true when used as property.
1 parent 1ef4ad1 commit d23207a

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

regression/verilog/SVA/empty_sequence1.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
KNOWNBUG
1+
CORE
22
empty_sequence1.sv
33
--bound 5
4+
^\[main\.p0\] 1 \[\*0\]: REFUTED$
5+
^\[main\.p1\] 1 \[\*0\] ##1 main\.x == 0: REFUTED$
46
^EXIT=10$
57
^SIGNAL=0$
68
--
79
^warning: ignoring
810
--
9-
Repetition with zero is not implemented.

regression/verilog/SVA/sequence_repetition2.desc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ CORE
22
sequence_repetition2.sv
33
--bound 10
44
^\[main\.p0\] main\.x == 0 \[\*\]: PROVED up to bound 10$
5-
^\[main\.p1\] main\.x == 1 \[\*\]: PROVED up to bound 10$
6-
^\[main\.p2\] \(main\.x == 0 \[\+\]\) #=# main\.x == 1: PROVED up to bound 10$
7-
^\[main\.p3\] main\.x == 0 \[\+\]: PROVED up to bound 10$
8-
^\[main\.p4\] main\.half_x == 0 \[\*\]: PROVED up to bound 10$
9-
^\[main\.p5\] 0 \[\*\]: PROVED up to bound 10$
5+
^\[main\.p1\] \(main\.x == 0 \[\+\]\) #=# main\.x == 1: PROVED up to bound 10$
6+
^\[main\.p2\] main\.x == 0 \[\+\]: PROVED up to bound 10$
7+
^\[main\.p3\] main\.half_x == 0 \[\*\]: PROVED up to bound 10$
8+
^\[main\.p4\] main\.x == 1 \[\*\]: REFUTED$
9+
^\[main\.p5\] 0 \[\*\]: REFUTED$
1010
^\[main\.p6\] main\.x == 1 \[\+\]: REFUTED$
1111
^\[main\.p7\] \(main\.x == 0 \[\+\]\) #-# main\.x == 1: REFUTED$
1212
^\[main\.p8\] 0 \[\+\]: REFUTED$

regression/verilog/SVA/sequence_repetition2.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module main(input clk);
1111

1212
// should pass
1313
initial p0: assert property (x==0[*]);
14-
initial p1: assert property (x==1[*]);
15-
initial p2: assert property (x==0[+] #=# x==1);
16-
initial p3: assert property (x==0[+]);
17-
initial p4: assert property (half_x==0[*]);
18-
initial p5: assert property (0[*]); // empty match
14+
initial p1: assert property (x==0[+] #=# x==1);
15+
initial p2: assert property (x==0[+]);
16+
initial p3: assert property (half_x==0[*]);
1917

2018
// should fail
19+
initial p4: assert property (x==1[*]);
20+
initial p5: assert property (0[*]); // empty match
2121
initial p6: assert property (x==1[+]);
2222
initial p7: assert property (x==0[+] #-# x==1);
2323
initial p8: assert property (0[+]);

src/trans-word-level/property.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ static obligationst property_obligations_rec(
563563
for(auto &match : matches)
564564
{
565565
// The sequence must not match.
566-
obligations.add(match.end_time, not_exprt{match.condition});
566+
if(!match.empty_match())
567+
obligations.add(match.end_time, not_exprt{match.condition});
567568
}
568569

569570
return obligations;
@@ -706,8 +707,12 @@ static obligationst property_obligations_rec(
706707

707708
for(auto &match : matches)
708709
{
709-
disjuncts.push_back(match.condition);
710-
max = std::max(max, match.end_time);
710+
// empty matches are not considered
711+
if(!match.empty_match())
712+
{
713+
disjuncts.push_back(match.condition);
714+
max = std::max(max, match.end_time);
715+
}
711716
}
712717

713718
return obligationst{max, disjunction(disjuncts)};

src/trans-word-level/sequence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ sequence_matchest instantiate_sequence(
368368
if(repetition.is_empty_match())
369369
{
370370
// [*0] denotes the empty match
371-
return {{t, true_exprt{}}};
371+
return {sequence_matcht::empty_match(t)};
372372
}
373373
else if(repetition.is_unbounded() && repetition.repetitions_given())
374374
{

src/trans-word-level/sequence.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,25 @@ class sequence_matcht
1919
{
2020
public:
2121
sequence_matcht(mp_integer __end_time, exprt __condition)
22-
: end_time(std::move(__end_time)), condition(std::move(__condition))
22+
: _is_empty_match(false), end_time(std::move(__end_time)), condition(std::move(__condition))
2323
{
2424
}
2525

26+
bool empty_match() const
27+
{
28+
return _is_empty_match;
29+
}
30+
31+
bool _is_empty_match;
2632
mp_integer end_time;
2733
exprt condition;
34+
35+
static sequence_matcht empty_match(mp_integer end_time)
36+
{
37+
auto result = sequence_matcht{end_time, true_exprt{}};
38+
result._is_empty_match = true;
39+
return result;
40+
}
2841
};
2942

3043
/// A set of matches of an SVA sequence.

0 commit comments

Comments
 (0)