summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/devices/nld_4066.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/devices/nld_4066.cpp')
-rw-r--r--src/lib/netlist/devices/nld_4066.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/netlist/devices/nld_4066.cpp b/src/lib/netlist/devices/nld_4066.cpp
index bd9b7bfe004..a45b2ab9e22 100644
--- a/src/lib/netlist/devices/nld_4066.cpp
+++ b/src/lib/netlist/devices/nld_4066.cpp
@@ -23,6 +23,7 @@ namespace netlist
, m_R(*this, "R")
, m_control(*this, "CTL")
, m_base_r(*this, "BASER", nlconst::magic(270.0))
+ , m_last(*this, "m_last", false)
{
}
@@ -34,7 +35,8 @@ namespace netlist
analog::NETLIB_SUB(R_base) m_R;
analog_input_t m_control;
- param_fp_t m_base_r;
+ param_fp_t m_base_r;
+ state_var<bool> m_last;
};
NETLIB_RESET(CD4066_GATE)
@@ -53,6 +55,7 @@ namespace netlist
nl_fptype in = m_control() - m_supply.GND().Q_Analog();
nl_fptype rON = m_base_r() * nlconst::magic(5.0) / sup;
nl_fptype R = -nlconst::one();
+ bool new_state(false);
if (in < low)
{
@@ -61,10 +64,12 @@ namespace netlist
else if (in > high)
{
R = rON;
+ new_state = true;
}
//printf("%s %f %f %g\n", name().c_str(), sup, in, R);
- if (R > nlconst::zero())
+ if (R > nlconst::zero() && (m_last != new_state))
{
+ m_last = new_state;
m_R.update();
m_R.set_R(R);
m_R.solve_later();