diff --git a/include/mockturtle/networks/aqfp.hpp b/include/mockturtle/networks/aqfp.hpp index 087fad2f2..e785e0788 100644 --- a/include/mockturtle/networks/aqfp.hpp +++ b/include/mockturtle/networks/aqfp.hpp @@ -28,6 +28,7 @@ \brief AQFP network implementation \author Dewmini Marakkalage + \author Alessandro Tempia Calvino */ #pragma once @@ -521,23 +522,27 @@ class aqfp_network std::vector old_children; - for ( auto i = 0u; i <= node.children.size(); ++i ) + bool replacement = false; + for ( size_t i = 0u; i < node.children.size(); ++i ) { - if ( i == node.children.size() ) - { - return std::nullopt; - } - old_children.push_back( signal{ node.children[i] } ); if ( node.children[i].index == old_node ) { node.children[i] = node.children[i].weight ? !new_signal : new_signal; - new_signal.complement ^= node.children[i].weight; + replacement = true; + + // update the reference counter of the new signal + _storage->nodes[new_signal.index].data[0].h1++; } } - /* TODO: Do the simplifications if possible */ + if ( !replacement ) + { + return std::nullopt; + } + + /* TODO: Do the simplifications if possible and ordering */ for ( auto const& fn : _events->on_modified ) { diff --git a/include/mockturtle/views/binding_view.hpp b/include/mockturtle/views/binding_view.hpp index f44955990..7326c21da 100644 --- a/include/mockturtle/views/binding_view.hpp +++ b/include/mockturtle/views/binding_view.hpp @@ -239,7 +239,7 @@ class binding_view : public Ntk { float tot_gate_area = gates_profile[i] * _library[i].area; - os << fmt::format( "[i] {:<15}", _library[i].name ) + os << fmt::format( "[i] {:<25}", _library[i].name ) << fmt::format( "\t Instance = {:>10d}", gates_profile[i] ) << fmt::format( "\t Area = {:>12.2f}", tot_gate_area ) << fmt::format( " {:>8.2f} %\n", tot_gate_area / area * 100 ); @@ -248,7 +248,7 @@ class binding_view : public Ntk } } - os << fmt::format( "[i] {:<15}", "TOTAL" ) + os << fmt::format( "[i] {:<25}", "TOTAL" ) << fmt::format( "\t Instance = {:>10d}", tot_instances ) << fmt::format( "\t Area = {:>12.2f} 100.00 %\n", area ); } diff --git a/test/algorithms/akers_synthesis.cpp b/test/algorithms/akers_synthesis.cpp index 7077f0dc1..e9fb3ce91 100644 --- a/test/algorithms/akers_synthesis.cpp +++ b/test/algorithms/akers_synthesis.cpp @@ -89,6 +89,8 @@ TEST_CASE( "Check Akers for MAJ-5 in XMG", "[akers_synthesis]" ) TEST_CASE( "Check Akers for random - 4 inputs", "[akers_synthesis]" ) { + std::array tts = { "d5d0", "fe52", "ad1b", "401a", "79e2" }; + for ( auto y = 0; y < 5; y++ ) { std::vector xs{6, kitty::dynamic_truth_table( 4 )}; @@ -97,7 +99,7 @@ TEST_CASE( "Check Akers for random - 4 inputs", "[akers_synthesis]" ) kitty::create_nth_var( xs[4], 2 ); kitty::create_nth_var( xs[5], 3 ); - create_random( xs[0] ); + create_from_hex_string( xs[0], tts[y] ); for ( auto i = 0u; i < unsigned( xs[0].num_bits() ); i++ ) { @@ -134,6 +136,8 @@ TEST_CASE( "Check Akers for random - 4 inputs", "[akers_synthesis]" ) TEST_CASE( "Check Akers for random - 5 inputs", "[akers_synthesis]" ) { + std::array tts = { "e3cee67b", "bb5bee39", "b220ff4c", "fa43751f", "9ec83bf4" }; + for ( auto y = 0; y < 5; y++ ) { std::vector xs{7, kitty::dynamic_truth_table( 5 )}; @@ -143,7 +147,7 @@ TEST_CASE( "Check Akers for random - 5 inputs", "[akers_synthesis]" ) kitty::create_nth_var( xs[5], 3 ); kitty::create_nth_var( xs[6], 4 ); - create_random( xs[0] ); + create_from_hex_string( xs[0], tts[y] ); for ( auto i = 0u; i < unsigned( xs[0].num_bits() ); i++ ) { @@ -190,7 +194,7 @@ TEST_CASE( "Check Akers for random - 6 inputs", "[akers_synthesis]" ) kitty::create_nth_var( xs[6], 4 ); kitty::create_nth_var( xs[7], 5 ); - create_random( xs[0] ); + create_from_hex_string( xs[0], "32b43db39dde2b16" ); for ( auto i = 0u; i < unsigned( xs[0].num_bits() ); i++ ) { diff --git a/test/views/binding_view.cpp b/test/views/binding_view.cpp index c10703a5a..114da60a8 100644 --- a/test/views/binding_view.cpp +++ b/test/views/binding_view.cpp @@ -80,11 +80,11 @@ TEST_CASE( "Create binding view", "[binding_view]" ) std::stringstream report_gates; ntk.report_gates_usage( report_gates ); CHECK( report_gates.str() == "[i] Report gates usage:\n" - "[i] zero \t Instance = 1\t Area = 0.00 0.00 %\n" - "[i] inverter \t Instance = 1\t Area = 1.00 6.25 %\n" - "[i] and \t Instance = 2\t Area = 10.00 62.50 %\n" - "[i] or \t Instance = 1\t Area = 5.00 31.25 %\n" - "[i] TOTAL \t Instance = 5\t Area = 16.00 100.00 %\n" ); + "[i] zero \t Instance = 1\t Area = 0.00 0.00 %\n" + "[i] inverter \t Instance = 1\t Area = 1.00 6.25 %\n" + "[i] and \t Instance = 2\t Area = 10.00 62.50 %\n" + "[i] or \t Instance = 1\t Area = 5.00 31.25 %\n" + "[i] TOTAL \t Instance = 5\t Area = 16.00 100.00 %\n" ); } TEST_CASE( "Binding view on copy", "[binding_view]" )