Skip to content

Commit 11397bf

Browse files
authored
Merge pull request #844 from diffblue/instrument_past
Instrumentation for `$past`
2 parents 1b31efb + b261dfd commit 11397bf

18 files changed

+323
-40
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Verilog: bugfix for $onehot0
44
* Verilog: fix for primitive gates with more than two inputs
5+
* Verilog: Support $past when using AIG-based engines
56

67
# EBMC 5.4
78

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
past-instrumentation1.sv
3+
--bound 10 --aig
4+
^\[.*\] always main\.counter >= 1 -> \$past\(main\.counter, 1\) == main\.counter - 1: PROVED up to bound 10$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module main(input clk);
2+
3+
reg [31:0] counter = 0;
4+
5+
always @(posedge clk)
6+
counter++;
7+
8+
assert property ($past(counter, 0) == counter);
9+
10+
assert property (counter >= 1 -> $past(counter, 1) == counter - 1);
11+
12+
assert property (counter >= 2 -> $past(counter, 2) == counter - 2);
13+
14+
assert property (counter == 0 -> $past(counter, 1) == 0);
15+
16+
assert property (counter == 1 -> $past(counter, 2) == 0);
17+
18+
endmodule
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
past-instrumentation2.sv
3+
--bdd
4+
\[main\.assert\.1\] always \$past\(main\.counter, 0\) == main\.counter: PROVED$
5+
\[main\.assert\.2\] always main\.counter >= 1 -> \$past\(main\.counter, 1\) == main\.counter - 1: PROVED$
6+
\[main\.assert\.3\] always main\.counter >= 2 -> \$past\(main\.counter, 2\) == main\.counter - 2: PROVED$
7+
\[main\.assert\.4\] always main\.counter == 0 -> \$past\(main\.counter, 1\) == 0: REFUTED$
8+
\[main\.assert\.5\] always main\.counter == 1 -> \$past\(main\.counter, 2\) == 0: REFUTED$
9+
^EXIT=10$
10+
^SIGNAL=0$
11+
--
12+
^warning: ignoring
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module main(input clk);
2+
3+
reg [3:0] counter = 0;
4+
5+
always @(posedge clk)
6+
counter++;
7+
8+
assert property ($past(counter, 0) == counter);
9+
10+
assert property (counter >= 1 -> $past(counter, 1) == counter - 1);
11+
12+
assert property (counter >= 2 -> $past(counter, 2) == counter - 2);
13+
14+
// expected to fail -- the counter can wrap around
15+
assert property (counter == 0 -> $past(counter, 1) == 0);
16+
17+
// expected to fail -- the counter can wrap around
18+
assert property (counter == 1 -> $past(counter, 2) == 0);
19+
20+
endmodule
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
past-instrumentation3.sv
3+
--bdd
4+
\[.*\] always main\.counter >= 2 -> \$past\(main\.counter, 2\) == main\.counter - 2: PROVED$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module main(input clk);
2+
3+
reg [3:0] counter = 0;
4+
5+
always @(posedge clk)
6+
counter++;
7+
8+
// $past(counter, 1) is deliberately not used
9+
assert property (counter >= 2 -> $past(counter, 2) == counter - 2);
10+
11+
endmodule

regression/verilog/system-functions/past2.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
past2.sv
33
--bdd
4-
^\[main\.p0\] always \(main\.counter == 0 \|-> \$past\(main\.counter, 1\) == 0\): FAILURE: property not supported by BDD engine$
5-
^EXIT=10$
4+
^\[main\.p0\] always \(main\.counter == 0 \|-> \$past\(main\.counter, 1\) == 0\): PROVED$
5+
^EXIT=0$
66
^SIGNAL=0$
77
--
88
^warning: ignoring
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module main(input clk);
22

3-
reg [31:0] counter = 0;
3+
reg [3:0] counter = 0;
44

55
always @(posedge clk)
66
if(counter < 10)
77
counter++;
88

99
p0: assert property (counter == 0 |-> $past(counter, 1) == 0);
10-
// p1: assert property (counter != 0 && counter != 10 |-> $past(counter, 1) == counter - 1);
10+
p1: assert property (counter != 0 && counter != 10 |-> $past(counter, 1) == counter - 1);
1111

1212
endmodule

src/ebmc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SRC = \
1515
ebmc_parse_options.cpp \
1616
ebmc_properties.cpp \
1717
ebmc_solver_factory.cpp \
18+
instrument_past.cpp \
1819
k_induction.cpp \
1920
liveness_to_safety.cpp \
2021
live_signal.cpp \

0 commit comments

Comments
 (0)