diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index c2dd2c683a3..55560151e21 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -856,7 +856,7 @@ terminal_t::terminal_t(core_device_t &dev, const pstring &aname, terminal_t *oth , m_Idr1(nullptr) , m_go1(nullptr) , m_gt1(nullptr) -, m_otherterm(otherterm) +, m_connected_terminal(otherterm) { state().setup().register_term(*this); } diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 572dba272b9..66fc49d7e5e 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -626,14 +626,14 @@ namespace netlist void set_ptrs(nl_double *gt, nl_double *go, nl_double *Idr) noexcept; - terminal_t *otherterm() const noexcept { return m_otherterm; } + terminal_t *connected_terminal() const noexcept { return m_connected_terminal; } private: nl_double *m_Idr1; // drive current nl_double *m_go1; // conductance for Voltage from other term nl_double *m_gt1; // conductance for total conductance - terminal_t *m_otherterm; + terminal_t *m_connected_terminal; }; diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 09065e081df..1fe14b0f5e1 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -227,7 +227,7 @@ namespace devices for (std::size_t i = 0; i < term->count(); i++) //FIXME: this is weird if (other[i] != -1) - other[i] = get_net_idx(&term->terms()[i]->otherterm()->net()); + other[i] = get_net_idx(&term->terms()[i]->connected_terminal()->net()); } } @@ -491,7 +491,7 @@ namespace devices for (std::size_t i = 0; i < term->count(); i++) { - auto col = get_net_idx(&term->terms()[i]->otherterm()->net()); + auto col = get_net_idx(&term->terms()[i]->connected_terminal()->net()); if (col != -1) { if (col==row) col = diag; @@ -519,7 +519,7 @@ namespace devices auto &term = m_terms[row]; for (std::size_t i = 0; i < term->count(); i++) { - auto col = get_net_idx(&term->terms()[i]->otherterm()->net()); + auto col = get_net_idx(&term->terms()[i]->connected_terminal()->net()); if (col >= 0) { auto colu = static_cast(col); @@ -539,13 +539,13 @@ namespace devices void matrix_solver_t::add_term(std::size_t k, terminal_t *term) { - if (term->otherterm()->net().isRailNet()) + if (term->connected_terminal()->net().isRailNet()) { m_rails_temp[k]->add(term, -1, false); } else { - int ot = get_net_idx(&term->otherterm()->net()); + int ot = get_net_idx(&term->connected_terminal()->net()); if (ot>=0) { m_terms[k]->add(term, ot, true); diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index d93da02c63e..a7473eb6315 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -192,7 +192,7 @@ namespace devices for (std::size_t i = 0; i < count; i++) { m_terms[k]->terms()[i]->set_ptrs(&m_gtn[k][i], &m_gonn[k][i], &m_Idrn[k][i]); - m_connected_net_Vn[k][i] = m_terms[k]->terms()[i]->otherterm()->net().Q_Analog_state_ptr(); + m_connected_net_Vn[k][i] = m_terms[k]->terms()[i]->connected_terminal()->net().Q_Analog_state_ptr(); } } } diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index de5c547dc4c..9d7b8e7dbb2 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -187,30 +187,36 @@ namespace devices struct net_splitter { - bool already_processed(analog_net_t *n) + bool already_processed(const analog_net_t &n) const { - if (n->isRailNet()) + /* no need to process rail nets - these are known variables */ + if (n.isRailNet()) return true; + /* if it's already processed - no need to continue */ for (auto & grp : groups) - if (plib::container::contains(grp, n)) + if (plib::container::contains(grp, &n)) return true; return false; } - void process_net(analog_net_t *n) + void process_net(analog_net_t &n) { - if (n->num_cons() == 0) + /* ignore empty nets. FIXME: print a warning message */ + if (n.num_cons() == 0) return; /* add the net */ - groups.back().push_back(n); - for (auto &p : n->core_terms()) + groups.back().push_back(&n); + /* process all terminals connected to this net */ + for (auto &term : n.core_terms()) { - if (p->is_type(detail::terminal_type::TERMINAL)) + /* only process analog terminals */ + if (term->is_type(detail::terminal_type::TERMINAL)) { - auto *pt = static_cast(p); - analog_net_t *other_net = &pt->otherterm()->net(); - if (!already_processed(other_net)) - process_net(other_net); + auto *pt = static_cast(term); + /* check the connected terminal */ + analog_net_t &connected_net = pt->connected_terminal()->net(); + if (!already_processed(connected_net)) + process_net(connected_net); } } } @@ -224,7 +230,7 @@ namespace devices { netlist.log().debug(" ==> not a rail net\n"); /* Must be an analog net */ - auto *n = static_cast(net.get()); + auto &n = *static_cast(net.get()); if (!already_processed(n)) { groups.emplace_back(analog_net_t::list_t());