13
13
#include < util/std_expr.h>
14
14
15
15
#include < ebmc/ebmc_error.h>
16
- #include < solvers/flattening/boolbv.h>
17
16
#include < solvers/prop/literal_expr.h>
18
17
#include < temporal-logic/temporal_logic.h>
19
18
#include < verilog/sva_expr.h>
20
19
20
+ #include " netlist_boolbv.h"
21
+
21
22
#include < cassert>
22
23
#include < cstdlib>
23
24
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
-
58
25
/* ******************************************************************\
59
26
60
27
Function: instantiate_constraint
@@ -74,7 +41,7 @@ void instantiate_constraint(
74
41
const namespacet &ns,
75
42
message_handlert &message_handler)
76
43
{
77
- instantiate_var_mapt i (ns, solver, message_handler, var_map);
44
+ netlist_boolbvt i (ns, solver, message_handler, var_map);
78
45
79
46
try
80
47
{
@@ -113,7 +80,7 @@ literalt instantiate_convert(
113
80
const namespacet &ns,
114
81
message_handlert &message_handler)
115
82
{
116
- instantiate_var_mapt i (ns, solver, message_handler, var_map);
83
+ netlist_boolbvt i (ns, solver, message_handler, var_map);
117
84
118
85
try
119
86
{
@@ -153,7 +120,7 @@ void instantiate_convert(
153
120
message_handlert &message_handler,
154
121
bvt &bv)
155
122
{
156
- instantiate_var_mapt i (ns, solver, message_handler, var_map);
123
+ netlist_boolbvt i (ns, solver, message_handler, var_map);
157
124
158
125
try
159
126
{
@@ -175,107 +142,6 @@ void instantiate_convert(
175
142
176
143
/* ******************************************************************\
177
144
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
-
279
145
Function: netlist_property
280
146
281
147
Inputs:
0 commit comments