This commit is contained in:
Matthias Koefferlein 2023-09-22 22:59:43 +02:00
parent 2f1cbf2e01
commit e56cdaeaab
5 changed files with 47 additions and 15 deletions

View File

@ -682,30 +682,36 @@ void Circuit::connect_pin (size_t pin_id, Net *net)
void Circuit::join_pins (size_t pin, size_t with)
{
if (with < m_pin_by_id.size () && ! tl::is_null_iterator (m_pin_by_id [with])) {
if (with != pin && with < m_pin_by_id.size () && ! tl::is_null_iterator (m_pin_by_id [with])) {
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);
// correct the pin IDs inside the circuit: all IDS > with will be reduced by 1
if (pin > with) {
--pin;
}
for (auto p = m_pins.begin (); p != m_pins.end (); ++p) {
if (p->id () > with) {
p->set_id (p->id () - 1);
}
}
for (auto p = m_pin_refs.begin () + with; p != m_pin_refs.end (); ++p) {
(*p)->set_pin_id ((*p)->pin_id () - 1);
}
// join nets in calls
for (auto s = begin_refs (); s != end_refs (); ++s) {
db::SubCircuit &sc = *s;
db::Net *with_net = sc.net_for_pin (with);
// remove the subcircuit pin reference from the "with" net
for (auto sc_pin = with_net->begin_subcircuit_pins (); sc_pin != with_net->end_subcircuit_pins (); ++sc_pin) {
if (sc_pin->subcircuit () == &sc && sc_pin->pin_id () == with) {
with_net->erase_subcircuit_pin (sc_pin);
break;
}
}
// NOTE: this will also correct the Pin IDs on the attached nets
sc.erase_pin (with);
sc.circuit ()->join_nets (sc.net_for_pin (pin), with_net);
sc.erase_pin_ref (with);
}
}

View File

@ -235,6 +235,7 @@ public:
private:
friend class Net;
friend class Circuit;
size_t m_pin_id;
Net *mp_net;
@ -246,6 +247,14 @@ private:
{
mp_net = net;
}
/**
* @brief Sets the pin ID
*/
void set_pin_id (size_t id)
{
m_pin_id = id;
}
};
/**
@ -343,6 +352,7 @@ public:
private:
friend class Net;
friend class SubCircuit;
size_t m_pin_id;
SubCircuit *mp_subcircuit;
@ -355,6 +365,14 @@ private:
{
mp_net = net;
}
/**
* @brief Sets the pin ID
*/
void set_pin_id (size_t pin)
{
m_pin_id = pin;
}
};
/**

View File

@ -414,8 +414,8 @@ generic_categorizer<Obj>::cat_for (const Obj *cls)
}
// explicit instantiations
template class DB_PUBLIC generic_categorizer<db::DeviceClass>;
template class DB_PUBLIC generic_categorizer<db::Circuit>;
template class generic_categorizer<db::DeviceClass>;
template class generic_categorizer<db::Circuit>;
// --------------------------------------------------------------------------------------------------------------------
// DeviceCategorizer implementation

View File

@ -90,9 +90,17 @@ void SubCircuit::set_trans (const db::DCplxTrans &t)
m_trans = t;
}
void SubCircuit::erase_pin_ref (size_t pin_id)
void SubCircuit::erase_pin (size_t pin_id)
{
Net *net = net_for_pin (pin_id);
net->erase_subcircuit_pin (m_pin_refs [pin_id]);
m_pin_refs.erase (m_pin_refs.begin () + pin_id);
// correct pin IDs for the pins with ID > pin_id
for (auto p = m_pin_refs.begin () + pin_id; p != m_pin_refs.end (); ++p) {
(*p)->set_pin_id ((*p)->pin_id () - 1);
}
}
void SubCircuit::set_pin_ref_for_pin (size_t pin_id, Net::subcircuit_pin_iterator iter)

View File

@ -233,7 +233,7 @@ private:
/**
* @brief Erases the given pin reference
*/
void erase_pin_ref (size_t pin_id);
void erase_pin (size_t pin_id);
/**
* @brief Sets the circuit the subcircuit belongs to