-
Notifications
You must be signed in to change notification settings - Fork 15
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 #527 from diffblue/sequence2
Verilog: normalize `##[i:$]`
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CORE | ||
sequence2.sv | ||
--bound 10 --numbered-trace | ||
^\[main\.property\.1] ##\[0:\$\] main\.x == 10: REFUTED$ | ||
^Counterexample with 7 states:$ | ||
^main\.x@0 = 0$ | ||
^main\.x@1 = 1$ | ||
^main\.x@2 = 2$ | ||
^main\.x@3 = 3$ | ||
^main\.x@4 = 4$ | ||
^main\.x@5 = 5$ | ||
^main\.x@6 = 5$ | ||
^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,15 @@ | ||
module main; | ||
|
||
reg [31:0] x; | ||
wire clk; | ||
|
||
initial x=0; | ||
|
||
always @(posedge clk) | ||
if(x != 5) | ||
x<=x+1; | ||
|
||
// fails once we see the lasso 0, 1, 2, 3, 4, 5, 5 | ||
initial p0: assert property (##[0:$] x==10); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "normalize_property.h" | ||
|
||
#include <util/arith_tools.h> | ||
#include <util/std_expr.h> | ||
|
||
#include <verilog/sva_expr.h> | ||
|
@@ -74,6 +75,27 @@ exprt normalize_pre_sva_non_overlapped_implication( | |
return or_exprt{not_exprt{expr.lhs()}, X_exprt{expr.rhs()}}; | ||
} | ||
|
||
exprt normalize_pre_sva_cycle_delay(sva_cycle_delay_exprt expr) | ||
{ | ||
if(expr.is_unbounded()) | ||
{ | ||
if( | ||
expr.from().is_constant() && | ||
numeric_cast_v<mp_integer>(to_constant_expr(expr.from())) == 0) | ||
{ | ||
// ##[0:$] φ --> F φ | ||
return F_exprt{expr.op()}; | ||
} | ||
else | ||
{ | ||
// ##[i:$] φ --> ##i F φ | ||
return sva_cycle_delay_exprt{expr.from(), F_exprt{expr.op()}}; | ||
} | ||
} | ||
else | ||
return std::move(expr); | ||
} | ||
|
||
exprt normalize_property(exprt expr) | ||
{ | ||
// pre-traversal | ||
|
@@ -93,6 +115,8 @@ exprt normalize_property(exprt expr) | |
expr = X_exprt{to_sva_nexttime_expr(expr).op()}; | ||
else if(expr.id() == ID_sva_s_nexttime) | ||
expr = X_exprt{to_sva_s_nexttime_expr(expr).op()}; | ||
else if(expr.id() == ID_sva_cycle_delay) | ||
expr = normalize_pre_sva_cycle_delay(to_sva_cycle_delay_expr(expr)); | ||
|
||
// normalize the operands | ||
for(auto &op : expr.operands()) | ||
|
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