Skip to content

Commit 69a7c0d

Browse files
committed
generate stable AIGs
To remove nondeterminism when generating AIGs, sort the identifiers before allocating netlist nodes to them.
1 parent efa2b5f commit 69a7c0d

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
s_until1.sv
33
--smv-netlist
4-
^LTLSPEC \(\!node144\) U node151$
5-
^LTLSPEC TRUE U node158$
4+
^LTLSPEC \(\!node144\) U node51$
5+
^LTLSPEC TRUE U node151$
66
^EXIT=0$
77
^SIGNAL=0$
88
--

src/trans-netlist/trans_to_netlist.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,22 @@ void convert_trans_to_netlistt::map_vars(
264264
}
265265
};
266266

267-
for_all_module_symbols(symbol_table, module, update_dest_var_map);
267+
// get the symbols in the given module
268+
std::vector<const symbolt *> module_symbols;
269+
270+
for(const auto &symbol_it : symbol_table.symbols)
271+
if(symbol_it.second.module == module)
272+
module_symbols.push_back(&symbol_it.second);
273+
274+
// we sort them to get a stable netlist
275+
std::sort(
276+
module_symbols.begin(),
277+
module_symbols.end(),
278+
[](const symbolt *a, const symbolt *b)
279+
{ return a->name.compare(b->name) < 0; });
280+
281+
for(auto symbol_ptr : module_symbols)
282+
update_dest_var_map(*symbol_ptr);
268283
}
269284

270285
/*******************************************************************\

src/util/ebmc_util.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@
1515

1616
#include <solvers/sat/cnf.h>
1717

18-
template <typename F>
19-
void for_all_module_symbols(const symbol_tablet &symbol_table,
20-
const irep_idt &module_name, F &&f) {
21-
using symbol_pairt = typename symbol_tablet::iteratort::value_type;
22-
std::for_each(symbol_table.begin(), symbol_table.end(),
23-
[&module_name, &f](const symbol_pairt &symbol_pair) {
24-
const auto &symbol = symbol_pair.second;
25-
if (symbol.module == module_name)
26-
f(symbol);
27-
});
28-
}
29-
3018
// This function is legacy, and will be gradually removed.
3119
// Consider to_integer(constant_exprt, mp_integer &) or numerical_cast<mp_integer>(...).
3220
inline bool to_integer_non_constant(const exprt &expr, mp_integer &int_value)

0 commit comments

Comments
 (0)