-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from diffblue/initial-properties
SystemVerilog: distinguish assertions
- Loading branch information
Showing
21 changed files
with
355 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
initial1.smv | ||
--bound 0 | ||
^\[main::spec1\] main::var::tmp1 = TRUE: PROVED up to bound 0$ | ||
^\[main::spec2\] main::var::tmp2 = TRUE: REFUTED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
MODULE main | ||
|
||
VAR tmp1: boolean; | ||
VAR tmp2: boolean; | ||
|
||
ASSIGN init(tmp1):=1; | ||
|
||
-- should pass | ||
SPEC tmp1 = 1; | ||
|
||
-- should fail | ||
SPEC tmp2 = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
KNOWNBUG | ||
CORE | ||
initial1.sv | ||
--module main --bound 1 | ||
^EXIT=0$ | ||
^\[main\.property\.1\] main\.counter == 0: PROVED up to bound 1$ | ||
^\[main\.property\.2\] main\.counter == 100: REFUTED$ | ||
^\[main\.property\.3\] ##1 main\.counter == 1: PROVED up to bound 1$ | ||
^\[main\.property\.4\] ##1 main\.counter == 100: REFUTED$ | ||
^\[main\.property\.5\] s_nexttime main\.counter == 1: PROVED up to bound 1$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
Syntax is missing for initial label: assert property (...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ module main; | |
some_task(x, y); | ||
end | ||
|
||
assert p1: y==x+1; | ||
always assert p1: y==x+1; | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,31 +10,28 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <util/expr_iterator.h> | ||
|
||
bool is_temporal_operator(const exprt &expr) | ||
{ | ||
return expr.id() == ID_AG || expr.id() == ID_EG || expr.id() == ID_AF || | ||
expr.id() == ID_EF || expr.id() == ID_AX || expr.id() == ID_EX || | ||
expr.id() == ID_A || expr.id() == ID_E || expr.id() == ID_U || | ||
expr.id() == ID_R || expr.id() == ID_G || expr.id() == ID_F || | ||
expr.id() == ID_X || expr.id() == ID_sva_always || | ||
expr.id() == ID_sva_always || expr.id() == ID_sva_nexttime || | ||
expr.id() == ID_sva_s_nexttime || expr.id() == ID_sva_until || | ||
expr.id() == ID_sva_s_until || expr.id() == ID_sva_until_with || | ||
expr.id() == ID_sva_s_until_with || expr.id() == ID_sva_eventually || | ||
expr.id() == ID_sva_s_eventually || expr.id() == ID_sva_cycle_delay; | ||
} | ||
|
||
bool has_temporal_operator(const exprt &expr) | ||
{ | ||
for(auto subexpr_it = expr.depth_cbegin(), subexpr_end = expr.depth_cend(); | ||
subexpr_it != subexpr_end; | ||
subexpr_it++) | ||
{ | ||
// clang-format off | ||
if( | ||
subexpr_it->id() == ID_AG || subexpr_it->id() == ID_EG || | ||
subexpr_it->id() == ID_AF || subexpr_it->id() == ID_EF || | ||
subexpr_it->id() == ID_AX || subexpr_it->id() == ID_EX || | ||
subexpr_it->id() == ID_A || subexpr_it->id() == ID_E || | ||
subexpr_it->id() == ID_U || subexpr_it->id() == ID_R || | ||
subexpr_it->id() == ID_G || subexpr_it->id() == ID_F || | ||
subexpr_it->id() == ID_X || | ||
subexpr_it->id() == ID_sva_always || subexpr_it->id() == ID_sva_always || | ||
subexpr_it->id() == ID_sva_nexttime || subexpr_it->id() == ID_sva_s_nexttime || | ||
subexpr_it->id() == ID_sva_until || subexpr_it->id() == ID_sva_s_until || | ||
subexpr_it->id() == ID_sva_until_with || subexpr_it->id() == ID_sva_s_until_with || | ||
subexpr_it->id() == ID_sva_eventually || | ||
subexpr_it->id() == ID_sva_s_eventually) | ||
{ | ||
if(is_temporal_operator(*subexpr_it)) | ||
return true; | ||
} | ||
// clang-format on | ||
} | ||
|
||
return false; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,8 @@ Author: Daniel Kroening, [email protected] | |
/// Returns true iff the given expression contains a temporal operator | ||
bool has_temporal_operator(const exprt &); | ||
|
||
/// Returns true iff the given expression has a temporal operator | ||
/// as its root | ||
bool is_temporal_operator(const exprt &); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/symbol_table.h> | ||
|
||
#include <temporal-logic/temporal_expr.h> | ||
#include <temporal-logic/temporal_logic.h> | ||
#include <verilog/sva_expr.h> | ||
|
||
#include "instantiate_word_level.h" | ||
|
@@ -34,8 +35,19 @@ Function: bmc_supports_property | |
|
||
bool bmc_supports_property(const exprt &expr) | ||
{ | ||
if(expr.is_constant()) | ||
return true; | ||
if(!is_temporal_operator(expr)) | ||
{ | ||
if(!has_temporal_operator(expr)) | ||
return true; // initial state only | ||
else | ||
return false; | ||
} | ||
else if(expr.id() == ID_sva_cycle_delay) | ||
return !has_temporal_operator(to_sva_cycle_delay_expr(expr).op()); | ||
else if(expr.id() == ID_sva_nexttime) | ||
return !has_temporal_operator(to_sva_nexttime_expr(expr).op()); | ||
else if(expr.id() == ID_sva_s_nexttime) | ||
return !has_temporal_operator(to_sva_s_nexttime_expr(expr).op()); | ||
else if(expr.id() == ID_AG) | ||
return true; | ||
else if(expr.id() == ID_G) | ||
|
@@ -68,9 +80,20 @@ void property( | |
{ | ||
messaget message(message_handler); | ||
|
||
if(property_expr.is_true()) | ||
// Initial state only property? | ||
if( | ||
!is_temporal_operator(property_expr) || | ||
property_expr.id() == ID_sva_cycle_delay || | ||
property_expr.id() == ID_sva_nexttime || | ||
property_expr.id() == ID_sva_s_nexttime) | ||
{ | ||
prop_handles.resize(no_timeframes, true_exprt()); | ||
if(no_timeframes > 0) | ||
{ | ||
exprt tmp = instantiate(property_expr, 0, no_timeframes, ns); | ||
prop_handles.push_back(solver.handle(tmp)); | ||
} | ||
|
||
return; | ||
} | ||
|
||
|
Oops, something went wrong.