netlist: fix parameter update recalculation. (nw)

This commit is contained in:
couriersud 2020-01-29 18:53:06 +01:00
parent 2742727a0b
commit d7fd89afe1
6 changed files with 18 additions and 17 deletions

View File

@ -108,13 +108,13 @@ namespace netlist
m_R1.set_R(R_OFF);
m_R2.set_R(R_ON);
}
//m_R1.update_dev(time);
//m_R2.update_dev(time);
}
NETLIB_UPDATE_PARAM(switch2)
{
// FIXME: We only need to update the net first if this is a time stepping net
m_R1.solve_now();
m_R2.solve_now();
if (!m_POS())
{
m_R1.set_R(R_ON);
@ -125,9 +125,8 @@ namespace netlist
m_R1.set_R(R_OFF);
m_R2.set_R(R_ON);
}
m_R1.solve_now();
m_R2.solve_now();
m_R1.solve_later();
m_R2.solve_later();
}
} //namespace analog

View File

@ -66,6 +66,7 @@ namespace analog
NETLIB_UPDATE_PARAM(POT)
{
// FIXME: We only need to update the net first if this is a time stepping net
m_R1.solve_now();
m_R2.solve_now();
@ -76,6 +77,8 @@ namespace analog
v = nlconst::one() - v;
m_R1.set_R(std::max(m_R() * v, exec().gmin()));
m_R2.set_R(std::max(m_R() * (nlconst::one() - v), exec().gmin()));
m_R1.solve_later();
m_R2.solve_later();
}
@ -97,6 +100,7 @@ namespace analog
NETLIB_UPDATE_PARAM(POT2)
{
// FIXME: We only need to update the net first if this is a time stepping net
m_R1.solve_now();
nl_fptype v = m_Dial();
@ -106,6 +110,7 @@ namespace analog
if (m_Reverse())
v = nlconst::one() - v;
m_R1.set_R(std::max(m_R() * v, exec().gmin()));
m_R1.solve_later();
}
// ----------------------------------------------------------------------------------------

View File

@ -167,8 +167,10 @@ namespace analog
NETLIB_UPDATE_PARAMI()
{
// FIXME: We only need to update the net first if this is a time stepping net
solve_now();
set_R(std::max(m_R(), exec().gmin()));
solve_later();
}
private:
@ -485,11 +487,13 @@ namespace analog
NETLIB_UPDATE_PARAMI()
{
// FIXME: We only need to update the net first if this is a time stepping net
//FIXME: works only for CS without function
solve_now();
const auto zero(nlconst::zero());
set_mat(zero, zero, -m_I(),
zero, zero, m_I());
solve_later();
}
private:

View File

@ -39,12 +39,13 @@ namespace netlist
NETLIB_UPDATE_PARAM(r2r_dac)
{
// FIXME: We only need to update the net first if this is a time stepping net
solve_now();
nl_fptype V = m_VIN() / static_cast<nl_fptype>(1 << m_num())
* static_cast<nl_fptype>(m_val());
this->set_G_V_I(plib::reciprocal(m_R()), V, nlconst::zero());
solve_later();
}
} //namespace analog

View File

@ -49,9 +49,6 @@
#include "netlist/nl_setup.h"
#define R2R_DAC(name, p_VIN, p_R, p_N) \
NET_REGISTER_DEV(R2R_DAC, name) \
NETDEV_PARAMI(name, VIN, p_VIN) \
NETDEV_PARAMI(name, R, p_R) \
NETDEV_PARAMI(name, N, p_N)
NET_REGISTER_DEVEXT(R2R_DAC, name, p_VIN, p_R, p_N)
#endif /* NLD_R2R_DAC_H_ */

View File

@ -179,8 +179,6 @@ namespace devices
netlist_time::mult_type total = 0;
for (unsigned i=0; i<m_size; i++)
{
// FIXME: use pstonum_ne
//pati[i] = plib::pstonum<decltype(pati[i])>(pat[i]);
pati[i] = plib::pstonum<std::int64_t>(pat[i]);
total += pati[i];
}
@ -344,7 +342,6 @@ namespace devices
private:
analog::NETLIB_NAME(twoterm) m_RIN;
// Fixme: only works if the device is time-stepped - need to rework
analog::NETLIB_NAME(twoterm) m_ROUT;
analog_input_t m_I;
analog_output_t m_Q;
@ -355,8 +352,6 @@ namespace devices
// -----------------------------------------------------------------------------
// nld_function
//
// FIXME: Currently a proof of concept to get congo bongo working
// ----------------------------------------------------------------------------- */
NETLIB_OBJECT(function)
@ -437,7 +432,7 @@ namespace devices
const nl_fptype R = state ? m_RON() : m_ROFF();
// FIXME: We only need to update the net first if this is a time stepping net
m_R.update();
m_R.solve_now();
m_R.set_R(R);
m_R.solve_later();
}