Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d7baae4
mig resub: bottom up approach
lee30sonia Sep 26, 2020
55d3571
Merge branch 'master' into lee30sonia/mig_resub
lee30sonia Oct 2, 2020
66b8ec6
top-down: first try
lee30sonia Oct 9, 2020
f852c74
caching; avoid being stuck; choosing expansion position; separate two…
lee30sonia Oct 26, 2020
f4604fe
use kitty::hash; NPN enumeration
lee30sonia Oct 26, 2020
83d57f1
try all starting points at the first node
lee30sonia Oct 26, 2020
033426d
Merge branch 'master' into lee30sonia/mig_resub
lee30sonia Nov 13, 2020
2afc891
several improvements
lee30sonia Nov 15, 2020
efdc5d7
fix performance bug
lee30sonia Nov 16, 2020
00aab29
use new mig_resub_engine in the resub flow
lee30sonia Dec 17, 2020
5273789
updating cares; easy refine; use index_list
lee30sonia Dec 17, 2020
ad2af34
port kitty changes
lee30sonia Dec 22, 2020
a5d7af4
re-implementation of akers synthesis
lee30sonia Dec 22, 2020
de0d1d5
adjust interface
lee30sonia Dec 22, 2020
05eb5cc
Merge branch 'master' into lee30sonia/mig_resub
lee30sonia Dec 23, 2020
e36845b
unify interfaces
lee30sonia Dec 30, 2020
19dba9b
rename files
lee30sonia Dec 30, 2020
6b6f0aa
Delete mig_resub_engine.cpp
lee30sonia Dec 30, 2020
ee8a191
rename & add tests
lee30sonia Dec 30, 2020
ce9ded2
cleanup
lee30sonia Dec 30, 2020
549bf31
typo in index_list
lee30sonia Dec 30, 2020
6bdafa6
try to see if the problem comes from the new tests
lee30sonia Dec 31, 2020
a9a41fb
debug
lee30sonia Dec 31, 2020
d2fae0f
debug
lee30sonia Dec 31, 2020
1b47a63
debug & cleanup
lee30sonia Dec 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions include/mockturtle/algorithms/mig_resub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <mockturtle/algorithms/resubstitution.hpp>
#include <mockturtle/networks/mig.hpp>
#include <mockturtle/algorithms/mig_resyn_engines.hpp>
#include <mockturtle/utils/index_list.hpp>

namespace kitty
{
Expand Down Expand Up @@ -643,6 +645,62 @@ struct mig_resub_functor
binate_divisors bdivs;
}; /* mig_resub_functor */

template<typename Ntk, typename Simulator, typename TTcare, typename Engine = mig_resyn_engine<kitty::partial_truth_table>>
struct mig_resub_functor_new
{
public:
using node = mig_network::node;
using signal = mig_network::signal;
using stats = mig_resub_stats;

public:
explicit mig_resub_functor_new( Ntk& ntk, Simulator const& sim, std::vector<node> const& divs, uint32_t num_divs, stats& st )
: ntk( ntk )
, sim( sim )
, tts( ntk )
, divs( divs )
, st( st )
{
assert( divs.size() == num_divs ); (void)num_divs;
div_signals.reserve( divs.size() );
}

std::optional<signal> operator()( node const& root, TTcare care, uint32_t required, uint32_t max_inserts, uint32_t potential_gain, uint32_t& real_gain )
{
(void)care; (void)required;
kitty::partial_truth_table root_tt;
root_tt = sim.get_tt( sim.get_phase( root ) ? !ntk.make_signal( root ) : ntk.make_signal( root ) );
Engine engine( root_tt );
for ( auto const& d : divs )
{
div_signals.emplace_back( sim.get_phase( d ) ? !ntk.make_signal( d ) : ntk.make_signal( d ) );
tts[d] = sim.get_tt( div_signals.back() );
}
engine.add_divisors( divs.begin(), divs.end(), tts );

auto const res = engine.compute_function( std::min( potential_gain - 1, max_inserts ) );
if ( res )
{
signal ret;
real_gain = potential_gain - (*res).num_gates();
insert( ntk, div_signals.begin(), div_signals.end(), *res, [&]( signal const& s ){ ret = s; } );
return ret;
}
else
{
return std::nullopt;
}
}

private:
Ntk& ntk;
Simulator const& sim;
unordered_node_map<kitty::partial_truth_table, Ntk> tts;
std::vector<node> const& divs;
std::vector<signal> div_signals;
stats& st;
};

/*! \brief MIG-specific resubstitution algorithm.
*
* This algorithms iterates over each node, creates a
Expand Down Expand Up @@ -707,7 +765,7 @@ void mig_resubstitution( Ntk& ntk, resubstitution_params const& ps = {}, resubst
{
using truthtable_t = kitty::static_truth_table<8u>;
using truthtable_dc_t = kitty::dynamic_truth_table;
using resub_impl_t = detail::resubstitution_impl<Ntk, typename detail::window_based_resub_engine<Ntk, truthtable_t, truthtable_dc_t, mig_resub_functor<Ntk, typename detail::window_simulator<Ntk, truthtable_t>, truthtable_dc_t>>>;
using resub_impl_t = detail::resubstitution_impl<Ntk, typename detail::window_based_resub_engine<Ntk, truthtable_t, truthtable_dc_t, mig_resub_functor_new<Ntk, typename detail::window_simulator<Ntk, truthtable_t>, truthtable_dc_t>>>;

resubstitution_stats st;
typename resub_impl_t::engine_st_t engine_st;
Expand All @@ -732,7 +790,7 @@ void mig_resubstitution( Ntk& ntk, resubstitution_params const& ps = {}, resubst
{
using truthtable_t = kitty::dynamic_truth_table;
using truthtable_dc_t = kitty::dynamic_truth_table;
using resub_impl_t = detail::resubstitution_impl<Ntk, typename detail::window_based_resub_engine<Ntk, truthtable_t, truthtable_dc_t, mig_resub_functor<Ntk, typename detail::window_simulator<Ntk, truthtable_t>, truthtable_dc_t>>>;
using resub_impl_t = detail::resubstitution_impl<Ntk, typename detail::window_based_resub_engine<Ntk, truthtable_t, truthtable_dc_t, mig_resub_functor_new<Ntk, typename detail::window_simulator<Ntk, truthtable_t>, truthtable_dc_t>>>;

resubstitution_stats st;
typename resub_impl_t::engine_st_t engine_st;
Expand Down
Loading