Cost-generic resubstitution algorithm

Header: mockturtle/algorithms/experimental/cost_generic_resub.hpp

This header file defines a resubstitution algorithm to optimize a network with a customized cost function.

/* derive some XAG */
xag_network xag = ...;

cost_generic_resub_params ps;
cost_generic_resub_stats st;

cost_generic_resub( xag, xag_size_cost_function<xag_network>(), ps, &st );
xag = cleanup_dangling( xag );

Customized cost function

template<class Ntk>
struct recursive_cost_functions

(Recursive) customizable cost function

To define a new cost function, you need to first specify how each node contributes to the total cost via the contribution function. Each node is evaluated individually and independently.

If additional (global) information is required to decide a node’s contribution, you may specify them as context. The content stored in the context can be arbitrarily defined (context_t), but the derivation must be recursive. In other words, the context of a node is derived using context propagation function which takes only the context of fanins as input.

Examples of recursive cost functions can be found at: mockturtle/utils/recursive_cost_functions.hpp

Subclassed by mockturtle::t_xag_depth_cost_function< Ntk >, mockturtle::xag_depth_cost_function< Ntk >, mockturtle::xag_size_cost_function< Ntk >

Public Functions

virtual context_t operator()(Ntk const &ntk, node<Ntk> const &n, std::vector<context_t> const &fanin_contexts = {}) const = 0

Context propagation function.

Return the context of a node given fanin contexts.

virtual void operator()(Ntk const &ntk, node<Ntk> const &n, uint32_t &total_cost, context_t const context) const = 0

Contribution function.

Update the total cost using node n and its context.

Algorithm

template<class Ntk, class CostFn>
void mockturtle::experimental::cost_generic_resub(Ntk &ntk, CostFn cost_fn, cost_generic_resub_params const &ps, cost_generic_resub_stats *pst = nullptr)

Cost-generic resubstitution algorithm.

This algorithm creates a reconvergence-driven window for each node in the network, collects divisors, and builds the resynthesis problem. A search core then collects all the resubstitution candidates with the same functionality as the target. The candidate with the lowest cost will then replace the MFFC of the window.

Parameters:
  • ntk – Network

  • cost_fn – Customized cost function

  • ps – Optimization params

  • pst – Optimization statistics