Skip to content

corner case bug fixes #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 15 additions & 12 deletions include/mockturtle/algorithms/window_rewriting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class window_rewriting_impl
/* ensure that no dead nodes are reachable */
assert( count_reachable_dead_nodes( ntk ) == 0u );

bool fSuccess = true;
std::list<std::pair<node, signal>> substitutions;
insert_ntk( ntk, std::begin( signals ), std::end( signals ), win,
[&]( signal const& _new ) {
Expand All @@ -327,26 +328,28 @@ class window_rewriting_impl

/* ensure that _old is not in the TFI of _new */
// assert( !is_contained_in_tfi( ntk, ntk.get_node( _new ), ntk.get_node( _old ) ) );
if ( ps.filter_cyclic_substitutions &&
if ( fSuccess && ps.filter_cyclic_substitutions &&
call_with_stopwatch( st.time_window, [&]() { return is_contained_in_tfi( ntk, ntk.get_node( _new ), ntk.get_node( _old ) ); } ) )
{
std::cout << "undo resubstitution " << ntk.get_node( _old ) << std::endl;
substitutions.emplace_back( std::make_pair( ntk.get_node( _old ), ntk.is_complemented( _old ) ? !_new : _new ) );
for ( auto it = std::rbegin( substitutions ); it != std::rend( substitutions ); ++it )
{
if ( ntk.fanout_size( ntk.get_node( it->second ) ) == 0u )
{
ntk.take_out_node( ntk.get_node( it->second ) );
}
}
substitutions.clear();
return false;
fSuccess = false;
}

substitutions.emplace_back( std::make_pair( ntk.get_node( _old ), ntk.is_complemented( _old ) ? !_new : _new ) );
return true;
} );

if ( !fSuccess )
{
for ( auto it = std::rbegin( substitutions ); it != std::rend( substitutions ); ++it )
{
if ( ntk.fanout_size( ntk.get_node( it->second ) ) == 0u )
{
ntk.take_out_node( ntk.get_node( it->second ) );
}
}
substitutions.clear();
}

/* ensure that no dead nodes are reachable */
assert( count_reachable_dead_nodes( ntk ) == 0u );
substitute_nodes( substitutions );
Expand Down
8 changes: 4 additions & 4 deletions include/mockturtle/utils/window_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,10 @@ void levelized_expand_towards_tfo( Ntk const& ntk, std::vector<typename Ntk::nod

for ( uint32_t index = 0u; index < used.size(); ++index )
{
std::vector<node>& level = levels.at( used[index] );
for ( auto j = 0u; j < level.size(); ++j )
int current_index = used[index];
for ( auto j = 0u; j < levels[current_index].size(); ++j )
{
ntk.foreach_fanout( level[j], [&]( node const& fo, uint64_t index ) {
ntk.foreach_fanout( levels[current_index][j], [&]( node const& fo, uint64_t index ) {
/* avoid getting stuck on nodes with many fanouts */
if ( index == MAX_FANOUTS )
{
Expand Down Expand Up @@ -768,7 +768,7 @@ void levelized_expand_towards_tfo( Ntk const& ntk, std::vector<typename Ntk::nod
return true;
} );
}
level.clear();
levels[current_index].clear();
}
}

Expand Down
Loading