From ef4c9313ab0c79b6ddd4858e8b64fd8d45250ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6fferlein?= Date: Tue, 3 Mar 2020 22:24:03 +0100 Subject: [PATCH] Fixed a severe bug in join_symmetric_nets --- src/db/db/dbNetlistCompare.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/db/db/dbNetlistCompare.cc b/src/db/db/dbNetlistCompare.cc index 3b423f2d1..39be51719 100644 --- a/src/db/db/dbNetlistCompare.cc +++ b/src/db/db/dbNetlistCompare.cc @@ -3627,7 +3627,7 @@ NetlistComparer::do_subcircuit_assignment (const db::Circuit *c1, const db::NetG } } -static bool derive_symmetry_groups (const db::NetGraph &graph, const tl::equivalence_clusters &identical_nodes, std::set &considered_nodes, const std::set &symmetry_group, std::list > &symmetry_groups) +static bool derive_symmetry_groups (const db::NetGraph &graph, const tl::equivalence_clusters &identical_nodes, std::set &considered_nodes, const std::set &symmetry_group, std::vector > &symmetry_groups) { std::set cids; std::set new_symmetry_group; @@ -3752,7 +3752,7 @@ NetlistComparer::join_symmetric_nets (db::Circuit *circuit) } } - std::list > symmetry_groups; + std::vector > symmetry_groups; std::set visited; for (std::vector::const_iterator np = nodes.begin (); np != nodes.end (); ++np) { @@ -3774,10 +3774,13 @@ NetlistComparer::join_symmetric_nets (db::Circuit *circuit) } + std::sort (symmetry_groups.begin (), symmetry_groups.end ()); + symmetry_groups.erase (std::unique (symmetry_groups.begin (), symmetry_groups.end ()), symmetry_groups.end ()); + if (! symmetry_groups.empty () && tl::verbosity () >= 30) { tl::info << tl::to_string (tr ("Symmetry groups:")); int index = 0; - for (std::list >::const_iterator g = symmetry_groups.begin (); g != symmetry_groups.end (); ++g) { + for (std::vector >::const_iterator g = symmetry_groups.begin (); g != symmetry_groups.end (); ++g) { tl::info << " [" << index << "] " << tl::noendl; for (std::set::const_iterator i = g->begin (); i != g->end (); ++i) { tl::info << (i == g->begin () ? "" : ",") << (graph.node (*i).net () ? graph.node (*i).net ()->expanded_name ().c_str () : "(null)") << tl::noendl; @@ -3789,7 +3792,7 @@ NetlistComparer::join_symmetric_nets (db::Circuit *circuit) // join the nets - for (std::list >::const_iterator g = symmetry_groups.begin (); g != symmetry_groups.end (); ++g) { + for (std::vector >::const_iterator g = symmetry_groups.begin (); g != symmetry_groups.end (); ++g) { for (std::set::const_iterator i = g->begin (); i != g->end (); ++i) { if (i != g->begin ()) { circuit->join_nets (const_cast (graph.net_by_node_index (*g->begin ())), const_cast (graph.net_by_node_index (*i)));