panhongyang0 2024-05-10 16:36:43 +08:00
parent a29f90f9f2
commit 577a280b2e
3 changed files with 145 additions and 0 deletions

20
src/core/balance.rst Normal file
View File

@ -0,0 +1,20 @@
Balance
=============
**Header:** ``mockturtle/algorithms/balancing.hpp``
Parameters
~~~~~~~~~~
.. doxygenstruct:: mockturtle::aig_balancing_params
:members:
Algorithm
~~~~~~~~~
.. doxygenfunction:: mockturtle::aig_balance
Balancing of a logic network
This function implements a dynamic-programming and cut-enumeration based balancing algorithm.
It returns a new network of the same type and performs generic balancing by providing a rebalancing function.

80
src/core/resub.rst Normal file
View File

@ -0,0 +1,80 @@
Resub
=============
**Header:** ``mockturtle/algorithms/resubstitution.hpp``
Several resubstitution algorithms are implemented and can be called directly, including:
- ``default_resubstitution`` does functional reduction within a window.
Structure
~~~~~~~~~
In addition to the example algorithms listed above, custom resubstitution algorithms can also be composed.
**Top level**
First, the top-level framework ``detail::resubstitution_impl`` is built-up with a resubstitution engine and a divisor collector.
.. doxygenclass:: mockturtle::detail::resubstitution_impl
.. doxygenfunction:: mockturtle::detail::resubstitution_impl::resubstitution_impl
**ResubEngine**
There are two resubstitution engines implemented: `window_based_resub_engine` and `simulation_based_resub_engine`.
.. doxygenclass:: mockturtle::detail::window_based_resub_engine
.. doxygenclass:: mockturtle::detail::simulation_based_resub_engine
**DivCollector**
Currently, there is only one implementation:
.. doxygenclass:: mockturtle::detail::default_divisor_collector
**Example**
The following example shows how to compose a customized resubstitution algorithm.
.. code-block:: c++
/* derive some AIG */
aig_network aig = ...;
/* prepare the needed views */
using resub_view_t = fanout_view<depth_view<aig_network>>;
depth_view<aig_network> depth_view{aig};
resub_view_t resub_view{depth_view};
/* compose the resubstitution framework */
using validator_t = circuit_validator<Ntk, bill::solvers::bsat2, false, true, false>;
using functor_t = typename detail::sim_aig_resub_functor<resub_view_t, validator_t>;
using engine_t = typename detail::simulation_based_resub_engine<resub_view_t, validator_t, functor_t>;
using resub_impl_t = typename detail::resubstitution_impl<resub_view_t, engine_t>;
/* statistics objects */
resubstitution_stats st;
typename resub_impl_t::engine_st_t engine_st;
typename resub_impl_t::collector_st_t collector_st;
/* instantiate the framework and run it */
resubstitution_params ps;
resub_impl_t p( resub_view, ps, st, engine_st, collector_st );
p.run();
/* report statistics */
st.report();
collector_st.report();
engine_st.report();
Detailed statistics
~~~~~~~~~~~~~~~~~~~
.. doxygenstruct:: mockturtle::detail::window_resub_stats
:members:
.. doxygenstruct:: mockturtle::detail::sim_resub_stats
:members:

45
src/core/rewrite.rst Normal file
View File

@ -0,0 +1,45 @@
Rewrite
=============
**Header:** ``mockturtle/algorithms/cut_rewriting.hpp``
The following example shows how to rewrite an MIG using precomputed optimum networks. In this case the maximum number of variables for a node function is 4.
It is possible to change the cost function of nodes in cut rewriting. Here is
an example, in which the cost function only accounts for AND gates in a network,
which corresponds to the multiplicative complexity of a function.
.. code-block:: c++
template<class Ntk>
struct mc_cost
{
uint32_t operator()( Ntk const& ntk, node<Ntk> const& n ) const
{
return ntk.is_and( n ) ? 1 : 0;
}
};
SomeResynthesisClass resyn;
ntk = cut_rewriting<SomeResynthesisClass, mc_cost>( ntk, resyn );
Parameters and statistics
~~~~~~~~~~~~~~~~~~~~~~~~~
.. doxygenstruct:: mockturtle::cut_rewriting_params
:members:
.. doxygenstruct:: mockturtle::cut_rewriting_stats
:members:
Algorithm
~~~~~~~~~
.. doxygenfunction:: mockturtle::cut_rewriting
.. doxygenfunction:: mockturtle::cut_rewriting_with_compatibility_graph
Rewriting functions
~~~~~~~~~~~~~~~~~~~
One can use resynthesis functions that can be passed to `node_resynthesis`, see
:ref:`node_resynthesis_functions`.