Skip to content

Commit 0675677

Browse files
committed
Fix fragment of SVA supported by word-level BMC
1) The simplifier is changed to stay within SVA when simplifying SVA. 2) The logic that recognises supported SVA is adjusted.
1 parent 2c25ba1 commit 0675677

File tree

6 files changed

+58
-40
lines changed

6 files changed

+58
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
s_eventually4.sv
3+
--module main --bound 11
4+
^\[main\.p0\] always \(\(s_eventually main\.counter == 1\) or \(s_eventually main.counter == 10\)\): PROVED up to bound 11$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module main(input clk);
2+
3+
reg [7:0] counter;
4+
5+
initial counter = 0;
6+
7+
// 0, 1, 2, 3, 4, 0, ...
8+
always @(posedge clk)
9+
if(counter < 5)
10+
counter = counter + 1;
11+
else
12+
counter = 0;
13+
14+
// expected to pass, owing to the first disjunct
15+
p0: assert property ((s_eventually counter==1) or (s_eventually counter==10));
16+
17+
endmodule

src/temporal-logic/normalize_property.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ exprt normalize_pre_sva_overlapped_implication(
8686
exprt normalize_pre_sva_non_overlapped_implication(
8787
sva_non_overlapped_implication_exprt expr)
8888
{
89-
// Same as a->nexttime b if lhs is not a sequence.
89+
// Same as a->always[1:1] b if lhs is not a sequence.
9090
if(!is_SVA_sequence(expr.lhs()))
91-
return or_exprt{not_exprt{expr.lhs()}, sva_nexttime_exprt{expr.rhs()}};
91+
{
92+
auto one = natural_typet{}.one_expr();
93+
return or_exprt{
94+
not_exprt{expr.lhs()}, sva_ranged_always_exprt{one, one, expr.rhs()}};
95+
}
9296
else
9397
return std::move(expr);
9498
}
@@ -178,7 +182,7 @@ exprt normalize_property(exprt expr)
178182
else if(expr.id() == ID_sva_s_nexttime)
179183
{
180184
auto one = natural_typet{}.one_expr();
181-
expr = sva_ranged_always_exprt{one, one, to_sva_s_nexttime_expr(expr).op()};
185+
expr = sva_s_always_exprt{one, one, to_sva_s_nexttime_expr(expr).op()};
182186
}
183187
else if(expr.id() == ID_sva_indexed_nexttime)
184188
{
@@ -193,11 +197,18 @@ exprt normalize_property(exprt expr)
193197
nexttime_expr.index(), nexttime_expr.index(), nexttime_expr.op()};
194198
}
195199
else if(expr.id() == ID_sva_cycle_delay)
200+
{
196201
expr = normalize_pre_sva_cycle_delay(to_sva_cycle_delay_expr(expr));
202+
}
197203
else if(expr.id() == ID_sva_cycle_delay_plus)
198-
expr = F_exprt{X_exprt{to_sva_cycle_delay_plus_expr(expr).op()}};
204+
{
205+
expr = sva_s_eventually_exprt{
206+
sva_s_nexttime_exprt{to_sva_cycle_delay_plus_expr(expr).op()}};
207+
}
199208
else if(expr.id() == ID_sva_cycle_delay_star)
200-
expr = F_exprt{to_sva_cycle_delay_star_expr(expr).op()};
209+
{
210+
expr = sva_s_eventually_exprt{to_sva_cycle_delay_star_expr(expr).op()};
211+
}
201212
else if(expr.id() == ID_sva_sequence_concatenation)
202213
{
203214
auto &sequence_concatenation = to_sva_sequence_concatenation_expr(expr);

src/temporal-logic/normalize_property.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ Author: Daniel Kroening, [email protected]
2727
/// a sva_and b --> a ∧ b if a and b are not SVA sequences
2828
/// a sva_or b --> a ∨ b if a and b are not SVA sequences
2929
/// sva_overlapped_implication --> ¬a ∨ b if a is not an SVA sequence
30-
/// sva_non_overlapped_implication --> ¬a ∨ sva_nexttime b if a is not an SVA sequence
31-
/// sva_nexttime φ -->
30+
/// sva_non_overlapped_implication --> ¬a ∨ always[1:1] b if a is not an SVA sequence
31+
/// sva_nexttime φ --> sva_always[1:1] φ
3232
/// sva_nexttime[i] φ --> sva_always[i:i] φ
33-
/// sva_s_nexttime φ -->
33+
/// sva_s_nexttime φ --> sva_always[1:1] φ
3434
/// sva_s_nexttime[i] φ --> sva_s_always[i:i] φ
3535
/// sva_if --> ? :
3636
/// ##[0:$] φ --> s_eventually φ
3737
/// ##[i:$] φ --> s_nexttime[i] s_eventually φ
38-
/// ##[*] φ --> F φ
39-
/// ##[+] φ --> X F φ
38+
/// ##[*] φ --> s_eventually φ
39+
/// ##[+] φ --> always[1:1] s_eventually φ
4040
/// strong(φ) --> φ
4141
/// weak(φ) --> φ
4242
/// sva_case --> ? :

src/temporal-logic/temporal_logic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool is_SVA_sequence(const exprt &);
4545
/// Returns true iff the given expression is an SVA temporal operator
4646
bool is_SVA_operator(const exprt &);
4747

48-
/// Returns true iff the given expression contains an SVA temporal operator
48+
/// Returns true iff the given expression is an SVA expression
4949
bool is_SVA(const exprt &);
5050

5151
#endif

src/trans-word-level/property.cpp

+11-29
Original file line numberDiff line numberDiff line change
@@ -145,35 +145,15 @@ Function: bmc_supports_SVA_property
145145

146146
bool bmc_supports_SVA_property(const exprt &expr)
147147
{
148-
if(!is_temporal_operator(expr))
149-
{
150-
if(!has_temporal_operator(expr))
151-
return true; // initial state only
152-
else if(
153-
expr.id() == ID_and || expr.id() == ID_or || expr.id() == ID_implies)
154-
{
155-
for(auto &op : expr.operands())
156-
if(!bmc_supports_property(op))
157-
return false;
158-
return true;
159-
}
160-
else
161-
return false;
162-
}
163-
else if(expr.id() == ID_sva_cycle_delay)
164-
return !has_temporal_operator(to_sva_cycle_delay_expr(expr).op());
165-
else if(expr.id() == ID_sva_nexttime)
166-
return !has_temporal_operator(to_sva_nexttime_expr(expr).op());
167-
else if(expr.id() == ID_sva_s_nexttime)
168-
return !has_temporal_operator(to_sva_s_nexttime_expr(expr).op());
169-
else if(expr.id() == ID_sva_always)
170-
return true;
171-
else if(expr.id() == ID_sva_ranged_always)
172-
return true;
173-
else if(expr.id() == ID_sva_s_eventually)
174-
return true;
175-
else
148+
// sva_nonoverlapped_followed_by is not supported yet
149+
if(has_subexpr(expr, ID_sva_nonoverlapped_followed_by))
150+
return false;
151+
152+
// sva_overlapped_followed_by is not supported yet
153+
if(has_subexpr(expr, ID_sva_overlapped_followed_by))
176154
return false;
155+
156+
return true;
177157
}
178158

179159
/*******************************************************************\
@@ -194,8 +174,10 @@ bool bmc_supports_property(const exprt &expr)
194174
return bmc_supports_LTL_property(expr);
195175
else if(is_CTL(expr))
196176
return bmc_supports_CTL_property(expr);
197-
else
177+
else if(is_SVA(expr))
198178
return bmc_supports_SVA_property(expr);
179+
else
180+
return false; // unknown category
199181
}
200182

201183
/*******************************************************************\

0 commit comments

Comments
 (0)