Skip to content

Commit 4be42da

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

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-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
@@ -557,7 +557,8 @@ static obligationst property_obligations_rec(
557557
for(auto &match : matches)
558558
{
559559
// The sequence must not match.
560-
obligations.add(match.end_time, not_exprt{match.condition});
560+
if(!match.empty_match())
561+
obligations.add(match.end_time, not_exprt{match.condition});
561562
}
562563

563564
return obligations;
@@ -700,8 +701,12 @@ static obligationst property_obligations_rec(
700701

701702
for(auto &match : matches)
702703
{
703-
disjuncts.push_back(match.condition);
704-
max = std::max(max, match.end_time);
704+
// empty matches are not considered
705+
if(!match.empty_match())
706+
{
707+
disjuncts.push_back(match.condition);
708+
max = std::max(max, match.end_time);
709+
}
705710
}
706711

707712
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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,30 @@ 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),
23+
end_time(std::move(__end_time)),
24+
condition(std::move(__condition))
2325
{
2426
}
2527

28+
bool empty_match() const
29+
{
30+
return _is_empty_match;
31+
}
32+
33+
protected:
34+
bool _is_empty_match;
35+
36+
public:
2637
mp_integer end_time;
2738
exprt condition;
39+
40+
static sequence_matcht empty_match(mp_integer end_time)
41+
{
42+
auto result = sequence_matcht{end_time, true_exprt{}};
43+
result._is_empty_match = true;
44+
return result;
45+
}
2846
};
2947

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

0 commit comments

Comments
 (0)