From 5fbb57750b9aa526910d5765629e94caebc9dcd9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 15 Mar 2024 18:47:08 +0100 Subject: [PATCH] WIP --- src/db/db/dbHierNetworkProcessor.cc | 80 ++++++++++++++--------------- src/db/db/dbHierNetworkProcessor.h | 3 +- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/db/db/dbHierNetworkProcessor.cc b/src/db/db/dbHierNetworkProcessor.cc index eee016493..6ed288b23 100644 --- a/src/db/db/dbHierNetworkProcessor.cc +++ b/src/db/db/dbHierNetworkProcessor.cc @@ -850,7 +850,7 @@ local_clusters::remove_cluster (typename local_cluster::id_type id) m_needs_update = true; // take care of soft connections - remove_soft_connection_for (id); + remove_soft_connections_for (id); } template @@ -872,8 +872,18 @@ local_clusters::join_cluster_with (typename local_cluster::id_type id, typ with->clear (); // take care of soft connections - remove_soft_connection_for (id, with_id); - remove_soft_connection_for (with_id); + + std::set conn_down = downward_soft_connections (with_id); + std::set conn_up = upward_soft_connections (with_id); + + remove_soft_connections_for (with_id); + + for (auto i = conn_down.begin (); i != conn_down.end (); ++i) { + make_soft_connection (id, *i); + } + for (auto i = conn_up.begin (); i != conn_up.end (); ++i) { + make_soft_connection (*i, id); + } m_needs_update = true; } @@ -892,6 +902,10 @@ template void local_clusters::make_soft_connection (typename local_cluster::id_type a, typename local_cluster::id_type b) { + if (a == b) { + return; + } + // NOTE: antiparallel connections are allowed. We will eliminate them later m_soft_connections [a].insert (b); @@ -926,47 +940,33 @@ local_clusters::upward_soft_connections (typename local_cluster::id_type i } } -template -void -local_clusters::remove_soft_connection_for (typename local_cluster::id_type a, typename local_cluster::id_type b) +static void +remove_id_from_map (std::map > &fwd, std::map > &rev, size_t id) { - auto sc = m_soft_connections.find (a); - if (sc != m_soft_connections.end ()) { - sc->second.erase (b); - if (sc->second.empty ()) { - m_soft_connections.erase (sc); - } - } + auto sc = fwd.find (id); + if (sc != fwd.end ()) { - sc = m_soft_connections_rev.find (b); - if (sc != m_soft_connections_rev.end ()) { - sc->second.erase (a); - if (sc->second.empty ()) { - m_soft_connections_rev.erase (sc); + for (auto i = sc->second.begin (); i != sc->second.end (); ++i) { + auto sc_rev = rev.find (*i); + if (sc_rev != rev.end ()) { + sc_rev->second.erase (id); + if (sc_rev->second.empty ()) { + rev.erase (*i); + } + } } + + fwd.erase (sc); + } } template void -local_clusters::remove_soft_connection_for (typename local_cluster::id_type id) +local_clusters::remove_soft_connections_for (typename local_cluster::id_type id) { - auto sc = m_soft_connections.find (id); - if (sc != m_soft_connections.end ()) { - - for (auto i = sc->second.begin (); i != sc->second.end (); ++i) { - auto sc_rev = m_soft_connections_rev.find (*i); - tl_assert (sc_rev != m_soft_connections_rev.end ()) { - sc_rev->second.erase (id); - if (sc_rev->second.empty ()) { - m_soft_connections_rev.erase (*i); - } - } - } - - m_soft_connections.erase (sc); - - } + remove_id_from_map (m_soft_connections, m_soft_connections_rev, id); + remove_id_from_map (m_soft_connections_rev, m_soft_connections, id); } template @@ -1034,7 +1034,7 @@ struct cluster_building_receiver void generate_clusters (local_clusters &clusters) { - std::map *> in_to_out; + std::map::id_type> in_to_out; // build the resulting clusters for (typename std::list::const_iterator c = m_clusters.begin (); c != m_clusters.end (); ++c) { @@ -1046,7 +1046,7 @@ struct cluster_building_receiver cluster->add_attr (s->second.second); } - in_to_out.insert (std::make_pair (c.operator-> (), cluster)); + in_to_out.insert (std::make_pair (c.operator-> (), cluster->id ())); std::set global_nets = c->second; @@ -1087,7 +1087,7 @@ struct cluster_building_receiver auto c2 = in_to_out.find (sc->first.second); tl_assert (c1 != in_to_out.end () && c2 != in_to_out.end ()); - clusters.make_soft_connection (c1->second->id (), c2->second->id ()); + clusters.make_soft_connection (c1->second, c2->second); } } @@ -2957,7 +2957,7 @@ hier_clusters::build_hier_connections (cell_clusters_box_converter &cbc, c if (! i->has_instance ()) { local.join_cluster_with (gcid, i->id ()); - local.remove_cluster (i->id ()); + local.remove_cluster (i->id ()); // @@@ actually required? } else { @@ -2968,7 +2968,7 @@ hier_clusters::build_hier_connections (cell_clusters_box_converter &cbc, c // shouldn't happen, but duplicate instances may trigger this } else if (other_id) { local.join_cluster_with (gcid, other_id); - local.remove_cluster (other_id); + local.remove_cluster (other_id); // @@@ actually required? } else { local.add_connection (gcid, *i); } diff --git a/src/db/db/dbHierNetworkProcessor.h b/src/db/db/dbHierNetworkProcessor.h index efec69dd5..08ec80718 100644 --- a/src/db/db/dbHierNetworkProcessor.h +++ b/src/db/db/dbHierNetworkProcessor.h @@ -661,8 +661,7 @@ private: std::map > m_soft_connections_rev; void apply_attr_equivalences (const tl::equivalence_clusters &attr_equivalence); - void remove_soft_connection_for (typename local_cluster::id_type a, typename local_cluster::id_type b); - void remove_soft_connection_for (typename local_cluster::id_type id); + void remove_soft_connections_for (typename local_cluster::id_type id); }; /**