summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2019-01-15 23:42:16 +0100
committerGravatarGravatar couriersud <couriersud@gmx.org>2019-01-15 23:42:16 +0100
commitc89439dd2365e1c1936ea1cd9fb934fb2f1c1576 (patch) (github)
tree4d228467386fec91d9bfa8db28c1a69f51143921
parent656b70d8fd052d91b507882aeba584d59ea18048 (diff)
downloadmame-c89439dd2365e1c1936ea1cd9fb934fb2f1c1576.tar.bz2
mame-c89439dd2365e1c1936ea1cd9fb934fb2f1c1576.zip
netlist: refactored netlist creation. (nw)
This is an effort to separate netlist creation from netlist execution. The primary target is to avoid that code which will only run during execution is able to call setup code and thus create ugly hacks.
-rw-r--r--src/devices/machine/netlist.cpp10
-rw-r--r--src/lib/netlist/analog/nld_bjt.cpp22
-rw-r--r--src/lib/netlist/analog/nld_switches.cpp9
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.cpp34
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.h2
-rw-r--r--src/lib/netlist/devices/nld_4066.cpp10
-rw-r--r--src/lib/netlist/devices/nld_4316.cpp9
-rw-r--r--src/lib/netlist/devices/nld_log.cpp4
-rw-r--r--src/lib/netlist/devices/nlid_proxy.cpp10
-rw-r--r--src/lib/netlist/devices/nlid_proxy.h10
-rw-r--r--src/lib/netlist/devices/nlid_system.h2
-rw-r--r--src/lib/netlist/devices/nlid_truthtable.cpp2
-rw-r--r--src/lib/netlist/nl_base.cpp109
-rw-r--r--src/lib/netlist/nl_base.h163
-rw-r--r--src/lib/netlist/nl_config.h3
-rw-r--r--src/lib/netlist/nl_factory.cpp6
-rw-r--r--src/lib/netlist/nl_factory.h12
-rw-r--r--src/lib/netlist/nl_parser.h2
-rw-r--r--src/lib/netlist/nl_setup.cpp10
-rw-r--r--src/lib/netlist/nl_setup.h10
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.cpp6
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_direct.h8
-rw-r--r--src/lib/netlist/solver/nld_ms_direct1.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_direct2.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_gcr.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_gmres.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_sm.h4
-rw-r--r--src/lib/netlist/solver/nld_ms_sor.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_sor_mat.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_w.h4
-rw-r--r--src/lib/netlist/solver/nld_solver.cpp6
-rw-r--r--src/lib/netlist/solver/nld_solver.h2
33 files changed, 271 insertions, 212 deletions
diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp
index 49ed1e3fe05..75aa472e7e5 100644
--- a/src/devices/machine/netlist.cpp
+++ b/src/devices/machine/netlist.cpp
@@ -117,7 +117,7 @@ namespace {
class NETLIB_NAME(analog_callback) : public netlist::device_t
{
public:
- NETLIB_NAME(analog_callback)(netlist::netlist_t &anetlist, const pstring &name)
+ NETLIB_NAME(analog_callback)(netlist::netlist_base_t &anetlist, const pstring &name)
: device_t(anetlist, name)
, m_in(*this, "IN")
, m_cpu_device(nullptr)
@@ -165,7 +165,7 @@ private:
class NETLIB_NAME(logic_callback) : public netlist::device_t
{
public:
- NETLIB_NAME(logic_callback)(netlist::netlist_t &anetlist, const pstring &name)
+ NETLIB_NAME(logic_callback)(netlist::netlist_base_t &anetlist, const pstring &name)
: device_t(anetlist, name)
, m_in(*this, "IN")
, m_cpu_device(nullptr)
@@ -273,7 +273,7 @@ std::unique_ptr<plib::pistream> netlist_data_memregions_t::stream(const pstring
class NETLIB_NAME(sound_out) : public netlist::device_t
{
public:
- NETLIB_NAME(sound_out)(netlist::netlist_t &anetlist, const pstring &name)
+ NETLIB_NAME(sound_out)(netlist::netlist_base_t &anetlist, const pstring &name)
: netlist::device_t(anetlist, name)
, m_channel(*this, "CHAN", 0)
, m_mult(*this, "MULT", 1000.0)
@@ -311,7 +311,7 @@ public:
NETLIB_UPDATEI()
{
nl_double val = m_in() * m_mult() + m_offset();
- sound_update(netlist().time());
+ sound_update(exec().time());
/* ignore spikes */
if (std::abs(val) < 32767.0)
m_cur = val;
@@ -355,7 +355,7 @@ public:
static const int MAX_INPUT_CHANNELS = 16;
- NETLIB_NAME(sound_in)(netlist::netlist_t &anetlist, const pstring &name)
+ NETLIB_NAME(sound_in)(netlist::netlist_base_t &anetlist, const pstring &name)
: netlist::device_t(anetlist, name)
, m_inc(netlist::netlist_time::from_nsec(1))
, m_feedback(*this, "FB") // clock part
diff --git a/src/lib/netlist/analog/nld_bjt.cpp b/src/lib/netlist/analog/nld_bjt.cpp
index 83182847082..cf963465b09 100644
--- a/src/lib/netlist/analog/nld_bjt.cpp
+++ b/src/lib/netlist/analog/nld_bjt.cpp
@@ -185,8 +185,8 @@ NETLIB_OBJECT_DERIVED(QBJT_switch, QBJT)
, m_RB(*this, "m_RB", true)
, m_RC(*this, "m_RC", true)
, m_BC_dummy(*this, "m_BC", true)
- , m_gB(NETLIST_GMIN_DEFAULT)
- , m_gC(NETLIST_GMIN_DEFAULT)
+ , m_gB(1e-9)
+ , m_gC(1e-9)
, m_V(0.0)
, m_state_on(*this, "m_state_on", 0)
{
@@ -299,10 +299,10 @@ NETLIB_RESET(QBJT_switch)
m_state_on = 0;
- m_RB.set(netlist().gmin(), 0.0, 0.0);
- m_RC.set(netlist().gmin(), 0.0, 0.0);
+ m_RB.set(exec().gmin(), 0.0, 0.0);
+ m_RC.set(exec().gmin(), 0.0, 0.0);
- m_BC_dummy.set(netlist().gmin() / 10.0, 0.0, 0.0);
+ m_BC_dummy.set(exec().gmin() / 10.0, 0.0, 0.0);
}
@@ -341,8 +341,8 @@ NETLIB_UPDATE_PARAM(QBJT_switch)
//m_gB = d.gI(0.005 / alpha);
- if (m_gB < netlist().gmin())
- m_gB = netlist().gmin();
+ if (m_gB < exec().gmin())
+ m_gB = exec().gmin();
m_gC = d.gI(0.005); // very rough estimate
}
@@ -353,8 +353,8 @@ NETLIB_UPDATE_TERMINALS(QBJT_switch)
const unsigned new_state = (m_RB.deltaV() * m > m_V ) ? 1 : 0;
if (m_state_on ^ new_state)
{
- const nl_double gb = new_state ? m_gB : netlist().gmin();
- const nl_double gc = new_state ? m_gC : netlist().gmin();
+ const nl_double gb = new_state ? m_gB : exec().gmin();
+ const nl_double gc = new_state ? m_gC : exec().gmin();
const nl_double v = new_state ? m_V * m : 0;
m_RB.set(gb, v, 0.0);
@@ -423,8 +423,8 @@ NETLIB_UPDATE_PARAM(QBJT_EB)
m_alpha_f = BF / (1.0 + BF);
m_alpha_r = BR / (1.0 + BR);
- m_gD_BE.set_param(IS / m_alpha_f, NF, netlist().gmin());
- m_gD_BC.set_param(IS / m_alpha_r, NR, netlist().gmin());
+ m_gD_BE.set_param(IS / m_alpha_f, NF, exec().gmin());
+ m_gD_BC.set_param(IS / m_alpha_r, NR, exec().gmin());
}
} //namespace analog
diff --git a/src/lib/netlist/analog/nld_switches.cpp b/src/lib/netlist/analog/nld_switches.cpp
index 1575551f260..042b61ce7e7 100644
--- a/src/lib/netlist/analog/nld_switches.cpp
+++ b/src/lib/netlist/analog/nld_switches.cpp
@@ -6,10 +6,13 @@
*/
#include "nlid_twoterm.h"
-#include "../nl_base.h"
-#include "../nl_factory.h"
+#include "netlist/nl_base.h"
+#include "netlist/nl_factory.h"
+#include "netlist/solver/nld_solver.h"
-#define R_OFF (1.0 / netlist().gmin())
+/* FIXME : convert to parameters */
+
+#define R_OFF (1.0 / exec().gmin())
#define R_ON 0.01
namespace netlist
diff --git a/src/lib/netlist/analog/nlid_twoterm.cpp b/src/lib/netlist/analog/nlid_twoterm.cpp
index f54c2b3e68f..0f6fc3688c2 100644
--- a/src/lib/netlist/analog/nlid_twoterm.cpp
+++ b/src/lib/netlist/analog/nlid_twoterm.cpp
@@ -100,7 +100,7 @@ NETLIB_UPDATE(twoterm)
NETLIB_RESET(R_base)
{
NETLIB_NAME(twoterm)::reset();
- set_R(1.0 / netlist().gmin());
+ set_R(1.0 / exec().gmin());
}
NETLIB_UPDATE(R_base)
@@ -115,13 +115,13 @@ NETLIB_UPDATE(R_base)
NETLIB_UPDATE_PARAM(R)
{
update_dev();
- set_R(std::max(m_R(), netlist().gmin()));
+ set_R(std::max(m_R(), exec().gmin()));
}
NETLIB_RESET(R)
{
NETLIB_NAME(twoterm)::reset();
- set_R(std::max(m_R(), netlist().gmin()));
+ set_R(std::max(m_R(), exec().gmin()));
}
// ----------------------------------------------------------------------------------------
@@ -134,8 +134,8 @@ NETLIB_RESET(POT)
if (m_DialIsLog())
v = (std::exp(v) - 1.0) / (std::exp(1.0) - 1.0);
- m_R1.set_R(std::max(m_R() * v, netlist().gmin()));
- m_R2.set_R(std::max(m_R() * (NL_FCONST(1.0) - v), netlist().gmin()));
+ m_R1.set_R(std::max(m_R() * v, exec().gmin()));
+ m_R2.set_R(std::max(m_R() * (NL_FCONST(1.0) - v), exec().gmin()));
}
NETLIB_UPDATE_PARAM(POT)
@@ -147,8 +147,8 @@ NETLIB_UPDATE_PARAM(POT)
if (m_DialIsLog())
v = (std::exp(v) - 1.0) / (std::exp(1.0) - 1.0);
- m_R1.set_R(std::max(m_R() * v, netlist().gmin()));
- m_R2.set_R(std::max(m_R() * (NL_FCONST(1.0) - v), netlist().gmin()));
+ m_R1.set_R(std::max(m_R() * v, exec().gmin()));
+ m_R2.set_R(std::max(m_R() * (NL_FCONST(1.0) - v), exec().gmin()));
}
@@ -164,7 +164,7 @@ NETLIB_RESET(POT2)
v = (std::exp(v) - 1.0) / (std::exp(1.0) - 1.0);
if (m_Reverse())
v = 1.0 - v;
- m_R1.set_R(std::max(m_R() * v, netlist().gmin()));
+ m_R1.set_R(std::max(m_R() * v, exec().gmin()));
}
@@ -178,7 +178,7 @@ NETLIB_UPDATE_PARAM(POT2)
v = (std::exp(v) - 1.0) / (std::exp(1.0) - 1.0);
if (m_Reverse())
v = 1.0 - v;
- m_R1.set_R(std::max(m_R() * v, netlist().gmin()));
+ m_R1.set_R(std::max(m_R() * v, exec().gmin()));
}
// ----------------------------------------------------------------------------------------
@@ -188,13 +188,13 @@ NETLIB_UPDATE_PARAM(POT2)
NETLIB_RESET(C)
{
// FIXME: Startup conditions
- set(netlist().gmin(), 0.0, -5.0 / netlist().gmin());
- //set(netlist().gmin(), 0.0, 0.0);
+ set(exec().gmin(), 0.0, -5.0 / exec().gmin());
+ //set(exec().gmin(), 0.0, 0.0);
}
NETLIB_UPDATE_PARAM(C)
{
- m_GParallel = netlist().gmin();
+ m_GParallel = exec().gmin();
}
NETLIB_UPDATE(C)
@@ -218,7 +218,7 @@ NETLIB_TIMESTEP(C)
NETLIB_RESET(L)
{
- m_GParallel = netlist().gmin();
+ m_GParallel = exec().gmin();
m_I = 0.0;
m_G = m_GParallel;
set_mat( m_G, -m_G, -m_I,
@@ -254,7 +254,7 @@ NETLIB_RESET(D)
nl_double Is = m_model.m_IS;
nl_double n = m_model.m_N;
- m_D.set_param(Is, n, netlist().gmin());
+ m_D.set_param(Is, n, exec().gmin());
set(m_D.G(), 0.0, m_D.Ieq());
}
@@ -263,7 +263,7 @@ NETLIB_UPDATE_PARAM(D)
nl_double Is = m_model.m_IS;
nl_double n = m_model.m_N;
- m_D.set_param(Is, n, netlist().gmin());
+ m_D.set_param(Is, n, exec().gmin());
}
NETLIB_UPDATE(D)
@@ -299,7 +299,7 @@ NETLIB_UPDATE(VS)
NETLIB_TIMESTEP(VS)
{
this->set(1.0 / m_R(),
- m_compiled.evaluate(std::vector<double>({netlist().time().as_double()})),
+ m_compiled.evaluate(std::vector<double>({exec().time().as_double()})),
0.0);
}
@@ -324,7 +324,7 @@ NETLIB_UPDATE(CS)
NETLIB_TIMESTEP(CS)
{
- const double I = m_compiled.evaluate(std::vector<double>({netlist().time().as_double()}));
+ const double I = m_compiled.evaluate(std::vector<double>({exec().time().as_double()}));
set_mat(0.0, 0.0, -I,
0.0, 0.0, I);
}
diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h
index 4ab5fcda89b..efb9a8dd929 100644
--- a/src/lib/netlist/analog/nlid_twoterm.h
+++ b/src/lib/netlist/analog/nlid_twoterm.h
@@ -55,7 +55,7 @@ namespace netlist
return b ? *h : d2;
}
template<>
- inline core_device_t &bselect(bool b, netlist_t &d1, core_device_t &d2)
+ inline core_device_t &bselect(bool b, netlist_base_t &d1, core_device_t &d2)
{
if (b)
throw nl_exception("bselect with netlist and b==true");
diff --git a/src/lib/netlist/devices/nld_4066.cpp b/src/lib/netlist/devices/nld_4066.cpp
index b5f3b2f6bf2..2871e4898ae 100644
--- a/src/lib/netlist/devices/nld_4066.cpp
+++ b/src/lib/netlist/devices/nld_4066.cpp
@@ -5,10 +5,12 @@
*
*/
-#include "nlid_cmos.h"
-#include "../analog/nlid_twoterm.h"
#include "nld_4066.h"
+#include "nlid_cmos.h"
+#include "netlist/analog/nlid_twoterm.h"
+#include "netlist/solver/nld_solver.h"
+
namespace netlist
{
namespace devices
@@ -39,7 +41,7 @@ namespace netlist
{
// Start in off condition
// FIXME: is ROFF correct?
- m_R.set_R(NL_FCONST(1.0) / netlist().gmin());
+ m_R.set_R(NL_FCONST(1.0) / exec().gmin());
}
@@ -54,7 +56,7 @@ namespace netlist
if (in < low)
{
- R = NL_FCONST(1.0) / netlist().gmin();
+ R = NL_FCONST(1.0) / exec().gmin();
}
else if (in > high)
{
diff --git a/src/lib/netlist/devices/nld_4316.cpp b/src/lib/netlist/devices/nld_4316.cpp
index 0bce54cc6c3..4290c65670c 100644
--- a/src/lib/netlist/devices/nld_4316.cpp
+++ b/src/lib/netlist/devices/nld_4316.cpp
@@ -5,9 +5,10 @@
*
*/
-#include "nlid_cmos.h"
-#include "../analog/nlid_twoterm.h"
#include "nld_4316.h"
+#include "nlid_cmos.h"
+#include "netlist/analog/nlid_twoterm.h"
+#include "netlist/solver/nld_solver.h"
namespace netlist { namespace devices {
@@ -37,7 +38,7 @@ namespace netlist { namespace devices {
NETLIB_RESET(CD4316_GATE)
{
- m_R.set_R(NL_FCONST(1.0) / netlist().gmin());
+ m_R.set_R(NL_FCONST(1.0) / exec().gmin());
}
NETLIB_UPDATE(CD4316_GATE)
@@ -46,7 +47,7 @@ namespace netlist { namespace devices {
if (m_S() && !m_E())
m_R.set_R(m_base_r());
else
- m_R.set_R(NL_FCONST(1.0) / netlist().gmin());
+ m_R.set_R(NL_FCONST(1.0) / exec().gmin());
m_R.m_P.schedule_solve_after(NLTIME_FROM_NS(1));
}
diff --git a/src/lib/netlist/devices/nld_log.cpp b/src/lib/netlist/devices/nld_log.cpp
index 1d3ea7b1b75..03f7cae779c 100644
--- a/src/lib/netlist/devices/nld_log.cpp
+++ b/src/lib/netlist/devices/nld_log.cpp
@@ -27,7 +27,7 @@ namespace netlist
NETLIB_UPDATEI()
{
/* use pstring::sprintf, it is a LOT faster */
- m_writer.writeline(plib::pfmt("{1:.9} {2}").e(netlist().time().as_double()).e(static_cast<double>(m_I())));
+ m_writer.writeline(plib::pfmt("{1:.9} {2}").e(exec().time().as_double()).e(static_cast<double>(m_I())));
}
NETLIB_RESETI() { }
@@ -46,7 +46,7 @@ namespace netlist
NETLIB_UPDATEI()
{
- m_writer.writeline(plib::pfmt("{1:.9} {2}").e(netlist().time().as_double()).e(static_cast<double>(m_I() - m_I2())));
+ m_writer.writeline(plib::pfmt("{1:.9} {2}").e(exec().time().as_double()).e(static_cast<double>(m_I() - m_I2())));
}
NETLIB_RESETI() { }
diff --git a/src/lib/netlist/devices/nlid_proxy.cpp b/src/lib/netlist/devices/nlid_proxy.cpp
index 4c3ec6f67aa..c5ad63f3910 100644
--- a/src/lib/netlist/devices/nlid_proxy.cpp
+++ b/src/lib/netlist/devices/nlid_proxy.cpp
@@ -20,7 +20,7 @@ namespace netlist
// nld_base_proxy
// -----------------------------------------------------------------------------
- nld_base_proxy::nld_base_proxy(netlist_t &anetlist, const pstring &name,
+ nld_base_proxy::nld_base_proxy(netlist_base_t &anetlist, const pstring &name,
logic_t *inout_proxied, detail::core_terminal_t *proxy_inout)
: device_t(anetlist, name)
{
@@ -37,7 +37,7 @@ namespace netlist
// nld_a_to_d_proxy
// ----------------------------------------------------------------------------------------
- nld_base_a_to_d_proxy::nld_base_a_to_d_proxy(netlist_t &anetlist, const pstring &name,
+ nld_base_a_to_d_proxy::nld_base_a_to_d_proxy(netlist_base_t &anetlist, const pstring &name,
logic_input_t *in_proxied, detail::core_terminal_t *in_proxy)
: nld_base_proxy(anetlist, name, in_proxied, in_proxy)
, m_Q(*this, "Q")
@@ -46,7 +46,7 @@ namespace netlist
nld_base_a_to_d_proxy::~nld_base_a_to_d_proxy() {}
- nld_a_to_d_proxy::nld_a_to_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *in_proxied)
+ nld_a_to_d_proxy::nld_a_to_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *in_proxied)
: nld_base_a_to_d_proxy(anetlist, name, in_proxied, &m_I)
, m_I(*this, "I")
{
@@ -81,7 +81,7 @@ namespace netlist
// nld_d_to_a_proxy
// ----------------------------------------------------------------------------------------
- nld_base_d_to_a_proxy::nld_base_d_to_a_proxy(netlist_t &anetlist, const pstring &name,
+ nld_base_d_to_a_proxy::nld_base_d_to_a_proxy(netlist_base_t &anetlist, const pstring &name,
logic_output_t *out_proxied, detail::core_terminal_t &proxy_out)
: nld_base_proxy(anetlist, name, out_proxied, &proxy_out)
, m_I(*this, "I")
@@ -92,7 +92,7 @@ namespace netlist
{
}
- nld_d_to_a_proxy::nld_d_to_a_proxy(netlist_t &anetlist, const pstring &name, logic_output_t *out_proxied)
+ nld_d_to_a_proxy::nld_d_to_a_proxy(netlist_base_t &anetlist, const pstring &name, logic_output_t *out_proxied)
: nld_base_d_to_a_proxy(anetlist, name, out_proxied, m_RV.m_P)
, m_GNDHack(*this, "_Q")
, m_RV(*this, "RV")
diff --git a/src/lib/netlist/devices/nlid_proxy.h b/src/lib/netlist/devices/nlid_proxy.h
index 821cfa56d9d..eb1f2b3fe87 100644
--- a/src/lib/netlist/devices/nlid_proxy.h
+++ b/src/lib/netlist/devices/nlid_proxy.h
@@ -26,7 +26,7 @@ namespace netlist
NETLIB_OBJECT(base_proxy)
{
public:
- nld_base_proxy(netlist_t &anetlist, const pstring &name,
+ nld_base_proxy(netlist_base_t &anetlist, const pstring &name,
logic_t *inout_proxied, detail::core_terminal_t *proxy_inout);
virtual ~nld_base_proxy();
@@ -55,7 +55,7 @@ namespace netlist
protected:
- nld_base_a_to_d_proxy(netlist_t &anetlist, const pstring &name,
+ nld_base_a_to_d_proxy(netlist_base_t &anetlist, const pstring &name,
logic_input_t *in_proxied, detail::core_terminal_t *in_proxy);
private:
@@ -67,7 +67,7 @@ namespace netlist
NETLIB_OBJECT_DERIVED(a_to_d_proxy, base_a_to_d_proxy)
{
public:
- nld_a_to_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *in_proxied);
+ nld_a_to_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *in_proxied);
virtual ~nld_a_to_d_proxy() override;
@@ -93,7 +93,7 @@ namespace netlist
virtual logic_input_t &in() { return m_I; }
protected:
- nld_base_d_to_a_proxy(netlist_t &anetlist, const pstring &name,
+ nld_base_d_to_a_proxy(netlist_base_t &anetlist, const pstring &name,
logic_output_t *out_proxied, detail::core_terminal_t &proxy_out);
logic_input_t m_I;
@@ -104,7 +104,7 @@ namespace netlist
NETLIB_OBJECT_DERIVED(d_to_a_proxy, base_d_to_a_proxy)
{
public:
- nld_d_to_a_proxy(netlist_t &anetlist, const pstring &name, logic_output_t *out_proxied);
+ nld_d_to_a_proxy(netlist_base_t &anetlist, const pstring &name, logic_output_t *out_proxied);
virtual ~nld_d_to_a_proxy() override {}
protected:
diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h
index d1a8a04bb41..6acda365c8f 100644
--- a/src/lib/netlist/devices/nlid_system.h
+++ b/src/lib/netlist/devices/nlid_system.h
@@ -65,7 +65,7 @@ namespace netlist
logic_net_t &net = m_Q.net();
// this is only called during setup ...
net.toggle_new_Q();
- net.set_time(netlist().time() + m_inc);
+ net.set_time(exec().time() + m_inc);
}
public:
diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp
index 0b53652df6c..4cebc8c1b4c 100644
--- a/src/lib/netlist/devices/nlid_truthtable.cpp
+++ b/src/lib/netlist/devices/nlid_truthtable.cpp
@@ -233,7 +233,7 @@ namespace netlist
: netlist_base_factory_truthtable_t(name, classname, def_param, sourcefile)
{ }
- plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) override
+ plib::owned_ptr<device_t> Create(netlist_base_t &anetlist, const pstring &name) override
{
typedef nld_truthtable_t<m_NI, m_NO> tt_type;
truthtable_parser desc_s(m_NO, m_NI, &m_ttbl.m_initialized,
diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp
index d3de32d7d62..9c19d10f0c9 100644
--- a/src/lib/netlist/nl_base.cpp
+++ b/src/lib/netlist/nl_base.cpp
@@ -90,15 +90,15 @@ public:
m_R_low = 1.0;
m_R_high = 130.0;
}
- virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_t &anetlist, const pstring &name, logic_output_t *proxied) const override;
- virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *proxied) const override;
+ virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_base_t &anetlist, const pstring &name, logic_output_t *proxied) const override;
+ virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *proxied) const override;
};
-plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_ttl_t::create_d_a_proxy(netlist_t &anetlist, const pstring &name, logic_output_t *proxied) const
+plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_ttl_t::create_d_a_proxy(netlist_base_t &anetlist, const pstring &name, logic_output_t *proxied) const
{
return plib::owned_ptr<devices::nld_base_d_to_a_proxy>::Create<devices::nld_d_to_a_proxy>(anetlist, name, proxied);
}
-plib::owned_ptr<devices::nld_base_a_to_d_proxy> logic_family_ttl_t::create_a_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *proxied) const
+plib::owned_ptr<devices::nld_base_a_to_d_proxy> logic_family_ttl_t::create_a_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *proxied) const
{
return plib::owned_ptr<devices::nld_base_a_to_d_proxy>::Create<devices::nld_a_to_d_proxy>(anetlist, name, proxied);
}
@@ -117,15 +117,15 @@ public:
m_R_low = 10.0;
m_R_high = 10.0;
}
- virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_t &anetlist, const pstring &name, logic_output_t *proxied) const override;
- virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *proxied) const override;
+ virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_base_t &anetlist, const pstring &name, logic_output_t *proxied) const override;
+ virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *proxied) const override;
};
-plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_cd4xxx_t::create_d_a_proxy(netlist_t &anetlist, const pstring &name, logic_output_t *proxied) const
+plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_cd4xxx_t::create_d_a_proxy(netlist_base_t &anetlist, const pstring &name, logic_output_t *proxied) const
{
return plib::owned_ptr<devices::nld_base_d_to_a_proxy>::Create<devices::nld_d_to_a_proxy>(anetlist, name, proxied);
}
-plib::owned_ptr<devices::nld_base_a_to_d_proxy> logic_family_cd4xxx_t::create_a_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *proxied) const
+plib::owned_ptr<devices::nld_base_a_to_d_proxy> logic_family_cd4xxx_t::create_a_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *proxied) const
{
return plib::owned_ptr<devices::nld_base_a_to_d_proxy>::Create<devices::nld_a_to_d_proxy>(anetlist, name, proxied);
}
@@ -168,7 +168,7 @@ void detail::queue_t::on_pre_save()
{
netlist().log().debug("on_pre_save\n");
m_qsize = this->size();
- netlist().log().debug("current time {1} qsize {2}\n", netlist().time().as_double(), m_qsize);
+ netlist().log().debug("current time {1} qsize {2}\n", exec().time().as_double(), m_qsize);
for (std::size_t i = 0; i < m_qsize; i++ )
{
m_times[i] = this->listptr()[i].m_exec_time.as_raw();
@@ -180,7 +180,7 @@ void detail::queue_t::on_pre_save()
void detail::queue_t::on_post_load()
{
this->clear();
- netlist().log().debug("current time {1} qsize {2}\n", netlist().time().as_double(), m_qsize);
+ netlist().log().debug("current time {1} qsize {2}\n", exec().time().as_double(), m_qsize);
for (std::size_t i = 0; i < m_qsize; i++ )
{
detail::net_t *n = netlist().nets()[m_net_ids[i]].get();
@@ -240,35 +240,43 @@ detail::terminal_type detail::core_terminal_t::type() const
// ----------------------------------------------------------------------------------------
netlist_t::netlist_t(const pstring &aname, std::unique_ptr<callbacks_t> callbacks)
- : m_time(netlist_time::zero())
- , m_queue(*this)
+ : netlist_base_t(aname, std::move(callbacks))
+ , m_time(netlist_time::zero())
, m_mainclock(nullptr)
+ , m_queue(*this)
, m_solver(nullptr)
- , m_params(nullptr)
+{
+ state().save_item(this, static_cast<plib::state_manager_t::callback_t &>(m_queue), "m_queue");
+ state().save_item(this, m_time, "m_time");
+}
+
+netlist_t::~netlist_t()
+{
+}
+
+// ----------------------------------------------------------------------------------------
+// netlist_t
+// ----------------------------------------------------------------------------------------
+
+netlist_base_t::netlist_base_t(const pstring &aname, std::unique_ptr<callbacks_t> callbacks)
+ :m_params(nullptr)
, m_name(aname)
, m_lib(nullptr)
, m_state()
, m_callbacks(std::move(callbacks)) // Order is important here
, m_log(*m_callbacks)
{
- state().save_item(this, static_cast<plib::state_manager_t::callback_t &>(m_queue), "m_queue");
- state().save_item(this, m_time, "m_time");
m_setup = plib::make_unique<setup_t>(*this);
NETLIST_NAME(base)(*m_setup);
}
-netlist_t::~netlist_t()
+netlist_base_t::~netlist_base_t()
{
m_nets.clear();
m_devices.clear();
}
-nl_double netlist_t::gmin() const NL_NOEXCEPT
-{
- return solver()->gmin();
-}
-
-void netlist_t::register_dev(plib::owned_ptr<core_device_t> dev)
+void netlist_base_t::register_dev(plib::owned_ptr<core_device_t> dev)
{
for (auto & d : m_devices)
if (d->name() == dev->name())
@@ -276,7 +284,7 @@ void netlist_t::register_dev(plib::owned_ptr<core_device_t> dev)
m_devices.push_back(std::move(dev));
}
-void netlist_t::remove_dev(core_device_t *dev)
+void netlist_base_t::remove_dev(core_device_t *dev)
{
m_devices.erase(
std::remove_if(
@@ -290,7 +298,23 @@ void netlist_t::remove_dev(core_device_t *dev)
);
}
-void netlist_t::prepare_to_run()
+void netlist_base_t::delete_empty_nets()
+{
+ m_nets.erase(
+ std::remove_if(m_nets.begin(), m_nets.end(),
+ [](plib::owned_ptr<detail::net_t> &x)
+ {
+ if (x->num_cons() == 0)
+ {
+ x->netlist().log().verbose("Deleting net {1} ...", x->name());
+ return true;
+ }
+ else
+ return false;
+ }), m_nets.end());
+}
+
+void netlist_base_t::prepare_to_run()
{
setup().register_dynamic_log_devices();
@@ -310,7 +334,7 @@ void netlist_t::prepare_to_run()
log().debug("Searching for solver and parameters ...\n");
- m_solver = get_single_device<devices::NETLIB_NAME(solver)>("solver");
+ auto solver = get_single_device<devices::NETLIB_NAME(solver)>("solver");
m_params = get_single_device<devices::NETLIB_NAME(netlistparams)>("parameter");
/* create devices */
@@ -326,9 +350,6 @@ void netlist_t::prepare_to_run()
}
}
- log().debug("Searching for mainclock\n");
- m_mainclock = get_single_device<devices::NETLIB_NAME(mainclock)>("mainclock");
-
bool use_deactivate = (m_params->m_use_deactivate() ? true : false);
for (auto &d : m_devices)
@@ -370,14 +391,14 @@ void netlist_t::prepare_to_run()
log().verbose("initialize solver ...\n");
- if (m_solver == nullptr)
+ if (solver == nullptr)
{
for (auto &p : m_nets)
if (p->is_analog())
log().fatal(MF_0_NO_SOLVER);
}
else
- m_solver->post_start();
+ solver->post_start();
for (auto &n : m_nets)
for (auto & term : n->m_core_terms)
@@ -398,7 +419,7 @@ void netlist_t::stop()
m_solver->stop();
}
-detail::net_t *netlist_t::find_net(const pstring &name) const
+detail::net_t *netlist_base_t::find_net(const pstring &name) const
{
for (auto & net : m_nets)
if (net->name() == name)
@@ -407,7 +428,7 @@ detail::net_t *netlist_t::find_net(const pstring &name) const
return nullptr;
}
-std::size_t netlist_t::find_net_id(const detail::net_t *net) const
+std::size_t netlist_base_t::find_net_id(const detail::net_t *net) const
{
for (std::size_t i = 0; i < m_nets.size(); i++)
if (m_nets[i].get() == net)
@@ -417,7 +438,7 @@ std::size_t netlist_t::find_net_id(const detail::net_t *net) const
-void netlist_t::rebuild_lists()
+void netlist_base_t::rebuild_lists()
{
for (auto & net : m_nets)
net->rebuild_list();
@@ -426,6 +447,12 @@ void netlist_t::rebuild_lists()
void netlist_t::reset()
{
+ log().debug("Searching for mainclock\n");
+ m_mainclock = get_single_device<devices::NETLIB_NAME(mainclock)>("mainclock");
+
+ log().debug("Searching for solver\n");
+ m_solver = get_single_device<devices::NETLIB_NAME(solver)>("solver");
+
m_time = netlist_time::zero();
m_queue.clear();
if (m_mainclock != nullptr)
@@ -638,7 +665,7 @@ void netlist_t::print_stats() const
}
}
-core_device_t *netlist_t::get_single_device(const pstring &classname, bool (*cc)(core_device_t *)) const
+core_device_t *netlist_base_t::get_single_device(const pstring &classname, bool (*cc)(core_device_t *)) const
{
core_device_t *ret = nullptr;
for (auto &d : m_devices)
@@ -659,7 +686,7 @@ core_device_t *netlist_t::get_single_device(const pstring &classname, bool (*cc)
// core_device_t
// ----------------------------------------------------------------------------------------
-core_device_t::core_device_t(netlist_t &owner, const pstring &name)
+core_device_t::core_device_t(netlist_base_t &owner, const pstring &name)
: object_t(name)
, logic_family_t()
, netlist_ref(owner)
@@ -700,7 +727,7 @@ log_type & core_device_t::log()
// device_t
// ----------------------------------------------------------------------------------------
-device_t::device_t(netlist_t &owner, const pstring &name)
+device_t::device_t(netlist_base_t &owner, const pstring &name)
: core_device_t(owner, name)
{
}
@@ -780,7 +807,7 @@ detail::family_setter_t::family_setter_t(core_device_t &dev, const logic_family_
// net_t
// ----------------------------------------------------------------------------------------
-detail::net_t::net_t(netlist_t &nl, const pstring &aname, core_terminal_t *mr)
+detail::net_t::net_t(netlist_base_t &nl, const pstring &aname, core_terminal_t *mr)
: object_t(aname)
, netlist_ref(nl)
, m_new_Q(*this, "m_new_Q", 0)
@@ -805,10 +832,10 @@ void detail::net_t::add_to_active_list(core_terminal_t &term) NL_NOEXCEPT
railterminal().device().do_inc_active();
if (m_in_queue == QS_DELAYED_DUE_TO_INACTIVE)
{
- if (m_time > netlist().time())
+ if (m_time > exec().time())
{
m_in_queue = QS_QUEUED; /* pending */
- netlist().queue().push({m_time, this});
+ exec().queue().push({m_time, this});
}
else
{
@@ -934,7 +961,7 @@ void detail::net_t::move_connections(detail::net_t &dest_net)
// logic_net_t
// ----------------------------------------------------------------------------------------
-logic_net_t::logic_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr)
+logic_net_t::logic_net_t(netlist_base_t &nl, const pstring &aname, detail::core_terminal_t *mr)
: net_t(nl, aname, mr)
{
}
@@ -947,7 +974,7 @@ logic_net_t::~logic_net_t()
// analog_net_t
// ----------------------------------------------------------------------------------------
-analog_net_t::analog_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr)
+analog_net_t::analog_net_t(netlist_base_t &nl, const pstring &aname, detail::core_terminal_t *mr)
: net_t(nl, aname, mr)
, m_cur_Analog(*this, "m_cur_Analog", 0.0)
, m_solver(nullptr)
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index 9871da2a9d1..3d8ef2401d5 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -211,6 +211,7 @@ namespace netlist
class net_t;
class setup_t;
class netlist_t;
+ class netlist_base_t;
class core_device_t;
class device_t;
class callbacks_t;
@@ -246,9 +247,9 @@ namespace netlist
logic_family_desc_t();
virtual ~logic_family_desc_t();
- virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_t &anetlist, const pstring &name,
+ virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_base_t &anetlist, const pstring &name,
logic_output_t *proxied) const = 0;
- virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_t &anetlist, const pstring &name,
+ virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_base_t &anetlist, const pstring &name,
logic_input_t *proxied) const = 0;
double fixed_V() const { return m_fixed_V; }
@@ -424,16 +425,19 @@ namespace netlist
struct detail::netlist_ref
{
- explicit constexpr netlist_ref(netlist_t &nl) : m_netlist(nl) { }
+ explicit constexpr netlist_ref(netlist_base_t &nl) : m_netlist(nl) { }
- C14CONSTEXPR netlist_t & netlist() NL_NOEXCEPT { return m_netlist; }
- constexpr const netlist_t & netlist() const NL_NOEXCEPT { return m_netlist; }
+ C14CONSTEXPR netlist_base_t & netlist() NL_NOEXCEPT { return m_netlist; }
+ constexpr const netlist_base_t & netlist() const NL_NOEXCEPT { return m_netlist; }
+
+ netlist_t & exec() NL_NOEXCEPT { return *reinterpret_cast<netlist_t *>(&m_netlist); }
+ const netlist_t & exec() const NL_NOEXCEPT { return *reinterpret_cast<const netlist_t *>(&m_netlist); }
protected:
~netlist_ref() = default; // prohibit polymorphic destruction
private:
- netlist_t & m_netlist;
+ netlist_base_t & m_netlist;
};
@@ -465,8 +469,11 @@ namespace netlist
/*! The netlist owning the owner of this object.
* \returns reference to netlist object.
*/
- netlist_t &netlist() NL_NOEXCEPT;
- const netlist_t &netlist() const NL_NOEXCEPT;
+ netlist_base_t &netlist() NL_NOEXCEPT;
+ const netlist_base_t &netlist() const NL_NOEXCEPT;
+
+ netlist_t &exec() NL_NOEXCEPT;
+ const netlist_t &exec() const NL_NOEXCEPT;
private:
core_device_t & m_device;
@@ -709,7 +716,7 @@ namespace netlist
QS_DELIVERED
};
- net_t(netlist_t &nl, const pstring &aname, core_terminal_t *mr = nullptr);
+ net_t(netlist_base_t &nl, const pstring &aname, core_terminal_t *mr = nullptr);
virtual ~net_t();
void reset();
@@ -769,7 +776,7 @@ namespace netlist
{
public:
- logic_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr);
+ logic_net_t(netlist_base_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr);
virtual ~logic_net_t();
const netlist_sig_t & Q() const NL_NOEXCEPT { return m_cur_Q; }
@@ -820,7 +827,7 @@ namespace netlist
friend class detail::net_t;
- analog_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr);
+ analog_net_t(netlist_base_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr);
virtual ~analog_net_t();
@@ -1069,7 +1076,7 @@ namespace netlist
public detail::netlist_ref
{
public:
- core_device_t(netlist_t &owner, const pstring &name);
+ core_device_t(netlist_base_t &owner, const pstring &name);
core_device_t(core_device_t &owner, const pstring &name);
virtual ~core_device_t();
@@ -1141,7 +1148,7 @@ namespace netlist
{
public:
- device_t(netlist_t &owner, const pstring &name);
+ device_t(netlist_base_t &owner, const pstring &name);
device_t(core_device_t &owner, const pstring &name);
virtual ~device_t() override;
@@ -1224,31 +1231,14 @@ namespace netlist
// netlist_t
// -----------------------------------------------------------------------------
-
- class netlist_t : private plib::nocopyassignmove
+ class netlist_base_t : private plib::nocopyassignmove
{
public:
using nets_collection_type = std::vector<plib::owned_ptr<detail::net_t>>;
- explicit netlist_t(const pstring &aname, std::unique_ptr<callbacks_t> callbacks);
- ~netlist_t();
-
- /* run functions */
-
- const netlist_time &time() const NL_NOEXCEPT { return m_time; }
- devices::NETLIB_NAME(solver) *solver() const NL_NOEXCEPT { return m_solver; }
-
- /* never use this in constructors! */
- nl_double gmin() const NL_NOEXCEPT;
-
- void process_queue(const netlist_time &delta) NL_NOEXCEPT;
- void abort_current_queue_slice() NL_NOEXCEPT { m_queue.retime(detail::queue_t::entry_t(m_time, nullptr)); }
-
- const detail::queue_t &queue() const NL_NOEXCEPT { return m_queue; }
- detail::queue_t &queue() NL_NOEXCEPT { return m_queue; }
-
- /* setup functions - not needed by execute interface */
+ explicit netlist_base_t(const pstring &aname, std::unique_ptr<callbacks_t> callbacks);
+ ~netlist_base_t();
/* Control functions */
@@ -1330,41 +1320,23 @@ namespace netlist
m_nets.push_back(std::move(net));
}
- void delete_empty_nets()
- {
- m_nets.erase(
- std::remove_if(m_nets.begin(), m_nets.end(),
- [](plib::owned_ptr<detail::net_t> &x)
- {
- if (x->num_cons() == 0)
- {
- x->netlist().log().verbose("Deleting net {1} ...", x->name());
- return true;
- }
- else
- return false;
- }), m_nets.end());
- }
+ void delete_empty_nets();
/* sole use is to manage lifetime of family objects */
std::vector<std::pair<pstring, std::unique_ptr<logic_family_desc_t>>> m_family_cache;
protected:
- void print_stats() const;
+ /* sole use is to manage lifetime of net objects */
+ std::vector<plib::owned_ptr<core_device_t>> m_devices;
+ nets_collection_type m_nets;
private:
core_device_t *get_single_device(const pstring &classname, bool (*cc)(core_device_t *)) const;
- /* mostly rw */
- netlist_time m_time;
- detail::queue_t m_queue;
-
/* mostly ro */
- devices::NETLIB_NAME(mainclock) * m_mainclock;
- devices::NETLIB_NAME(solver) * m_solver;
devices::NETLIB_NAME(netlistparams) *m_params;
pstring m_name;
@@ -1372,17 +1344,62 @@ namespace netlist
plib::state_manager_t m_state;
- // performance
- nperftime_t<NL_KEEP_STATISTICS> m_stat_mainloop;
- nperfcount_t<NL_KEEP_STATISTICS> m_perf_out_processed;
- /* sole use is to manage lifetime of net objects */
- std::vector<plib::owned_ptr<core_device_t>> m_devices;
- nets_collection_type m_nets;
-
- std::unique_ptr<callbacks_t> m_callbacks;
+ std::unique_ptr<callbacks_t> m_callbacks;
log_type m_log;
std::unique_ptr<setup_t> m_setup;
+ };
+
+
+ class netlist_t : public netlist_base_t
+ {
+ public:
+
+ using nets_collection_type = std::vector<plib::owned_ptr<detail::net_t>>;
+
+ explicit netlist_t(const pstring &aname, std::unique_ptr<callbacks_t> callbacks);
+ ~netlist_t();
+
+ /* run functions */
+
+ const netlist_time &time() const NL_NOEXCEPT { return m_time; }
+
+ void process_queue(const netlist_time &delta) NL_NOEXCEPT;
+ void abort_current_queue_slice() NL_NOEXCEPT { m_queue.retime(detail::queue_t::entry_t(m_time, nullptr)); }
+
+ const detail::queue_t &queue() const NL_NOEXCEPT { return m_queue; }
+ detail::queue_t &queue() NL_NOEXCEPT { return m_queue; }
+
+ /* Control functions */
+
+ void stop();
+ void reset();
+
+ /* only used by nltool to create static c-code */
+ devices::NETLIB_NAME(solver) *solver() const NL_NOEXCEPT { return m_solver; }
+
+ /* force late type resolution */
+ template <typename X = devices::NETLIB_NAME(solver)>
+ nl_double gmin(X *solv = nullptr) const NL_NOEXCEPT
+ {
+ return static_cast<X *>(m_solver)->gmin();
+ }
+
+ protected:
+
+ void print_stats() const;
+
+ private:
+ /* mostly rw */
+ netlist_time m_time;
+ devices::NETLIB_NAME(mainclock) * m_mainclock;
+ detail::queue_t m_queue;
+
+ devices::NETLIB_NAME(solver) * m_solver;
+
+ // performance
+ nperftime_t<NL_KEEP_STATISTICS> m_stat_mainloop;
+ nperfcount_t<NL_KEEP_STATISTICS> m_perf_out_processed;
};
// -----------------------------------------------------------------------------
@@ -1482,11 +1499,11 @@ namespace netlist
if ((num_cons() != 0))
{
if (is_queued())
- netlist().queue().remove(this);
- m_time = netlist().time() + delay;
+ exec().queue().remove(this);
+ m_time = exec().time() + delay;
m_in_queue = (!m_list_active.empty()) ? QS_QUEUED : QS_DELAYED_DUE_TO_INACTIVE; /* queued ? */
if (m_in_queue == QS_QUEUED)
- netlist().queue().push(queue_t::entry_t(m_time, this));
+ exec().queue().push(queue_t::entry_t(m_time, this));
}
}
@@ -1532,16 +1549,26 @@ namespace netlist
}
}
- inline netlist_t &detail::device_object_t::netlist() NL_NOEXCEPT
+ inline netlist_base_t &detail::device_object_t::netlist() NL_NOEXCEPT
{
return m_device.netlist();
}
- inline const netlist_t &detail::device_object_t::netlist() const NL_NOEXCEPT
+ inline const netlist_base_t &detail::device_object_t::netlist() const NL_NOEXCEPT
{
return m_device.netlist();
}
+ inline netlist_t &detail::device_object_t::exec() NL_NOEXCEPT
+ {
+ return m_device.exec();
+ }
+
+ inline const netlist_t &detail::device_object_t::exec() const NL_NOEXCEPT
+ {
+ return m_device.exec();
+ }
+
template <typename T>
template <typename O>
state_var<T>::state_var(O &owner, const pstring &name, const T &value)
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index b72e0ee9944..dd94981d4ee 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -49,9 +49,8 @@
// savings are eaten up by effort
// FIXME: Convert into solver parameter
#define USE_LINEAR_PREDICTION (0)
-#define NETLIST_GMIN_DEFAULT (1e-9)
-
+#define NETLIST_GMIN_DEFAULT (1e-9)
//============================================================
// DEBUGGING
diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp
index bfefe5dd5e0..973b1b7814f 100644
--- a/src/lib/netlist/nl_factory.cpp
+++ b/src/lib/netlist/nl_factory.cpp
@@ -20,7 +20,7 @@ namespace netlist { namespace factory
class NETLIB_NAME(wrapper) : public device_t
{
public:
- NETLIB_NAME(wrapper)(netlist_t &anetlist, const pstring &name)
+ NETLIB_NAME(wrapper)(netlist_base_t &anetlist, const pstring &name)
: device_t(anetlist, name)
{
}
@@ -91,12 +91,12 @@ factory::element_t * list_t::factory_by_name(const pstring &devname)
// factory_lib_entry_t: factory class to wrap macro based chips/elements
// -----------------------------------------------------------------------------
-plib::owned_ptr<device_t> library_element_t::Create(netlist_t &anetlist, const pstring &name)
+plib::owned_ptr<device_t> library_element_t::Create(netlist_base_t &anetlist, const pstring &name)
{
return plib::owned_ptr<device_t>::Create<NETLIB_NAME(wrapper)>(anetlist, name);
}
-void library_element_t::macro_actions(netlist_t &anetlist, const pstring &name)
+void library_element_t::macro_actions(netlist_base_t &anetlist, const pstring &name)
{
anetlist.setup().namespace_push(name);
anetlist.setup().include(this->name());
diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h
index 2e5ba33c8b1..77da4193951 100644
--- a/src/lib/netlist/nl_factory.h
+++ b/src/lib/netlist/nl_factory.h
@@ -40,7 +40,7 @@
factory::constructor_ptr_t decl_ ## chip = NETLIB_NAME(chip ## _c);
namespace netlist {
- class netlist_t;
+ class netlist_base_t;
class device_t;
class setup_t;
@@ -58,8 +58,8 @@ namespace factory {
const pstring &def_param, const pstring &sourcefile);
virtual ~element_t();
- virtual plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) = 0;
- virtual void macro_actions(netlist_t &anetlist, const pstring &name) {}
+ virtual plib::owned_ptr<device_t> Create(netlist_base_t &anetlist, const pstring &name) = 0;
+ virtual void macro_actions(netlist_base_t &anetlist, const pstring &name) {}
const pstring &name() const { return m_name; }
const pstring &classname() const { return m_classname; }
@@ -84,7 +84,7 @@ namespace factory {
const pstring &def_param, const pstring &sourcefile)
: element_t(name, classname, def_param, sourcefile) { }
- plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) override
+ plib::owned_ptr<device_t> Create(netlist_base_t &anetlist, const pstring &name) override
{
return plib::owned_ptr<device_t>::Create<C>(anetlist, name);
}
@@ -143,9 +143,9 @@ namespace factory {
const pstring &def_param, const pstring &source)
: element_t(name, classname, def_param, source) { }
- plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) override;
+ plib::owned_ptr<device_t> Create(netlist_base_t &anetlist, const pstring &name) override;
- void macro_actions(netlist_t &anetlist, const pstring &name) override;
+ void macro_actions(netlist_base_t &anetlist, const pstring &name) override;
private:
};
diff --git a/src/lib/netlist/nl_parser.h b/src/lib/netlist/nl_parser.h
index 872cfa11954..26f9179c040 100644
--- a/src/lib/netlist/nl_parser.h
+++ b/src/lib/netlist/nl_parser.h
@@ -39,7 +39,7 @@ namespace netlist
void net_truthtable_start(const pstring &nlname);
/* for debugging messages */
- netlist_t &netlist() { return m_setup.netlist(); }
+ netlist_base_t &netlist() { return m_setup.netlist(); }
virtual void verror(const pstring &msg, int line_num, const pstring &line) override;
private:
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index 8d0ffc66bc9..9d004c76c28 100644
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -25,7 +25,7 @@
namespace netlist
{
-setup_t::setup_t(netlist_t &netlist)
+setup_t::setup_t(netlist_base_t &netlist)
: m_netlist(netlist)
, m_factory(*this)
, m_proxy_cnt(0)
@@ -841,17 +841,17 @@ class logic_family_std_proxy_t : public logic_family_desc_t
{
public:
logic_family_std_proxy_t() { }
- virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_t &anetlist,
+ virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_base_t &anetlist,
const pstring &name, logic_output_t *proxied) const override;
- virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *proxied) const override;
+ virtual plib::owned_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *proxied) const override;
};
-plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_std_proxy_t::create_d_a_proxy(netlist_t &anetlist,
+plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_std_proxy_t::create_d_a_proxy(netlist_base_t &anetlist,
const pstring &name, logic_output_t *proxied) const
{
return plib::owned_ptr<devices::nld_base_d_to_a_proxy>::Create<devices::nld_d_to_a_proxy>(anetlist, name, proxied);
}
-plib::owned_ptr<devices::nld_base_a_to_d_proxy> logic_family_std_proxy_t::create_a_d_proxy(netlist_t &anetlist, const pstring &name, logic_input_t *proxied) const
+plib::owned_ptr<devices::nld_base_a_to_d_proxy> logic_family_std_proxy_t::create_a_d_proxy(netlist_base_t &anetlist, const pstring &name, logic_input_t *proxied) const
{
return plib::owned_ptr<devices::nld_base_a_to_d_proxy>::Create<devices::nld_a_to_d_proxy>(anetlist, name, proxied);
}
diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h
index 25342e933f6..3b2f5c874a6 100644
--- a/src/lib/netlist/nl_setup.h
+++ b/src/lib/netlist/nl_setup.h
@@ -127,7 +127,7 @@ namespace netlist
class core_device_t;
class param_t;
class setup_t;
- class netlist_t;
+ class netlist_base_t;
class logic_family_desc_t;
class terminal_t;
@@ -204,11 +204,11 @@ namespace netlist
using link_t = std::pair<pstring, pstring>;
- explicit setup_t(netlist_t &netlist);
+ explicit setup_t(netlist_base_t &netlist);
~setup_t();
- netlist_t &netlist() { return m_netlist; }
- const netlist_t &netlist() const { return m_netlist; }
+ netlist_base_t &netlist() { return m_netlist; }
+ const netlist_base_t &netlist() const { return m_netlist; }
pstring build_fqn(const pstring &obj_name) const;
@@ -319,7 +319,7 @@ namespace netlist
devices::nld_base_proxy *get_d_a_proxy(detail::core_terminal_t &out);
devices::nld_base_proxy *get_a_d_proxy(detail::core_terminal_t &inp);
- netlist_t &m_netlist;
+ netlist_base_t &m_netlist;
std::unordered_map<pstring, param_ref_t> m_params;
std::vector<link_t> m_links;
factory::list_t m_factory;
diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp
index 0b2e89df08f..fd76b88dee8 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.cpp
+++ b/src/lib/netlist/solver/nld_matrix_solver.cpp
@@ -74,7 +74,7 @@ void terms_for_net_t::set_pointers()
// matrix_solver
// ----------------------------------------------------------------------------------------
-matrix_solver_t::matrix_solver_t(netlist_t &anetlist, const pstring &name,
+matrix_solver_t::matrix_solver_t(netlist_base_t &anetlist, const pstring &name,
const eSortType sort, const solver_parameters_t *params)
: device_t(anetlist, name)
, m_params(*params)
@@ -439,7 +439,7 @@ void matrix_solver_t::solve_base()
const netlist_time matrix_solver_t::solve()
{
- const netlist_time now = netlist().time();
+ const netlist_time now = exec().time();
const netlist_time delta = now - m_last_step;
// We are already up to date. Avoid oscillations.
@@ -545,7 +545,7 @@ void matrix_solver_t::log_stats()
static_cast<double>(this->m_stat_newton_raphson) / static_cast<double>(this->m_stat_vsolver_calls));
log().verbose(" {1:10} invocations ({2:6.0} Hz) {3:10} gs fails ({4:6.2} %) {5:6.3} average",
this->m_stat_calculations,
- static_cast<double>(this->m_stat_calculations) / this->netlist().time().as_double(),
+ static_cast<double>(this->m_stat_calculations) / this->exec().time().as_double(),
this->m_iterative_fail,
100.0 * static_cast<double>(this->m_iterative_fail)
/ static_cast<double>(this->m_stat_calculations),
diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h
index 5cbbe59b8d0..044d431468b 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.h
+++ b/src/lib/netlist/solver/nld_matrix_solver.h
@@ -144,7 +144,7 @@ public:
protected:
- matrix_solver_t(netlist_t &anetlist, const pstring &name,
+ matrix_solver_t(netlist_base_t &anetlist, const pstring &name,
const eSortType sort, const solver_parameters_t *params);
void setup_base(analog_net_t::list_t &nets);
diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h
index defa03bc044..7414f16db4c 100644
--- a/src/lib/netlist/solver/nld_ms_direct.h
+++ b/src/lib/netlist/solver/nld_ms_direct.h
@@ -36,8 +36,8 @@ class matrix_solver_direct_t: public matrix_solver_t
friend class matrix_solver_t;
public:
- matrix_solver_direct_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size);
- matrix_solver_direct_t(netlist_t &anetlist, const pstring &name, const eSortType sort, const solver_parameters_t *params, const std::size_t size);
+ matrix_solver_direct_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size);
+ matrix_solver_direct_t(netlist_base_t &anetlist, const pstring &name, const eSortType sort, const solver_parameters_t *params, const std::size_t size);
virtual ~matrix_solver_direct_t() override;
@@ -253,7 +253,7 @@ unsigned matrix_solver_direct_t<m_N, storage_N>::vsolve_non_dynamic(const bool n
}
template <std::size_t m_N, std::size_t storage_N>
-matrix_solver_direct_t<m_N, storage_N>::matrix_solver_direct_t(netlist_t &anetlist, const pstring &name,
+matrix_solver_direct_t<m_N, storage_N>::matrix_solver_direct_t(netlist_base_t &anetlist, const pstring &name,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_t(anetlist, name, ASCENDING, params)
, m_dim(size)
@@ -269,7 +269,7 @@ matrix_solver_direct_t<m_N, storage_N>::matrix_solver_direct_t(netlist_t &anetli
}
template <std::size_t m_N, std::size_t storage_N>
-matrix_solver_direct_t<m_N, storage_N>::matrix_solver_direct_t(netlist_t &anetlist, const pstring &name,
+matrix_solver_direct_t<m_N, storage_N>::matrix_solver_direct_t(netlist_base_t &anetlist, const pstring &name,
const eSortType sort, const solver_parameters_t *params, const std::size_t size)
: matrix_solver_t(anetlist, name, sort, params)
, m_dim(size)
diff --git a/src/lib/netlist/solver/nld_ms_direct1.h b/src/lib/netlist/solver/nld_ms_direct1.h
index 4967a9dc637..4ffbb833bc3 100644
--- a/src/lib/netlist/solver/nld_ms_direct1.h
+++ b/src/lib/netlist/solver/nld_ms_direct1.h
@@ -19,7 +19,7 @@ class matrix_solver_direct1_t: public matrix_solver_direct_t<1,1>
{
public:
- matrix_solver_direct1_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params)
+ matrix_solver_direct1_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params)
: matrix_solver_direct_t<1, 1>(anetlist, name, params, 1)
{}
virtual unsigned vsolve_non_dynamic(const bool newton_raphson) override;
diff --git a/src/lib/netlist/solver/nld_ms_direct2.h b/src/lib/netlist/solver/nld_ms_direct2.h
index 65cf30c0202..75bfd6e0803 100644
--- a/src/lib/netlist/solver/nld_ms_direct2.h
+++ b/src/lib/netlist/solver/nld_ms_direct2.h
@@ -19,7 +19,7 @@ class matrix_solver_direct2_t: public matrix_solver_direct_t<2,2>
{
public:
- matrix_solver_direct2_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params)
+ matrix_solver_direct2_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params)
: matrix_solver_direct_t<2, 2>(anetlist, name, params, 2)
{}
virtual unsigned vsolve_non_dynamic(const bool newton_raphson) override;
diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h
index dee76dd8281..b49d9e64602 100644
--- a/src/lib/netlist/solver/nld_ms_gcr.h
+++ b/src/lib/netlist/solver/nld_ms_gcr.h
@@ -28,7 +28,7 @@ class matrix_solver_GCR_t: public matrix_solver_t
{
public:
- matrix_solver_GCR_t(netlist_t &anetlist, const pstring &name,
+ matrix_solver_GCR_t(netlist_base_t &anetlist, const pstring &name,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_t(anetlist, name, matrix_solver_t::ASCENDING, params)
, m_dim(size)
diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h
index 2a73d45d3d1..4310af1b8de 100644
--- a/src/lib/netlist/solver/nld_ms_gmres.h
+++ b/src/lib/netlist/solver/nld_ms_gmres.h
@@ -29,7 +29,7 @@ class matrix_solver_GMRES_t: public matrix_solver_direct_t<m_N, storage_N>
{
public:
- matrix_solver_GMRES_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size)
+ matrix_solver_GMRES_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size)
: matrix_solver_direct_t<m_N, storage_N>(anetlist, name, matrix_solver_t::ASCENDING, params, size)
, m_use_iLU_preconditioning(true)
, m_use_more_precise_stop_condition(false)
diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h
index 42d35e9b14c..4b0f6940798 100644
--- a/src/lib/netlist/solver/nld_ms_sm.h
+++ b/src/lib/netlist/solver/nld_ms_sm.h
@@ -54,7 +54,7 @@ class matrix_solver_sm_t: public matrix_solver_t
public:
- matrix_solver_sm_t(netlist_t &anetlist, const pstring &name,
+ matrix_solver_sm_t(netlist_base_t &anetlist, const pstring &name,
const solver_parameters_t *params, const std::size_t size);
virtual ~matrix_solver_sm_t() override;
@@ -307,7 +307,7 @@ unsigned matrix_solver_sm_t<m_N, storage_N>::vsolve_non_dynamic(const bool newto
}
template <std::size_t m_N, std::size_t storage_N>
-matrix_solver_sm_t<m_N, storage_N>::matrix_solver_sm_t(netlist_t &anetlist, const pstring &name,
+matrix_solver_sm_t<m_N, storage_N>::matrix_solver_sm_t(netlist_base_t &anetlist, const pstring &name,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_t(anetlist, name, NOSORT, params)
, m_dim(size)
diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h
index eea692d6c47..1cc588a3e29 100644
--- a/src/lib/netlist/solver/nld_ms_sor.h
+++ b/src/lib/netlist/solver/nld_ms_sor.h
@@ -26,7 +26,7 @@ class matrix_solver_SOR_t: public matrix_solver_direct_t<m_N, storage_N>
{
public:
- matrix_solver_SOR_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size)
+ matrix_solver_SOR_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size)
: matrix_solver_direct_t<m_N, storage_N>(anetlist, name, matrix_solver_t::ASCENDING, params, size)
, m_lp_fact(*this, "m_lp_fact", 0)
{
diff --git a/src/lib/netlist/solver/nld_ms_sor_mat.h b/src/lib/netlist/solver/nld_ms_sor_mat.h
index 50bcac1a52d..7e80877d36e 100644
--- a/src/lib/netlist/solver/nld_ms_sor_mat.h
+++ b/src/lib/netlist/solver/nld_ms_sor_mat.h
@@ -29,7 +29,7 @@ class matrix_solver_SOR_mat_t: public matrix_solver_direct_t<m_N, storage_N>
public:
- matrix_solver_SOR_mat_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params, std::size_t size)
+ matrix_solver_SOR_mat_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params, std::size_t size)
: matrix_solver_direct_t<m_N, storage_N>(anetlist, name, matrix_solver_t::DESCENDING, params, size)
, m_Vdelta(*this, "m_Vdelta", 0.0)
, m_omega(*this, "m_omega", params->m_gs_sor)
diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h
index 4a2710a513d..ac7ea36a6a7 100644
--- a/src/lib/netlist/solver/nld_ms_w.h
+++ b/src/lib/netlist/solver/nld_ms_w.h
@@ -60,7 +60,7 @@ class matrix_solver_w_t: public matrix_solver_t
friend class matrix_solver_t;
public:
- matrix_solver_w_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size);
+ matrix_solver_w_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size);
virtual ~matrix_solver_w_t() override;
@@ -374,7 +374,7 @@ unsigned matrix_solver_w_t<m_N, storage_N>::vsolve_non_dynamic(const bool newton
}
template <std::size_t m_N, std::size_t storage_N>
-matrix_solver_w_t<m_N, storage_N>::matrix_solver_w_t(netlist_t &anetlist, const pstring &name,
+matrix_solver_w_t<m_N, storage_N>::matrix_solver_w_t(netlist_base_t &anetlist, const pstring &name,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_t(anetlist, name, NOSORT, params)
,m_cnt(0)
diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp
index 7373b2be963..f7a25fa7fcc 100644
--- a/src/lib/netlist/solver/nld_solver.cpp
+++ b/src/lib/netlist/solver/nld_solver.cpp
@@ -95,7 +95,7 @@ NETLIB_UPDATE(solver)
/* force solving during start up if there are no time-step devices */
/* FIXME: Needs a more elegant solution */
- bool force_solve = (netlist().time() < netlist_time::from_double(2 * m_params.m_max_timestep));
+ bool force_solve = (exec().time() < netlist_time::from_double(2 * m_params.m_max_timestep));
std::size_t nthreads = std::min(static_cast<std::size_t>(m_parallel()), plib::omp::get_max_threads());
@@ -128,7 +128,7 @@ NETLIB_UPDATE(solver)
}
template <class C>
-matrix_solver_t * create_it(netlist_t &nl, pstring name, solver_parameters_t &params, std::size_t size)
+matrix_solver_t * create_it(netlist_base_t &nl, pstring name, solver_parameters_t &params, std::size_t size)
{
return plib::palloc<C>(nl, name, &params, size);
}
@@ -213,7 +213,7 @@ struct net_splitter
}
}
- void run(netlist_t &netlist)
+ void run(netlist_base_t &netlist)
{
for (auto & net : netlist.nets())
{
diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h
index 8619f66f095..a52730773a7 100644
--- a/src/lib/netlist/solver/nld_solver.h
+++ b/src/lib/netlist/solver/nld_solver.h
@@ -68,7 +68,7 @@ NETLIB_OBJECT(solver)
void post_start();
void stop();
- nl_double gmin() { return m_gmin(); }
+ nl_double gmin() const { return m_gmin(); }
void create_solver_code(std::map<pstring, pstring> &mp);