Netlist: improve readability. (nw)

This commit is contained in:
couriersud 2019-02-26 22:29:50 +01:00
parent 893e676387
commit 20551e42a7
5 changed files with 28 additions and 22 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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<terminal_t *>(p);
analog_net_t *other_net = &pt->otherterm()->net();
if (!already_processed(other_net))
process_net(other_net);
auto *pt = static_cast<terminal_t *>(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<analog_net_t *>(net.get());
auto &n = *static_cast<analog_net_t *>(net.get());
if (!already_processed(n))
{
groups.emplace_back(analog_net_t::list_t());