Skip to content

Commit 2728d52

Browse files
authored
Merge pull request #1114 from diffblue/sva-to-ltl-and-or
SVA-to-LTL: sequence `and`/`or`
2 parents dc88f54 + fbbe228 commit 2728d52

File tree

6 files changed

+83
-0
lines changed

6 files changed

+83
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
sequence_and2.sv
3+
--bdd
4+
\[.*\] \(1 and \(##2 1\)\) \|-> main\.x == 2: FAILURE: property not supported by BDD engine$
5+
\[.*\] \(\(##2 1\) and 1\) \|-> main\.x == 2: FAILURE: property not supported by BDD engine$
6+
\[.*\] \(\(##2 1\) and 1\) #-# main\.x == 2: PROVED$
7+
^EXIT=10$
8+
^SIGNAL=0$
9+
--
10+
^warning: ignoring
11+
--

regression/verilog/SVA/sequence_and2.desc renamed to regression/verilog/SVA/sequence_and2.bmc.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ sequence_and2.sv
33

44
\[.*\] \(1 and \(##2 1\)\) \|-> main\.x == 2: PROVED up to bound 5$
55
\[.*\] \(\(##2 1\) and 1\) \|-> main\.x == 2: PROVED up to bound 5$
6+
\[.*\] \(\(##2 1\) and 1\) #-# main\.x == 2: PROVED up to bound 5$
67
^EXIT=0$
78
^SIGNAL=0$
89
--

regression/verilog/SVA/sequence_and2.sv

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

1212
initial p2: assert property ((##2 1 and 1) |-> x == 2);
1313

14+
initial p3: assert property ((##2 1 and 1) #-# x == 2);
15+
1416
endmodule
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
sequence_or1.sv
3+
--bdd
4+
^\[main\.p0\] main\.x == 0 or main\.x == 1: PROVED$
5+
^\[main\.p1\] strong\(main\.x == 0 or main\.x == 1\): PROVED$
6+
^\[main\.p2\] main\.x == 0 or \(nexttime main\.x == 1\): FAILURE: property not supported by BDD engine$
7+
^\[main\.p3\] \(nexttime main\.x == 1\) or main\.x == 1: FAILURE: property not supported by BDD engine$
8+
^\[main\.p4\] \(main\.x == 0 or main\.x != 10\) |=> main\.x == 1: FAILURE: property not supported by BDD engine$
9+
^EXIT=10$
10+
^SIGNAL=0$
11+
--
12+
--

src/temporal-logic/sva_sequence_match.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,63 @@ std::vector<sva_sequence_matcht> LTL_sequence_matches(const exprt &sequence)
166166
else
167167
return {};
168168
}
169+
else if(sequence.id() == ID_sva_and)
170+
{
171+
// IEEE 1800-2017 16.9.5
172+
// 1. Both operands must match.
173+
// 2. Both sequences start at the same time.
174+
// 3. The end time of the composite sequence is
175+
// the end time of the operand sequence that completes last.
176+
auto &and_expr = to_sva_and_expr(sequence);
177+
auto matches_lhs = LTL_sequence_matches(and_expr.lhs());
178+
auto matches_rhs = LTL_sequence_matches(and_expr.rhs());
179+
180+
if(matches_lhs.empty() || matches_rhs.empty())
181+
return {};
182+
183+
std::vector<sva_sequence_matcht> result;
184+
185+
for(auto &match_lhs : matches_lhs)
186+
for(auto &match_rhs : matches_rhs)
187+
{
188+
sva_sequence_matcht new_match;
189+
auto new_length = std::max(match_lhs.length(), match_rhs.length());
190+
new_match.cond_vector.resize(new_length);
191+
for(std::size_t i = 0; i < new_length; i++)
192+
{
193+
exprt::operandst conjuncts;
194+
if(i < match_lhs.cond_vector.size())
195+
conjuncts.push_back(match_lhs.cond_vector[i]);
196+
197+
if(i < match_rhs.cond_vector.size())
198+
conjuncts.push_back(match_rhs.cond_vector[i]);
199+
200+
new_match.cond_vector[i] = conjunction(conjuncts);
201+
}
202+
203+
result.push_back(std::move(new_match));
204+
}
205+
206+
return result;
207+
}
208+
else if(sequence.id() == ID_sva_or)
209+
{
210+
// IEEE 1800-2017 16.9.7
211+
// The set of matches of a or b is the set union of the matches of a
212+
// and the matches of b.
213+
std::vector<sva_sequence_matcht> result;
214+
215+
for(auto &op : to_sva_or_expr(sequence).operands())
216+
{
217+
auto op_matches = LTL_sequence_matches(op);
218+
if(op_matches.empty())
219+
return {}; // not supported
220+
for(auto &match : op_matches)
221+
result.push_back(std::move(match));
222+
}
223+
224+
return result;
225+
}
169226
else
170227
{
171228
return {}; // unsupported

0 commit comments

Comments
 (0)