Refactoring¶
Header: mockturtle/algorithms/refactoring.hpp
The following example shows how to refactor an MIG using the Akers synthesis method.
/* derive some MIG */
mig_network mig = ...;
/* node resynthesis */
akers_resynthesis resyn;
refactoring( mig, resyn );
mig = cleanup_dangling( mig );
It is possible to change the cost function of nodes in refactoring. Here is an example, in which the cost function does not account for XOR gates in a network. This may be helpful in logic synthesis addressing cryptography applications where XOR gates are considered “for free”.
template<class Ntk>
struct free_xor_cost
{
uint32_t operator()( Ntk const& ntk, node<Ntk> const& n ) const
{
return ntk.is_xor( n ) ? 0 : 1;
}
};
SomeResynthesisClass resyn;
refactoring( ntk, resyn, free_xor_cost<Ntk>());
Parameters and statistics¶
-
struct mockturtle::refactoring_params¶
Parameters for refactoring.
The data structure
refactoring_params
holds configurable parameters with default arguments forrefactoring
.
-
struct mockturtle::refactoring_stats¶
Statistics for refactoring.
The data structure
refactoring_stats
provides data collected by runningrefactoring
.Public Members
Algorithm¶
-
template<class Ntk, class RefactoringFn, class NodeCostFn = unit_cost<Ntk>>
void mockturtle::refactoring(Ntk &ntk, RefactoringFn &&refactoring_fn, refactoring_params const &ps = {}, refactoring_stats *pst = nullptr, NodeCostFn const &cost_fn = {})¶ Boolean refactoring.
This algorithm performs refactoring by collapsing maximal fanout-free cones (MFFCs) into truth tables and recreating a new network structure from it. The algorithm performs changes directly in the input network and keeps the substituted structures dangling in the network. They can be cleaned up using the
cleanup_dangling
algorithm.The refactoring function must be of type
NtkDest::signal(NtkDest&, kitty::dynamic_truth_table const&, LeavesIterator, LeavesIterator)
whereLeavesIterator
can be dereferenced to aNtkDest::signal
. The last two parameters compose an iterator pair where the distance matches the number of variables of the truth table that is passed as second parameter. There are some refactoring algorithms in the foldermockturtle/algorithms/node_resyntesis
, since the resynthesis functions have the same signature.Required network functions:
get_node
size
make_signal
foreach_gate
substitute_node
clear_visited
clear_values
fanout_size
set_value
foreach_node
- Parameters
ntk – Input network (will be changed in-place)
refactoring_fn – Refactoring function
ps – Refactoring params
pst – Refactoring statistics
cost_fn – Node cost function (a functor with signature
uint32_t(Ntk const&, node<Ntk> const&)
)
Rewriting functions¶
One can use resynthesis functions that can be passed to node_resynthesis, see Resynthesis functions.