Skip to content

Commit fbbe228

Browse files
committed
SVA-to-LTL: sequence and/or
This adds SVA sequence and/or to the SVA-to-LTL translator.
1 parent 6732c86 commit fbbe228

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
@@ -115,6 +115,63 @@ std::vector<sva_sequence_matcht> LTL_sequence_matches(const exprt &sequence)
115115
else
116116
return {};
117117
}
118+
else if(sequence.id() == ID_sva_and)
119+
{
120+
// IEEE 1800-2017 16.9.5
121+
// 1. Both operands must match.
122+
// 2. Both sequences start at the same time.
123+
// 3. The end time of the composite sequence is
124+
// the end time of the operand sequence that completes last.
125+
auto &and_expr = to_sva_and_expr(sequence);
126+
auto matches_lhs = LTL_sequence_matches(and_expr.lhs());
127+
auto matches_rhs = LTL_sequence_matches(and_expr.rhs());
128+
129+
if(matches_lhs.empty() || matches_rhs.empty())
130+
return {};
131+
132+
std::vector<sva_sequence_matcht> result;
133+
134+
for(auto &match_lhs : matches_lhs)
135+
for(auto &match_rhs : matches_rhs)
136+
{
137+
sva_sequence_matcht new_match;
138+
auto new_length = std::max(match_lhs.length(), match_rhs.length());
139+
new_match.cond_vector.resize(new_length);
140+
for(std::size_t i = 0; i < new_length; i++)
141+
{
142+
exprt::operandst conjuncts;
143+
if(i < match_lhs.cond_vector.size())
144+
conjuncts.push_back(match_lhs.cond_vector[i]);
145+
146+
if(i < match_rhs.cond_vector.size())
147+
conjuncts.push_back(match_rhs.cond_vector[i]);
148+
149+
new_match.cond_vector[i] = conjunction(conjuncts);
150+
}
151+
152+
result.push_back(std::move(new_match));
153+
}
154+
155+
return result;
156+
}
157+
else if(sequence.id() == ID_sva_or)
158+
{
159+
// IEEE 1800-2017 16.9.7
160+
// The set of matches of a or b is the set union of the matches of a
161+
// and the matches of b.
162+
std::vector<sva_sequence_matcht> result;
163+
164+
for(auto &op : to_sva_or_expr(sequence).operands())
165+
{
166+
auto op_matches = LTL_sequence_matches(op);
167+
if(op_matches.empty())
168+
return {}; // not supported
169+
for(auto &match : op_matches)
170+
result.push_back(std::move(match));
171+
}
172+
173+
return result;
174+
}
118175
else
119176
{
120177
return {}; // unsupported

0 commit comments

Comments
 (0)