From b72dfe34b4ad30370b20ebcc83f33d50cd777cf7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 23 Sep 2023 00:35:11 +0200 Subject: [PATCH] WIP: aligned new implementation better with original one --- src/db/db/dbCircuit.cc | 30 ++++++++++++++++++++ src/db/db/dbLayoutToNetlist.cc | 18 ++++-------- src/db/unit_tests/dbLayoutToNetlistTests.cc | 2 +- testdata/algo/device_extract_l14.gds | Bin 3158 -> 3158 bytes 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/db/db/dbCircuit.cc b/src/db/db/dbCircuit.cc index ebf520118..07d8cb338 100644 --- a/src/db/db/dbCircuit.cc +++ b/src/db/db/dbCircuit.cc @@ -30,6 +30,30 @@ namespace db { +/** + * @brief Creates a joined name for nets and pins + */ +static std::string +join_names (const std::string &n1, const std::string &n2) +{ + // create a new name for the joined net + if (n2.empty ()) { + return n1; + } else if (n1.empty ()) { + return n2; + } else if (n1 == n2) { + return n1; + } else { + // separate parts (if already joined) and mix + auto p1 = tl::split (n1, ","); + auto p2 = tl::split (n2, ","); + std::set ps; + ps.insert (p1.begin (), p1.end ()); + ps.insert (p2.begin (), p2.end ()); + return tl::join (ps.begin (), ps.end (), ","); + } +} + // -------------------------------------------------------------------------------- // Circuit class implementation @@ -391,6 +415,9 @@ void Circuit::join_nets (Net *net, Net *with) netlist ()->callbacks ()->link_nets (net, with); } + // create a new name for the joined net + net->set_name (join_names (net->name (), with->name ())); + remove_net (with); } @@ -684,6 +711,9 @@ void Circuit::join_pins (size_t pin, size_t with) { if (with != pin && with < m_pin_by_id.size () && ! tl::is_null_iterator (m_pin_by_id [with])) { + // create a new joined name + m_pin_by_id [pin]->set_name (join_names (m_pin_by_id [pin]->name (), m_pin_by_id [with]->name ())); + m_pins.erase (m_pin_by_id [with]); m_pin_by_id.erase (m_pin_by_id.begin () + with); m_pin_refs.erase (m_pin_refs.begin () + with); diff --git a/src/db/db/dbLayoutToNetlist.cc b/src/db/db/dbLayoutToNetlist.cc index 48eba3c61..53a88e01f 100644 --- a/src/db/db/dbLayoutToNetlist.cc +++ b/src/db/db/dbLayoutToNetlist.cc @@ -445,15 +445,14 @@ void LayoutToNetlist::join_nets_from_pattern (db::Circuit &c, const tl::GlobPatt void LayoutToNetlist::join_nets_from_pattern (db::Circuit &c, const std::set &p) { + // NOTE: this version implies implicit joining of different nets with the same name from the set p std::vector nets; - for (auto n = p.begin (); n != p.end (); ++n) { - if (! n->empty ()) { - db::Net *net = c.net_by_name (*n); - if (net) { - nets.push_back (net); - } + for (auto n = c.begin_nets (); n != c.end_nets (); ++n) { + if (! n->name ().empty () && p.find (n->name ()) != p.end ()) { + nets.push_back (n.operator-> ()); } } + if (nets.size () > 1) { do_join_nets (c, nets); } @@ -465,13 +464,6 @@ void LayoutToNetlist::do_join_nets (db::Circuit &c, const std::vector return; } - std::set names; - for (auto n = nets.begin (); n != nets.end (); ++n) { - names.insert ((*n)->name ()); - } - - nets [0]->set_name (tl::join (names.begin (), names.end (), ",")); - for (auto n = nets.begin () + 1; n != nets.end (); ++n) { check_must_connect (c, *nets [0], **n); c.join_nets (nets [0], *n); diff --git a/src/db/unit_tests/dbLayoutToNetlistTests.cc b/src/db/unit_tests/dbLayoutToNetlistTests.cc index 83161873b..d7524ad70 100644 --- a/src/db/unit_tests/dbLayoutToNetlistTests.cc +++ b/src/db/unit_tests/dbLayoutToNetlistTests.cc @@ -3648,7 +3648,7 @@ TEST(14_JoinNets) jn.insert ("BULK"); l2n->join_nets (tl::GlobPattern ("INV2"), jn); - // This will trigger an implicit connection on top level (side effect of explicit connections) + // Implicit connection of nets with same name "VDD" jn.clear (); jn.insert ("VDD"); l2n->join_nets (jn); diff --git a/testdata/algo/device_extract_l14.gds b/testdata/algo/device_extract_l14.gds index 740a561b4a75ddda9b93bef45e0b86754f84dfd4..ecb5ef30638c87d91aa19fcffcd8bba62b75bcea 100644 GIT binary patch delta 157 zcmca6aZMtMfsKKQDS|{L4=vr&au{L4=vr&au