Skip to content

Commit 2e7a406

Browse files
authored
Merge pull request #1064 from diffblue/smv-netlist-not-translated
netlists: include properties that are not translated in map
2 parents 31c4ec8 + fe8a5e2 commit 2e7a406

File tree

8 files changed

+32
-16
lines changed

8 files changed

+32
-16
lines changed

regression/ebmc/smv-netlist/verilog1.desc

+3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ verilog1.sv
55
^VAR Verilog\.main\.x: boolean;$
66
^ASSIGN next\(Verilog\.main\.x\):=\!Verilog\.main\.x;$
77
^INIT !Verilog\.main\.x$
8+
^-- Verilog::main.assert.1$
89
^LTLSPEC G F Verilog\.main\.x$
10+
^-- Verilog::main.assert.2$
11+
^-- not translated$
912
^EXIT=0$
1013
^SIGNAL=0$
1114
--

regression/ebmc/smv-netlist/verilog1.sv

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module main(input clk);
77
always @(posedge clk)
88
x = !x;
99

10-
always assert property (always s_eventually x);
10+
assert property (always s_eventually x);
11+
12+
// won't get translated
13+
assert property (x[->5]);
1114

1215
endmodule

src/ebmc/bdd_engine.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void bdd_enginet::compute_counterexample(
412412
CHECK_RETURN(netlist_property != netlist.properties.end());
413413

414414
property.timeframe_literals =
415-
::unwind_property(netlist_property->second, bmc_map);
415+
::unwind_property(netlist_property->second.value(), bmc_map);
416416

417417
// we need the propertyt to fail in one of the timeframes
418418
bvt clause=property.timeframe_literals;
@@ -1053,9 +1053,11 @@ void bdd_enginet::build_BDDs()
10531053
// find the netlist property
10541054
auto netlist_property = netlist.properties.find(property.identifier);
10551055
CHECK_RETURN(netlist_property != netlist.properties.end());
1056+
CHECK_RETURN(netlist_property->second.has_value());
10561057
DATA_INVARIANT(
1057-
netlist_property->second.id() == ID_G, "assumed property must be G");
1058-
auto &p = to_G_expr(netlist_property->second).op();
1058+
netlist_property->second.value().id() == ID_G,
1059+
"assumed property must be G");
1060+
auto &p = to_G_expr(netlist_property->second.value()).op();
10591061
DATA_INVARIANT(
10601062
p.id() == ID_literal, "assumed property must be G literal");
10611063
auto l = to_literal_expr(p).get_literal();

src/ebmc/cegar/bmc_cegar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void bmc_cegart::unwind(
7878
for(auto &property_it : netlist.properties)
7979
{
8080
auto &prop_bv = prop_bv_map[property_it.first];
81-
prop_bv = unwind_property(property_it.second, bmc_map);
81+
prop_bv = unwind_property(property_it.second.value(), bmc_map);
8282

8383
disjuncts.push_back(!solver.land(prop_bv));
8484
}

src/ebmc/property_checker.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ property_checker_resultt bit_level_bmc(
257257
// look up the property in the netlist
258258
auto netlist_property = netlist.properties.find(property.identifier);
259259
CHECK_RETURN(netlist_property != netlist.properties.end());
260+
CHECK_RETURN(netlist_property->second.has_value());
260261

261262
property.timeframe_literals =
262-
::unwind_property(netlist_property->second, bmc_map);
263+
::unwind_property(netlist_property->second.value(), bmc_map);
263264

264265
if(property.is_assumed())
265266
{

src/trans-netlist/netlist.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class netlistt:public aig_plus_constraintst
5656

5757
// Map from property ID to a netlist property,
5858
// which uses literal_exprt.
59-
using propertiest = std::map<irep_idt, exprt>;
59+
// Maps to {} if translation was not possible.
60+
using propertiest = std::map<irep_idt, std::optional<exprt>>;
6061
propertiest properties;
6162
};
6263

src/trans-netlist/smv_netlist.cpp

+14-7
Original file line numberDiff line numberDiff line change
@@ -241,30 +241,37 @@ void smv_netlist(const netlistt &netlist, std::ostream &out)
241241

242242
for(auto &[id, netlist_expr] : netlist.properties)
243243
{
244-
if(is_CTL(netlist_expr))
244+
if(!netlist_expr.has_value())
245+
{
246+
// translation has failed
247+
out << "-- " << id << '\n';
248+
out << "-- not translated\n";
249+
out << '\n';
250+
}
251+
else if(is_CTL(*netlist_expr))
245252
{
246253
out << "-- " << id << '\n';
247254
out << "CTLSPEC ";
248-
print_smv(netlist, out, netlist_expr);
255+
print_smv(netlist, out, *netlist_expr);
249256
out << '\n';
250257
}
251-
else if(is_LTL(netlist_expr))
258+
else if(is_LTL(*netlist_expr))
252259
{
253260
out << "-- " << id << '\n';
254261
out << "LTLSPEC ";
255-
print_smv(netlist, out, netlist_expr);
262+
print_smv(netlist, out, *netlist_expr);
256263
out << '\n';
257264
}
258-
else if(is_SVA(netlist_expr))
265+
else if(is_SVA(*netlist_expr))
259266
{
260267
// Should have been mapped to LTL
261268
DATA_INVARIANT(false, "smv_netlist got SVA");
262269
}
263270
else
264271
{
265-
// neither LTL nor CTL nor SVA
272+
// translated to something we can't print
266273
out << "-- " << id << '\n';
267-
out << "-- not translated\n";
274+
out << "-- cannot output\n";
268275
out << '\n';
269276
}
270277
}

src/trans-netlist/trans_to_netlist.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ void convert_trans_to_netlistt::operator()(
332332
auto netlist_expr_opt = netlist_property(
333333
aig_prop, dest.var_map, property_expr, ns, get_message_handler());
334334

335-
if(netlist_expr_opt.has_value())
336-
dest.properties.emplace(id, netlist_expr_opt.value());
335+
dest.properties.emplace(id, netlist_expr_opt);
337336
}
338337

339338
// find the nondet nodes

0 commit comments

Comments
 (0)