Skip to content

Commit f885b0d

Browse files
authored
Merge pull request #1100 from diffblue/aig_prop_constraintt-member
make the `aig_prop_constraintt` a member `convert_trans_to_netlistt`
2 parents a2468e7 + 685ece3 commit f885b0d

File tree

1 file changed

+36
-40
lines changed

1 file changed

+36
-40
lines changed

src/trans-netlist/trans_to_netlist.cpp

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class convert_trans_to_netlistt:public messaget
4646
: messaget(_message_handler),
4747
symbol_table(_symbol_table),
4848
ns(_symbol_table),
49-
dest(_dest)
49+
dest(_dest),
50+
aig_prop(dest, _message_handler)
5051
{
5152
}
5253

@@ -59,7 +60,8 @@ class convert_trans_to_netlistt:public messaget
5960
symbol_table_baset &symbol_table;
6061
const namespacet ns;
6162
netlistt &dest;
62-
63+
aig_prop_constraintt aig_prop;
64+
6365
literalt new_input();
6466
std::size_t input_counter = 0;
6567
irep_idt mode;
@@ -132,17 +134,13 @@ class convert_trans_to_netlistt:public messaget
132134
std::size_t lhs_from, std::size_t lhs_to,
133135
rhs_entryt &rhs_entry);
134136

135-
literalt convert_rhs(const rhst &rhs, propt &prop);
137+
literalt convert_rhs(const rhst &);
136138

137-
void finalize_lhs(lhs_mapt::iterator, propt &prop);
139+
void finalize_lhs(lhs_mapt::iterator);
138140

139-
void convert_lhs_rec(
140-
const exprt &expr,
141-
std::size_t from,
142-
std::size_t to,
143-
propt &prop);
141+
void convert_lhs_rec(const exprt &expr, std::size_t from, std::size_t to);
144142

145-
void convert_constraints(propt &prop);
143+
void convert_constraints();
146144

147145
void map_vars(
148146
const irep_idt &module,
@@ -294,9 +292,6 @@ void convert_trans_to_netlistt::operator()(
294292

295293
mode = ns.lookup(module).mode;
296294

297-
// build the net-list
298-
aig_prop_constraintt aig_prop(dest, get_message_handler());
299-
300295
// extract constraints from transition relation
301296
add_constraint(trans.invar());
302297
add_constraint(trans.trans());
@@ -306,13 +301,15 @@ void convert_trans_to_netlistt::operator()(
306301
it=lhs_map.begin();
307302
it!=lhs_map.end();
308303
it++)
309-
finalize_lhs(it, aig_prop);
310-
304+
{
305+
finalize_lhs(it);
306+
}
307+
311308
// finish the var_map
312309
dest.var_map.build_reverse_map();
313310

314311
// do the remaining transition constraints
315-
convert_constraints(aig_prop);
312+
convert_constraints();
316313

317314
dest.constraints.insert(
318315
dest.constraints.end(), invar_constraints.begin(), invar_constraints.end());
@@ -370,7 +367,7 @@ Function: convert_trans_to_netlistt::convert_constraints
370367
371368
\*******************************************************************/
372369

373-
void convert_trans_to_netlistt::convert_constraints(propt &prop)
370+
void convert_trans_to_netlistt::convert_constraints()
374371
{
375372
invar_constraints.reserve(
376373
transition_constraints.size() + constraint_list.size());
@@ -383,8 +380,8 @@ void convert_trans_to_netlistt::convert_constraints(propt &prop)
383380
it!=constraint_list.end();
384381
it++)
385382
{
386-
literalt l=
387-
instantiate_convert(prop, dest.var_map, *it, ns, get_message_handler());
383+
literalt l = instantiate_convert(
384+
aig_prop, dest.var_map, *it, ns, get_message_handler());
388385

389386
if(has_subexpr(*it, ID_next_symbol))
390387
transition_constraints.push_back(l);
@@ -405,9 +402,7 @@ Function: convert_trans_to_netlistt::finalize_lhs
405402
406403
\*******************************************************************/
407404

408-
void convert_trans_to_netlistt::finalize_lhs(
409-
lhs_mapt::iterator lhs_it,
410-
propt &prop)
405+
void convert_trans_to_netlistt::finalize_lhs(lhs_mapt::iterator lhs_it)
411406
{
412407
lhs_entryt &lhs=lhs_it->second;
413408

@@ -437,7 +432,7 @@ void convert_trans_to_netlistt::finalize_lhs(
437432
// do first one by setting the node appropriately
438433

439434
lhs.in_progress=true;
440-
lhs.l=convert_rhs(lhs.equal_to.front(), prop);
435+
lhs.l = convert_rhs(lhs.equal_to.front());
441436

442437
if(lhs.var->is_latch())
443438
lhs.bit->next=lhs.l;
@@ -456,10 +451,9 @@ void convert_trans_to_netlistt::finalize_lhs(
456451
{
457452
// first one? -- already done
458453
if(it==lhs.equal_to.begin()) continue;
459-
460-
literalt l_rhs=convert_rhs(*it, prop);
461-
transition_constraints.push_back(
462-
prop.lequal(lhs.l, l_rhs));
454+
455+
literalt l_rhs = convert_rhs(*it);
456+
transition_constraints.push_back(aig_prop.lequal(lhs.l, l_rhs));
463457
}
464458
}
465459

@@ -477,8 +471,8 @@ Function: convert_trans_to_netlistt::convert_lhs_rec
477471

478472
void convert_trans_to_netlistt::convert_lhs_rec(
479473
const exprt &expr,
480-
std::size_t from, std::size_t to,
481-
propt &prop)
474+
std::size_t from,
475+
std::size_t to)
482476
{
483477
PRECONDITION(from <= to);
484478

@@ -499,8 +493,8 @@ void convert_trans_to_netlistt::convert_lhs_rec(
499493

500494
// we only need to do wires
501495
if(!it->second.var->is_wire()) return;
502-
503-
finalize_lhs(it, prop);
496+
497+
finalize_lhs(it);
504498
}
505499

506500
return;
@@ -512,7 +506,7 @@ void convert_trans_to_netlistt::convert_lhs_rec(
512506
to_extractbit_expr(expr).index(), i)) // constant?
513507
{
514508
from = i.to_ulong();
515-
convert_lhs_rec(to_extractbit_expr(expr).src(), from, from, prop);
509+
convert_lhs_rec(to_extractbit_expr(expr).src(), from, from);
516510
return;
517511
}
518512
}
@@ -528,7 +522,7 @@ void convert_trans_to_netlistt::convert_lhs_rec(
528522
from = new_from.to_ulong();
529523
to = new_to.to_ulong();
530524

531-
convert_lhs_rec(to_extractbits_expr(expr).src(), from, to, prop);
525+
convert_lhs_rec(to_extractbits_expr(expr).src(), from, to);
532526
return;
533527
}
534528
}
@@ -548,7 +542,7 @@ void convert_trans_to_netlistt::convert_lhs_rec(
548542
if(width==0)
549543
continue;
550544

551-
convert_lhs_rec(*it, 0, width-1, prop);
545+
convert_lhs_rec(*it, 0, width - 1);
552546
}
553547
}
554548

@@ -564,24 +558,26 @@ Function: convert_trans_to_netlistt::convert_rhs
564558
565559
\*******************************************************************/
566560

567-
literalt convert_trans_to_netlistt::convert_rhs(
568-
const rhst &rhs,
569-
propt &prop)
561+
literalt convert_trans_to_netlistt::convert_rhs(const rhst &rhs)
570562
{
571563
rhs_entryt &rhs_entry=*rhs.entry;
572564

573565
// done already?
574566
if(!rhs_entry.converted)
575567
{
576568
// get all lhs symbols this depends on
577-
convert_lhs_rec(rhs_entry.expr, 0, rhs_entry.width-1, prop);
569+
convert_lhs_rec(rhs_entry.expr, 0, rhs_entry.width - 1);
578570

579571
rhs_entry.converted=true;
580572

581573
// now we can convert
582574
instantiate_convert(
583-
prop, dest.var_map, rhs_entry.expr, ns,
584-
get_message_handler(), rhs_entry.bv);
575+
aig_prop,
576+
dest.var_map,
577+
rhs_entry.expr,
578+
ns,
579+
get_message_handler(),
580+
rhs_entry.bv);
585581

586582
DATA_INVARIANT(rhs_entry.bv.size() == rhs_entry.width, "bit-width match");
587583
}

0 commit comments

Comments
 (0)