From 2f1cbf2e0111af9b1fdd149555c6ea4d712d77df Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 22 Sep 2023 21:45:34 +0200 Subject: [PATCH] WIP --- src/db/db/dbLayoutToNetlist.cc | 43 ++++++++++++++++++++-------------- src/db/db/dbLayoutToNetlist.h | 2 ++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/db/db/dbLayoutToNetlist.cc b/src/db/db/dbLayoutToNetlist.cc index 63ff977c1..48eba3c61 100644 --- a/src/db/db/dbLayoutToNetlist.cc +++ b/src/db/db/dbLayoutToNetlist.cc @@ -427,27 +427,36 @@ void LayoutToNetlist::extract_netlist () // @@@ raise error on error } -static std::vector nets_from_pattern (db::Circuit &c, const tl::GlobPattern &p) +void LayoutToNetlist::join_nets_from_pattern (db::Circuit &c, const tl::GlobPattern &p) { - std::vector result; + std::map > nets_by_name; for (auto n = c.begin_nets (); n != c.end_nets (); ++n) { - if (p.match (n->name ())) { - result.push_back (n.operator-> ()); + if (! n->name ().empty () && p.match (n->name ())) { + nets_by_name [n->name ()].push_back (n.operator-> ()); + } + } + + for (auto n2n = nets_by_name.begin (); n2n != nets_by_name.end (); ++n2n) { + if (n2n->second.size () > 1) { + do_join_nets (c, n2n->second); } } - return result; } -static std::vector nets_from_pattern (db::Circuit &c, const std::set &p) +void LayoutToNetlist::join_nets_from_pattern (db::Circuit &c, const std::set &p) { - std::vector result; + std::vector nets; for (auto n = p.begin (); n != p.end (); ++n) { - db::Net *net = c.net_by_name (*n); - if (net) { - result.push_back (net); + if (! n->empty ()) { + db::Net *net = c.net_by_name (*n); + if (net) { + nets.push_back (net); + } } } - return result; + if (nets.size () > 1) { + do_join_nets (c, nets); + } } void LayoutToNetlist::do_join_nets (db::Circuit &c, const std::vector &nets) @@ -458,9 +467,7 @@ void LayoutToNetlist::do_join_nets (db::Circuit &c, const std::vector std::set names; for (auto n = nets.begin (); n != nets.end (); ++n) { - if (! (*n)->name ().empty ()) { - names.insert ((*n)->name ()); - } + names.insert ((*n)->name ()); } nets [0]->set_name (tl::join (names.begin (), names.end (), ",")); @@ -524,20 +531,20 @@ void LayoutToNetlist::do_join_nets () for (auto jn = m_joined_net_names.begin (); jn != m_joined_net_names.end (); ++jn) { for (auto c = mp_netlist->begin_top_down (); c != mp_netlist->end_top_down (); ++c) { - do_join_nets (*c, nets_from_pattern (*c, *jn)); + join_nets_from_pattern (*c, *jn); } } for (auto jn = m_joined_nets.begin (); jn != m_joined_nets.end (); ++jn) { for (auto c = mp_netlist->begin_top_down (); c != mp_netlist->end_top_down (); ++c) { - do_join_nets (*c, nets_from_pattern (*c, *jn)); + join_nets_from_pattern (*c, *jn); } } for (auto jn = m_joined_net_names_per_cell.begin (); jn != m_joined_net_names_per_cell.end (); ++jn) { for (auto c = mp_netlist->begin_top_down (); c != mp_netlist->end_top_down (); ++c) { if (jn->first.match (c->name ())) { - do_join_nets (*c, nets_from_pattern (*c, jn->second)); + join_nets_from_pattern (*c, jn->second); } } } @@ -545,7 +552,7 @@ void LayoutToNetlist::do_join_nets () for (auto jn = m_joined_nets_per_cell.begin (); jn != m_joined_nets_per_cell.end (); ++jn) { for (auto c = mp_netlist->begin_top_down (); c != mp_netlist->end_top_down (); ++c) { if (jn->first.match (c->name ())) { - do_join_nets (*c, nets_from_pattern (*c, jn->second)); + join_nets_from_pattern (*c, jn->second); } } } diff --git a/src/db/db/dbLayoutToNetlist.h b/src/db/db/dbLayoutToNetlist.h index 443bef184..b3ce1d6d9 100644 --- a/src/db/db/dbLayoutToNetlist.h +++ b/src/db/db/dbLayoutToNetlist.h @@ -995,6 +995,8 @@ private: bool is_persisted_impl (const db::ShapeCollection &coll) const; void do_join_nets (db::Circuit &c, const std::vector &nets); void do_join_nets (); + void join_nets_from_pattern (db::Circuit &c, const tl::GlobPattern &p); + void join_nets_from_pattern (db::Circuit &c, const std::set &p); void check_must_connect (const db::Circuit &c, const db::Net &a, const db::Net &b); void error (const std::string &msg); void warn (const std::string &msg);