WIP: aligned new implementation better with original one

This commit is contained in:
Matthias Koefferlein 2023-09-23 00:35:11 +02:00
parent 4f3522961e
commit b72dfe34b4
4 changed files with 36 additions and 14 deletions

View File

@ -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<std::string> 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);

View File

@ -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<std::string> &p)
{
// NOTE: this version implies implicit joining of different nets with the same name from the set p
std::vector<db::Net *> 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<db::Net *>
return;
}
std::set<std::string> 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);

View File

@ -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);

Binary file not shown.