1313#include < util/std_expr.h>
1414
1515#include < ebmc/ebmc_error.h>
16- #include < solvers/flattening/boolbv.h>
1716#include < solvers/prop/literal_expr.h>
1817#include < temporal-logic/temporal_logic.h>
1918#include < verilog/sva_expr.h>
2019
20+ #include " netlist_boolbv.h"
21+
2122#include < cassert>
2223#include < cstdlib>
2324
24- /* ******************************************************************\
25-
26- Class: instantiate_var_mapt
27-
28- Purpose:
29-
30- \*******************************************************************/
31-
32- class instantiate_var_mapt :public boolbvt
33- {
34- public:
35- instantiate_var_mapt (const namespacet &_ns, propt &solver,
36- message_handlert &message_handler,
37- const var_mapt &_var_map)
38- : boolbvt(_ns, solver, message_handler), var_map(_var_map) {}
39-
40- typedef boolbvt SUB;
41-
42- // overloading
43- using boolbvt::get_literal;
44-
45- virtual literalt convert_bool (const exprt &expr);
46- virtual literalt get_literal (const std::string &symbol, const unsigned bit);
47- virtual bvt convert_bitvector (const exprt &expr);
48-
49- protected:
50- // disable smart variable allocation,
51- // we already have literals for all variables
52- virtual bool boolbv_set_equality_to_true (const equal_exprt &expr) { return true ; }
53- virtual bool set_equality_to_true (const equal_exprt &expr) { return true ; }
54-
55- const var_mapt &var_map;
56- };
57-
5825/* ******************************************************************\
5926
6027Function: instantiate_constraint
@@ -74,7 +41,7 @@ void instantiate_constraint(
7441 const namespacet &ns,
7542 message_handlert &message_handler)
7643{
77- instantiate_var_mapt i (ns, solver, message_handler, var_map);
44+ netlist_boolbvt i (ns, solver, message_handler, var_map);
7845
7946 try
8047 {
@@ -113,7 +80,7 @@ literalt instantiate_convert(
11380 const namespacet &ns,
11481 message_handlert &message_handler)
11582{
116- instantiate_var_mapt i (ns, solver, message_handler, var_map);
83+ netlist_boolbvt i (ns, solver, message_handler, var_map);
11784
11885 try
11986 {
@@ -153,7 +120,7 @@ void instantiate_convert(
153120 message_handlert &message_handler,
154121 bvt &bv)
155122{
156- instantiate_var_mapt i (ns, solver, message_handler, var_map);
123+ netlist_boolbvt i (ns, solver, message_handler, var_map);
157124
158125 try
159126 {
@@ -175,107 +142,6 @@ void instantiate_convert(
175142
176143/* ******************************************************************\
177144
178- Function: instantiate_var_mapt::convert_bool
179-
180- Inputs:
181-
182- Outputs:
183-
184- Purpose:
185-
186- \*******************************************************************/
187-
188- literalt instantiate_var_mapt::convert_bool (const exprt &expr)
189- {
190- if (expr.id ()==ID_symbol || expr.id ()==ID_next_symbol)
191- {
192- bvt result=convert_bitvector (expr);
193-
194- if (result.size ()!=1 )
195- throw " expected one-bit result" ;
196-
197- return result[0 ];
198- }
199- else if (expr.id ()==ID_sva_overlapped_implication)
200- {
201- // same as regular implication
202- auto &sva_overlapped_implication = to_sva_overlapped_implication_expr (expr);
203- return prop.limplies (
204- convert_bool (sva_overlapped_implication.lhs ()),
205- convert_bool (sva_overlapped_implication.rhs ()));
206- }
207- else if (expr.id () == ID_verilog_past)
208- {
209- throw ebmc_errort ().with_location (expr.source_location ())
210- << " no support for $past when using AIG backends" ;
211- }
212-
213- return SUB::convert_bool (expr);
214- }
215-
216- /* ******************************************************************\
217-
218- Function: instantiate_var_mapt::convert_bitvector
219-
220- Inputs:
221-
222- Outputs:
223-
224- Purpose:
225-
226- \*******************************************************************/
227-
228- bvt instantiate_var_mapt::convert_bitvector (const exprt &expr)
229- {
230- if (expr.id ()==ID_symbol || expr.id ()==ID_next_symbol)
231- {
232- bool next=(expr.id ()==ID_next_symbol);
233- const irep_idt &identifier=expr.get (ID_identifier);
234-
235- std::size_t width=boolbv_width (expr.type ());
236-
237- if (width!=0 )
238- {
239- bvt bv;
240- bv.resize (width);
241-
242- for (std::size_t i=0 ; i<width; i++)
243- bv[i]=next?var_map.get_next (identifier, i)
244- :var_map.get_current (identifier, i);
245-
246- return bv;
247- }
248- }
249- else if (expr.id () == ID_verilog_past)
250- {
251- throw ebmc_errort ().with_location (expr.source_location ())
252- << " no support for $past when using AIG backends" ;
253- }
254-
255- return SUB::convert_bitvector (expr);
256- }
257-
258- /* ******************************************************************\
259-
260- Function: instantiate_var_mapt::get_literal
261-
262- Inputs:
263-
264- Outputs:
265-
266- Purpose:
267-
268- \*******************************************************************/
269-
270- literalt instantiate_var_mapt::get_literal (
271- const std::string &symbol,
272- const unsigned bit)
273- {
274- return var_map.get_current (symbol, bit);
275- }
276-
277- /* ******************************************************************\
278-
279145Function: netlist_property
280146
281147 Inputs:
0 commit comments