Skip to content

Commit b643fae

Browse files
committed
smv-netlist: use expr2smv for property
The SMV to netlist conversion now uses expr2smv for outputting the property, which enables outputting full LTL or CTL.
1 parent d179b18 commit b643fae

File tree

5 files changed

+64
-9
lines changed

5 files changed

+64
-9
lines changed

regression/ebmc/smv-netlist/smv1.desc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
smv1.smv
3+
--smv-netlist
4+
^MODULE main$
5+
^VAR smv\.main\.var\.x: boolean;$
6+
^ASSIGN next\(smv\.main\.var\.x\):=\!smv\.main\.var\.x;$
7+
^INIT !smv\.main\.var\.x$
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--

regression/ebmc/smv-netlist/smv1.smv

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MODULE main
2+
3+
VAR x: boolean;
4+
5+
ASSIGN next(x):=!x;
6+
ASSIGN init(x):=FALSE;
7+
8+
LTLSPEC G F x
9+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
verilog1.sv
3+
--smv-netlist
4+
^MODULE main$
5+
^VAR Verilog\.main\.x: boolean;$
6+
^ASSIGN next\(Verilog\.main\.x\):=\!Verilog\.main\.x;$
7+
^INIT !Verilog\.main\.x$
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module main(input clk);
2+
3+
reg x;
4+
5+
initial x = 0;
6+
7+
always @(posedge clk)
8+
x = !x;
9+
10+
always assert property (always s_eventually x);
11+
12+
endmodule

src/trans-netlist/smv_netlist.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,35 @@ void print_smv(const netlistt &netlist, std::ostream &out, const exprt &expr)
8888
symbol_tablet symbol_table;
8989
namespacet ns{symbol_table};
9090

91-
// replace literal expressions by symbols
91+
class expr2smv_netlistt : public expr2smvt
92+
{
93+
public:
94+
expr2smv_netlistt(const namespacet &ns, const netlistt &__netlist)
95+
: expr2smvt(ns), netlist(__netlist)
96+
{
97+
}
9298

93-
exprt replaced = expr;
94-
replaced.visit_pre(
95-
[&netlist](exprt &node)
99+
protected:
100+
const netlistt &netlist;
101+
102+
resultt convert_rec(const exprt &expr) override
96103
{
97-
if(node.id() == ID_literal)
104+
if(expr.id() == ID_literal)
98105
{
99106
std::ostringstream buffer;
100-
print_smv(netlist, buffer, to_literal_expr(node).get_literal());
101-
node = symbol_exprt{buffer.str(), node.type()};
107+
auto l = to_literal_expr(expr).get_literal();
108+
print_smv(netlist, buffer, l);
109+
if(l.sign())
110+
return {precedencet::NOT, buffer.str()};
111+
else
112+
return {precedencet::MAX, buffer.str()};
102113
}
103-
});
114+
else
115+
return expr2smvt::convert_rec(expr);
116+
}
117+
};
104118

105-
out << expr2smv(replaced, ns);
119+
out << expr2smv_netlistt{ns, netlist}.convert(expr);
106120
}
107121

108122
void smv_netlist(const netlistt &netlist, std::ostream &out)

0 commit comments

Comments
 (0)