Skip to content

Commit e289306

Browse files
committed
SVA Monitors
This adds an alternative flow for checking SVA properties, by translating the property into a monitor, which is added to the transition system.
1 parent bb675f6 commit e289306

18 files changed

+454
-7
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
always1.sv
3+
--sva-monitor --smv-word-level
4+
^VAR initial : boolean;$
5+
^VAR always_activated : boolean;$
6+
^INIT sva-monitor::initial$
7+
^INIT !sva-monitor::always_activated$
8+
^TRANS !next\(sva-monitor::initial\)$
9+
^TRANS next\(sva-monitor::always_activated\) = sva-monitor::always_active$
10+
^LTLSPEC G \(sva-monitor::always_active -> FALSE\)$
11+
^EXIT=0$
12+
^SIGNAL=0$
13+
--
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main(input clk);
2+
3+
p0: assert property (0);
4+
5+
endmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
initial1.sv
3+
--sva-monitor --smv-word-level
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main(input clk);
2+
3+
initial p0: assert property (0);
4+
5+
endmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
s_eventually1.sv
3+
--sva-monitor --smv-word-level
4+
^-- Verilog::main\.p0: not converted$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main(input clk);
2+
3+
p0: assert property (s_eventually 0);
4+
5+
endmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
s_nexttime1.sv
3+
--sva-monitor --smv-word-level
4+
^VAR initial : boolean;$
5+
^VAR delayed_active : boolean;$
6+
^INIT sva-monitor::initial$
7+
^INIT !sva-monitor::delayed_active$
8+
^TRANS !next\(sva-monitor::initial\)$
9+
^TRANS next\(sva-monitor::delayed_active\) = sva-monitor::initial$
10+
^LTLSPEC G \(sva-monitor::delayed_active -> FALSE\)$
11+
^EXIT=0$
12+
^SIGNAL=0$
13+
--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main(input clk);
2+
3+
initial p0: assert property (s_nexttime 0);
4+
5+
endmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
sequence1.sv
3+
--sva-monitor --smv-word-level
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module main(input clk);
2+
3+
reg [31:0] x = 0;
4+
5+
always_ff @(posedge clk)
6+
x++;
7+
8+
initial p0: assert property (x==0 ##1 x==1 ##1 x==2);
9+
10+
endmodule

src/ebmc/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SRC = \
3333
show_formula_solver.cpp \
3434
show_properties.cpp \
3535
show_trans.cpp \
36+
sva_monitor.cpp \
3637
transition_system.cpp \
3738
waveform.cpp \
3839
#empty line

src/ebmc/ebmc_parse_options.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Author: Daniel Kroening, kroening@kroening.com
2929
#include "ranking_function.h"
3030
#include "show_properties.h"
3131
#include "show_trans.h"
32+
#include "sva_monitor.h"
3233

3334
#include <iostream>
3435

@@ -218,6 +219,13 @@ int ebmc_parse_optionst::doit()
218219
auto properties = ebmc_propertiest::from_command_line(
219220
cmdline, transition_system, ui_message_handler);
220221

222+
// possibly apply liveness-to-safety
223+
if(cmdline.isset("liveness-to-safety"))
224+
liveness_to_safety(transition_system, properties);
225+
226+
if(cmdline.isset("sva-monitor"))
227+
sva_monitor(transition_system, properties);
228+
221229
if(cmdline.isset("smv-word-level"))
222230
{
223231
auto filename = cmdline.value_opt("outfile").value_or("-");
@@ -239,10 +247,6 @@ int ebmc_parse_optionst::doit()
239247
return 0;
240248
}
241249

242-
// possibly apply liveness-to-safety
243-
if(cmdline.isset("liveness-to-safety"))
244-
liveness_to_safety(transition_system, properties);
245-
246250
if(cmdline.isset("show-varmap"))
247251
{
248252
auto netlist =
@@ -373,6 +377,7 @@ void ebmc_parse_optionst::help()
373377
" {y--show-properties} \t list the properties in the model\n"
374378
" {y--property} {uid} \t check the property with given ID\n"
375379
" {y--liveness-to-safety} \t translate liveness properties to safety properties\n"
380+
" {y--sva-monitor} \t translate SVA properties into a monitor circuit\n"
376381
"\n"
377382
"Methods:\n"
378383
" {y--k-induction} \t do k-induction with k=bound\n"

src/ebmc/ebmc_parse_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ebmc_parse_optionst:public parse_options_baset
4949
"(random-traces)(trace-steps):(random-seed):(traces):"
5050
"(random-trace)(random-waveform)"
5151
"(bmc-with-assumptions)"
52-
"(liveness-to-safety)"
52+
"(liveness-to-safety)(sva-monitor)"
5353
"I:D:(preprocess)(systemverilog)(vl2smv-extensions)"
5454
"(warn-implicit-nets)",
5555
argc,

src/ebmc/output_smv_word_level.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ smv_invar(const exprt &expr, const namespacet &ns, std::ostream &out)
119119
if(expr.id() == ID_and)
120120
{
121121
for(auto &conjunct : expr.operands())
122-
smv_initial_states(conjunct, ns, out);
122+
smv_invar(conjunct, ns, out);
123123
}
124124
else if(expr.is_true())
125125
{
@@ -146,7 +146,7 @@ static void smv_transition_relation(
146146
if(expr.id() == ID_and)
147147
{
148148
for(auto &conjunct : expr.operands())
149-
smv_initial_states(conjunct, ns, out);
149+
smv_transition_relation(conjunct, ns, out);
150150
}
151151
else if(expr.is_true())
152152
{

0 commit comments

Comments
 (0)