mirror of
https://github.com/holub/mame
synced 2025-07-07 19:03:29 +03:00
netlist: code maintenance and fixing kidniki ... (nw)
to run at acceptable speed again.
This commit is contained in:
parent
15e84aaa88
commit
b4ba8dc552
@ -144,7 +144,7 @@ public:
|
||||
// avoid calls due to noise
|
||||
if (std::fabs(cur - m_last) > 1e-6)
|
||||
{
|
||||
m_cpu_device->update_icount();
|
||||
m_cpu_device->update_icount(exec().time());
|
||||
m_callback(cur, m_cpu_device->local_time());
|
||||
m_cpu_device->check_mame_abort_slice();
|
||||
m_last = cur;
|
||||
@ -192,7 +192,7 @@ public:
|
||||
// avoid calls due to noise
|
||||
if (cur != m_last)
|
||||
{
|
||||
m_cpu_device->update_icount();
|
||||
m_cpu_device->update_icount(exec().time());
|
||||
m_callback(cur, m_cpu_device->local_time());
|
||||
m_cpu_device->check_mame_abort_slice();
|
||||
m_last = cur;
|
||||
@ -933,9 +933,9 @@ ATTR_COLD void netlist_mame_device::device_pre_save()
|
||||
netlist().run_state_manager().pre_save();
|
||||
}
|
||||
|
||||
void netlist_mame_device::update_icount()
|
||||
void netlist_mame_device::update_icount(netlist::netlist_time time)
|
||||
{
|
||||
const netlist::netlist_time newt(netlist().time());
|
||||
const netlist::netlist_time newt(time);
|
||||
const netlist::netlist_time delta(newt - m_old + m_rem);
|
||||
const uint64_t d = delta / m_div;
|
||||
m_old = newt;
|
||||
@ -1061,13 +1061,13 @@ ATTR_HOT void netlist_mame_cpu_device::execute_run()
|
||||
m_genPC &= 255;
|
||||
debugger_instruction_hook(m_genPC);
|
||||
netlist().process_queue(m_div);
|
||||
update_icount();
|
||||
update_icount(netlist().time());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
netlist().process_queue(m_div * m_icount);
|
||||
update_icount();
|
||||
update_icount(netlist().time());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
ATTR_HOT inline netlist_mame_t &netlist() { return *m_netlist; }
|
||||
|
||||
ATTR_HOT inline const netlist::netlist_time last_time_update() { return m_old; }
|
||||
ATTR_HOT void update_icount();
|
||||
ATTR_HOT void update_icount(netlist::netlist_time time);
|
||||
ATTR_HOT void check_mame_abort_slice();
|
||||
|
||||
static void register_memregion_source(netlist::setup_t &setup, const char *name);
|
||||
|
@ -49,6 +49,11 @@ namespace netlist
|
||||
|
||||
NETLIB_UPDATE(switch1)
|
||||
{
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_PARAM(switch1)
|
||||
{
|
||||
m_R.solve_now();
|
||||
if (!m_POS())
|
||||
{
|
||||
m_R.set_R(R_OFF);
|
||||
@ -58,12 +63,6 @@ namespace netlist
|
||||
m_R.set_R(R_ON);
|
||||
}
|
||||
|
||||
m_R.update_dev();
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_PARAM(switch1)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -113,13 +112,25 @@ namespace netlist
|
||||
m_R2.set_R(R_ON);
|
||||
}
|
||||
|
||||
m_R1.update_dev();
|
||||
m_R2.update_dev();
|
||||
//m_R1.update_dev(time);
|
||||
//m_R2.update_dev(time);
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_PARAM(switch2)
|
||||
{
|
||||
update();
|
||||
if (!m_POS())
|
||||
{
|
||||
m_R1.set_R(R_ON);
|
||||
m_R2.set_R(R_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_R1.set_R(R_OFF);
|
||||
m_R2.set_R(R_ON);
|
||||
}
|
||||
|
||||
m_R1.solve_now();
|
||||
m_R2.solve_now();
|
||||
}
|
||||
|
||||
} //namespace analog
|
||||
|
@ -63,11 +63,6 @@ NETLIB_UPDATE_PARAM(LVCCS)
|
||||
NETLIB_NAME(VCCS)::update_param();
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(LVCCS)
|
||||
{
|
||||
NETLIB_NAME(VCCS)::update();
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_TERMINALS(LVCCS)
|
||||
{
|
||||
const nl_double m_mult = m_G() * m_gfac; // 1.0 ==> 1V ==> 1A
|
||||
@ -105,11 +100,6 @@ NETLIB_UPDATE_PARAM(CCCS)
|
||||
NETLIB_NAME(VCCS)::update_param();
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(CCCS)
|
||||
{
|
||||
NETLIB_NAME(VCCS)::update();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// nld_VCVS
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
@ -101,7 +101,7 @@ namespace netlist {
|
||||
param_double_t m_cur_limit; /* current limit */
|
||||
|
||||
protected:
|
||||
NETLIB_UPDATEI();
|
||||
//NETLIB_UPDATEI();
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
NETLIB_UPDATE_TERMINALSI();
|
||||
@ -141,7 +141,7 @@ namespace netlist {
|
||||
}
|
||||
|
||||
protected:
|
||||
NETLIB_UPDATEI();
|
||||
//NETLIB_UPDATEI();
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
};
|
||||
|
@ -83,9 +83,8 @@ void generic_diode::update_diode(const nl_double nVd)
|
||||
// nld_twoterm
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_UPDATE(twoterm)
|
||||
void NETLIB_NAME(twoterm)::solve_now()
|
||||
{
|
||||
/* only called if connected to a rail net ==> notify the solver to recalculate */
|
||||
/* we only need to call the non-rail terminal */
|
||||
if (m_P.has_net() && !m_P.net().isRailNet())
|
||||
m_P.solve_now();
|
||||
@ -93,6 +92,13 @@ NETLIB_UPDATE(twoterm)
|
||||
m_N.solve_now();
|
||||
}
|
||||
|
||||
|
||||
NETLIB_UPDATE(twoterm)
|
||||
{
|
||||
/* only called if connected to a rail net ==> notify the solver to recalculate */
|
||||
solve_now();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// nld_R_base
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -103,18 +109,13 @@ NETLIB_RESET(R_base)
|
||||
set_R(1.0 / exec().gmin());
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(R_base)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::update();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// nld_R
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_UPDATE_PARAM(R)
|
||||
{
|
||||
update_dev();
|
||||
solve_now();
|
||||
set_R(std::max(m_R(), exec().gmin()));
|
||||
}
|
||||
|
||||
@ -140,8 +141,8 @@ NETLIB_RESET(POT)
|
||||
|
||||
NETLIB_UPDATE_PARAM(POT)
|
||||
{
|
||||
m_R1.update_dev();
|
||||
m_R2.update_dev();
|
||||
m_R1.solve_now();
|
||||
m_R2.solve_now();
|
||||
|
||||
nl_double v = m_Dial();
|
||||
if (m_DialIsLog())
|
||||
@ -170,7 +171,7 @@ NETLIB_RESET(POT2)
|
||||
|
||||
NETLIB_UPDATE_PARAM(POT2)
|
||||
{
|
||||
m_R1.update_dev();
|
||||
m_R1.solve_now();
|
||||
|
||||
nl_double v = m_Dial();
|
||||
|
||||
@ -197,11 +198,6 @@ NETLIB_UPDATE_PARAM(C)
|
||||
m_GParallel = exec().gmin();
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(C)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::update();
|
||||
}
|
||||
|
||||
NETLIB_TIMESTEP(C)
|
||||
{
|
||||
/* Gpar should support convergence */
|
||||
@ -230,11 +226,6 @@ NETLIB_UPDATE_PARAM(L)
|
||||
{
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(L)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::update();
|
||||
}
|
||||
|
||||
NETLIB_TIMESTEP(L)
|
||||
{
|
||||
/* Gpar should support convergence */
|
||||
@ -266,11 +257,6 @@ NETLIB_UPDATE_PARAM(D)
|
||||
m_D.set_param(Is, n, exec().gmin());
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(D)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::update();
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_TERMINALS(D)
|
||||
{
|
||||
m_D.update_diode(deltaV());
|
||||
@ -281,53 +267,6 @@ NETLIB_UPDATE_TERMINALS(D)
|
||||
//set(m_D.G(), 0.0, m_D.Ieq());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// nld_VS
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_RESET(VS)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::reset();
|
||||
this->set(1.0 / m_R(), m_V(), 0.0);
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(VS)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::update();
|
||||
}
|
||||
|
||||
NETLIB_TIMESTEP(VS)
|
||||
{
|
||||
this->set(1.0 / m_R(),
|
||||
m_compiled.evaluate(std::vector<double>({exec().time().as_double()})),
|
||||
0.0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// nld_CS
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_RESET(CS)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::reset();
|
||||
const nl_double I = m_I();
|
||||
|
||||
set_mat(0.0, 0.0, -I,
|
||||
0.0, 0.0, I);
|
||||
//this->set(0.0, 0.0, m_I());
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(CS)
|
||||
{
|
||||
NETLIB_NAME(twoterm)::update();
|
||||
}
|
||||
|
||||
NETLIB_TIMESTEP(CS)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
} //namespace analog
|
||||
|
||||
|
@ -81,6 +81,8 @@ NETLIB_OBJECT(twoterm)
|
||||
NETLIB_UPDATEI();
|
||||
|
||||
public:
|
||||
void solve_now();
|
||||
|
||||
void set(const nl_double G, const nl_double V, const nl_double I)
|
||||
{
|
||||
/* GO, GT, I */
|
||||
@ -125,7 +127,7 @@ public:
|
||||
|
||||
protected:
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATEI();
|
||||
//NETLIB_UPDATEI();
|
||||
|
||||
};
|
||||
|
||||
@ -233,7 +235,7 @@ public:
|
||||
|
||||
protected:
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATEI();
|
||||
//NETLIB_UPDATEI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
|
||||
private:
|
||||
@ -265,7 +267,7 @@ public:
|
||||
|
||||
protected:
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATEI();
|
||||
//NETLIB_UPDATEI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
|
||||
private:
|
||||
@ -381,7 +383,7 @@ public:
|
||||
|
||||
protected:
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATEI();
|
||||
//NETLIB_UPDATEI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
|
||||
generic_diode m_D;
|
||||
@ -398,6 +400,7 @@ NETLIB_OBJECT_DERIVED(VS, twoterm)
|
||||
{
|
||||
public:
|
||||
NETLIB_CONSTRUCTOR_DERIVED(VS, twoterm)
|
||||
, m_t(*this, "m_t", 0.0)
|
||||
, m_R(*this, "R", 0.1)
|
||||
, m_V(*this, "V", 0.0)
|
||||
, m_func(*this,"FUNC", "")
|
||||
@ -410,12 +413,26 @@ public:
|
||||
}
|
||||
|
||||
NETLIB_IS_TIMESTEP(m_func() != "")
|
||||
NETLIB_TIMESTEPI();
|
||||
|
||||
NETLIB_TIMESTEPI()
|
||||
{
|
||||
m_t += step;
|
||||
this->set(1.0 / m_R(),
|
||||
m_compiled.evaluate(std::vector<double>({m_t})),
|
||||
0.0);
|
||||
}
|
||||
|
||||
protected:
|
||||
NETLIB_UPDATEI();
|
||||
NETLIB_RESETI();
|
||||
// NETLIB_UPDATEI() { NETLIB_NAME(twoterm)::update(time); }
|
||||
|
||||
NETLIB_RESETI()
|
||||
{
|
||||
NETLIB_NAME(twoterm)::reset();
|
||||
this->set(1.0 / m_R(), m_V(), 0.0);
|
||||
}
|
||||
|
||||
private:
|
||||
state_var<double> m_t;
|
||||
param_double_t m_R;
|
||||
param_double_t m_V;
|
||||
param_str_t m_func;
|
||||
@ -430,6 +447,7 @@ NETLIB_OBJECT_DERIVED(CS, twoterm)
|
||||
{
|
||||
public:
|
||||
NETLIB_CONSTRUCTOR_DERIVED(CS, twoterm)
|
||||
, m_t(*this, "m_t", 0.0)
|
||||
, m_I(*this, "I", 1.0)
|
||||
, m_func(*this,"FUNC", "")
|
||||
, m_compiled(this->name() + ".FUNCC", this, this->state().run_state_manager())
|
||||
@ -441,12 +459,26 @@ public:
|
||||
}
|
||||
|
||||
NETLIB_IS_TIMESTEP(m_func() != "")
|
||||
NETLIB_TIMESTEPI();
|
||||
NETLIB_TIMESTEPI()
|
||||
{
|
||||
m_t += step;
|
||||
const double I = m_compiled.evaluate(std::vector<double>({m_t}));
|
||||
set_mat(0.0, 0.0, -I,
|
||||
0.0, 0.0, I);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
NETLIB_UPDATEI();
|
||||
NETLIB_RESETI();
|
||||
//NETLIB_UPDATEI() { NETLIB_NAME(twoterm)::update(time); }
|
||||
NETLIB_RESETI()
|
||||
{
|
||||
NETLIB_NAME(twoterm)::reset();
|
||||
set_mat(0.0, 0.0, -m_I(),
|
||||
0.0, 0.0, m_I());
|
||||
}
|
||||
|
||||
private:
|
||||
state_var<double> m_t;
|
||||
param_double_t m_I;
|
||||
param_str_t m_func;
|
||||
plib::pfunction m_compiled;
|
||||
|
@ -101,7 +101,7 @@ namespace netlist
|
||||
{
|
||||
unsigned start_q = m_last_Q;
|
||||
|
||||
NETLIB_PARENT_UPDATE(7477);
|
||||
NETLIB_NAME(7477)::update();
|
||||
|
||||
for (std::size_t i=0; i<4; i++)
|
||||
{
|
||||
|
@ -104,7 +104,10 @@ namespace netlist
|
||||
}
|
||||
NETLIB_UPDATEI();
|
||||
|
||||
NETLIB_UPDATE_PARAMI() { update_dev(); }
|
||||
NETLIB_UPDATE_PARAMI()
|
||||
{
|
||||
/* update param may be called from anywhere, update_dev(time) is not a good idea */
|
||||
}
|
||||
|
||||
public:
|
||||
NETLIB_SUB(SN74LS629clk) m_clock;
|
||||
|
@ -39,7 +39,7 @@ namespace netlist
|
||||
|
||||
NETLIB_UPDATE_PARAM(r2r_dac)
|
||||
{
|
||||
update_dev();
|
||||
solve_now();
|
||||
|
||||
double V = m_VIN() / static_cast<double>(1 << m_num())
|
||||
* static_cast<double>(m_val());
|
||||
|
@ -51,43 +51,6 @@ namespace netlist
|
||||
m_cnt = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// logic_input
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_RESET(logic_input)
|
||||
{
|
||||
m_Q.initial(0);
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(logic_input)
|
||||
{
|
||||
m_Q.push(m_IN() & 1, netlist_time::from_nsec(1));
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_PARAM(logic_input)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// analog_input
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_RESET(analog_input)
|
||||
{
|
||||
m_Q.initial(0.0);
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(analog_input)
|
||||
{
|
||||
m_Q.push(m_IN());
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_PARAM(analog_input)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// nld_res_sw
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -126,11 +126,6 @@ namespace netlist
|
||||
log().warning(MW_1_NO_POWER_TERMINALS_ON_DEVICE_1, out_proxied->device().name());
|
||||
else
|
||||
log().verbose("D/A Proxy: Found power terminals on device {1}", out_proxied->device().name());
|
||||
#if (0)
|
||||
printf("%s %s\n", out_proxied->name().c_str(), out_proxied->device().name().c_str());
|
||||
auto x = netlist().setup().find_terminal(out_proxied->name(), detail::device_object_t::terminal_type::OUTPUT, false);
|
||||
if (x) printf("==> %s\n", x->name().c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,11 +187,9 @@ namespace netlist
|
||||
set_logic_family(setup().family_from_model(m_FAMILY()));
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_AFTER_PARAM_CHANGE()
|
||||
|
||||
NETLIB_UPDATEI();
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
NETLIB_UPDATEI() { }
|
||||
NETLIB_RESETI() { m_Q.initial(0); }
|
||||
NETLIB_UPDATE_PARAMI() { m_Q.push(m_IN() & 1, netlist_time::from_nsec(1)); }
|
||||
|
||||
protected:
|
||||
logic_output_t m_Q;
|
||||
@ -207,11 +205,11 @@ namespace netlist
|
||||
, m_IN(*this, "IN", 0.0)
|
||||
{
|
||||
}
|
||||
NETLIB_UPDATE_AFTER_PARAM_CHANGE()
|
||||
|
||||
NETLIB_UPDATEI();
|
||||
NETLIB_RESETI();
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
NETLIB_UPDATEI() { }
|
||||
NETLIB_RESETI() { m_Q.initial(0.0); }
|
||||
NETLIB_UPDATE_PARAMI() { m_Q.push(m_IN()); }
|
||||
|
||||
protected:
|
||||
analog_output_t m_Q;
|
||||
param_double_t m_IN;
|
||||
|
@ -209,15 +209,6 @@ namespace netlist
|
||||
}
|
||||
|
||||
m_ign = 0;
|
||||
|
||||
#if 0
|
||||
printf("%s\n", name().c_str());
|
||||
for (int j=0; j < m_size; j++)
|
||||
printf("%05x %04x %04x %04x\n", j, m_ttp->m_out_state[j] & ((1 << m_NO)-1),
|
||||
m_ttp->m_out_state[j] >> m_NO, m_ttp->m_timing[j * m_NO + 0]);
|
||||
for (int k=0; m_ttp->m_timing_nt[k] != netlist_time::zero(); k++)
|
||||
printf("%d %f\n", k, m_ttp->m_timing_nt[k].as_double() * 1000000.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
@ -168,7 +168,7 @@ void detail::queue_t::on_pre_save()
|
||||
{
|
||||
state().log().debug("on_pre_save\n");
|
||||
m_qsize = this->size();
|
||||
state().log().debug("current time {1} qsize {2}\n", exec().time().as_double(), m_qsize);
|
||||
state().log().debug("qsize {1}\n", 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();
|
||||
state().log().debug("current time {1} qsize {2}\n", exec().time().as_double(), m_qsize);
|
||||
state().log().debug("qsize {1}\n", m_qsize);
|
||||
for (std::size_t i = 0; i < m_qsize; i++ )
|
||||
{
|
||||
detail::net_t *n = state().nets()[m_net_ids[i]].get();
|
||||
@ -352,14 +352,20 @@ void netlist_state_t::reset()
|
||||
std::unordered_map<core_device_t *, bool> m;
|
||||
|
||||
// Reset all nets once !
|
||||
log().verbose("Call reset on all nets:");
|
||||
for (auto & n : nets())
|
||||
n->reset();
|
||||
|
||||
// Reset all devices once !
|
||||
log().verbose("Call reset on all devices:");
|
||||
for (auto & dev : m_devices)
|
||||
dev->do_reset();
|
||||
|
||||
// Make sure everything depending on parameters is set
|
||||
// Currently analog input and logic input also
|
||||
// push their outputs to queue.
|
||||
|
||||
log().verbose("Call update_param on all devices:");
|
||||
for (auto & dev : m_devices)
|
||||
dev->update_param();
|
||||
|
||||
@ -391,17 +397,6 @@ void netlist_state_t::reset()
|
||||
if (!plib::container::contains(d, dev))
|
||||
d.push_back(dev);
|
||||
}
|
||||
log().verbose("Call update on devices which need parameter update:");
|
||||
for (auto & dev : m_devices)
|
||||
if (dev->needs_update_after_param_change())
|
||||
{
|
||||
if (!plib::container::contains(d, dev.get()))
|
||||
{
|
||||
d.push_back(dev.get());
|
||||
log().verbose("\t ...{1}", dev->name());
|
||||
dev->update_dev();
|
||||
}
|
||||
}
|
||||
log().verbose("Devices not yet updated:");
|
||||
for (auto &dev : m_devices)
|
||||
if (!plib::container::contains(d, dev.get()))
|
||||
@ -1061,8 +1056,6 @@ param_t::param_type_t param_t::param_type() const
|
||||
void param_t::update_param()
|
||||
{
|
||||
device().update_param();
|
||||
if (device().needs_update_after_param_change())
|
||||
device().update_dev();
|
||||
}
|
||||
|
||||
pstring param_t::get_initial(const device_t &dev, bool *found)
|
||||
|
@ -123,9 +123,6 @@ class NETLIB_NAME(name) : public device_t
|
||||
#define NETLIB_TIMESTEPI() \
|
||||
public: virtual void timestep(const nl_double step) override
|
||||
|
||||
#define NETLIB_UPDATE_AFTER_PARAM_CHANGE() \
|
||||
public: virtual bool needs_update_after_param_change() const override { return true; }
|
||||
|
||||
#define NETLIB_FAMILY(family) , m_famsetter(*this, family)
|
||||
|
||||
#define NETLIB_DELEGATE(chip, name) nldelegate(&NETLIB_NAME(chip) :: name, this)
|
||||
@ -141,18 +138,15 @@ class NETLIB_NAME(name) : public device_t
|
||||
#define NETLIB_SUB(chip) nld_ ## chip
|
||||
#define NETLIB_SUBXX(ns, chip) std::unique_ptr< ns :: nld_ ## chip >
|
||||
|
||||
#define NETLIB_HANDLER(chip, name) void NETLIB_NAME(chip) :: name(void) NL_NOEXCEPT
|
||||
#define NETLIB_HANDLER(chip, name) void NETLIB_NAME(chip) :: name() NL_NOEXCEPT
|
||||
#define NETLIB_UPDATE(chip) NETLIB_HANDLER(chip, update)
|
||||
|
||||
// FIXME: NETLIB_PARENT_UPDATE should disappear
|
||||
#define NETLIB_PARENT_UPDATE(chip) NETLIB_NAME(chip) :: update()
|
||||
|
||||
#define NETLIB_RESET(chip) void NETLIB_NAME(chip) :: reset(void)
|
||||
|
||||
#define NETLIB_UPDATE_PARAM(chip) void NETLIB_NAME(chip) :: update_param(void)
|
||||
#define NETLIB_UPDATE_PARAM(chip) void NETLIB_NAME(chip) :: update_param()
|
||||
#define NETLIB_FUNC_VOID(chip, name, params) void NETLIB_NAME(chip) :: name params
|
||||
|
||||
#define NETLIB_UPDATE_TERMINALS(chip) void NETLIB_NAME(chip) :: update_terminals(void)
|
||||
#define NETLIB_UPDATE_TERMINALS(chip) void NETLIB_NAME(chip) :: update_terminals()
|
||||
|
||||
//============================================================
|
||||
// Asserts
|
||||
@ -727,19 +721,19 @@ namespace netlist
|
||||
|
||||
void toggle_new_Q() noexcept { m_new_Q = (m_cur_Q ^ 1); }
|
||||
|
||||
void toggle_and_push_to_queue(const netlist_time delay) NL_NOEXCEPT
|
||||
void toggle_and_push_to_queue(netlist_time delay) NL_NOEXCEPT
|
||||
{
|
||||
toggle_new_Q();
|
||||
push_to_queue(delay);
|
||||
}
|
||||
|
||||
void push_to_queue(const netlist_time delay) NL_NOEXCEPT;
|
||||
void push_to_queue(netlist_time delay) NL_NOEXCEPT;
|
||||
bool is_queued() const noexcept { return m_in_queue == QS_QUEUED; }
|
||||
|
||||
void update_devs() NL_NOEXCEPT;
|
||||
|
||||
const netlist_time time() const noexcept { return m_time; }
|
||||
void set_time(const netlist_time ntime) noexcept { m_time = ntime; }
|
||||
void set_time(netlist_time ntime) noexcept { m_time = ntime; }
|
||||
|
||||
bool isRailNet() const noexcept { return !(m_railterminal == nullptr); }
|
||||
core_terminal_t & railterminal() const noexcept { return *m_railterminal; }
|
||||
@ -979,7 +973,7 @@ namespace netlist
|
||||
virtual ~param_str_t();
|
||||
|
||||
const pstring &operator()() const NL_NOEXCEPT { return Value(); }
|
||||
void setTo(const pstring ¶m) NL_NOEXCEPT
|
||||
void setTo(netlist_time time, const pstring ¶m) NL_NOEXCEPT
|
||||
{
|
||||
if (m_param != param)
|
||||
{
|
||||
@ -1086,6 +1080,7 @@ namespace netlist
|
||||
|
||||
virtual ~core_device_t();
|
||||
|
||||
// FIXME: useless trampoline
|
||||
void update_dev() NL_NOEXCEPT
|
||||
{
|
||||
do_update();
|
||||
@ -1139,7 +1134,6 @@ namespace netlist
|
||||
virtual void update_param() {}
|
||||
virtual bool is_dynamic() const { return false; }
|
||||
virtual bool is_timestep() const { return false; }
|
||||
virtual bool needs_update_after_param_change() const { return false; }
|
||||
|
||||
private:
|
||||
bool m_hint_deactivate;
|
||||
|
@ -67,11 +67,7 @@ void list_t::register_device(std::unique_ptr<element_t> &&factory)
|
||||
{
|
||||
for (auto & e : *this)
|
||||
if (e->name() == factory->name())
|
||||
{
|
||||
// FIXME: throws pure virtual exception
|
||||
printf("%s\n", e->name().c_str());
|
||||
m_setup.log().fatal(MF_1_FACTORY_ALREADY_CONTAINS_1, factory->name());
|
||||
}
|
||||
push_back(std::move(factory));
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,6 @@ namespace plib
|
||||
const float_type rho_to_accuracy = std::sqrt(vec_mult2<FT>(n, Ax)) / accuracy;
|
||||
|
||||
rho_delta = accuracy * rho_to_accuracy;
|
||||
//printf("%e %e\n", rho_delta, accuracy * std::sqrt(static_cast<FT>(n)));
|
||||
}
|
||||
else
|
||||
rho_delta = accuracy * std::sqrt(static_cast<FT>(n));
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "pconfig.h"
|
||||
#include "palloc.h"
|
||||
#include "pfmtlog.h"
|
||||
#include "pexception.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -91,7 +92,7 @@ void mempool::free(void *ptr)
|
||||
auto i = reinterpret_cast<info *>(p - mininfosize());
|
||||
block *b = i->m_block;
|
||||
if (b->m_num_alloc == 0)
|
||||
fprintf(stderr, "Argh .. double free\n");
|
||||
plib::pexception("mempool::free - double free was called\n");
|
||||
else
|
||||
{
|
||||
//b->m_free = m_min_alloc;
|
||||
|
@ -117,7 +117,6 @@ void pfunction::compile_infix(const std::vector<pstring> &inputs, const pstring
|
||||
std::stack<pstring> opstk;
|
||||
std::vector<pstring> postfix;
|
||||
|
||||
//printf("dbg: %s\n", expr.c_str());
|
||||
for (unsigned i = 0; i < sexpr.size(); i++)
|
||||
{
|
||||
pstring &s = sexpr[i];
|
||||
|
@ -59,7 +59,6 @@ void state_manager_t::post_load()
|
||||
|
||||
template<> void state_manager_t::save_item(const void *owner, callback_t &state, const pstring &stname)
|
||||
{
|
||||
//save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
|
||||
callback_t *state_p = &state;
|
||||
auto p = plib::make_unique<entry_t>(stname, owner, state_p);
|
||||
m_custom.push_back(std::move(p));
|
||||
|
@ -169,7 +169,6 @@ void pofilestream::vwrite(const value_type *buf, const pos_type n)
|
||||
std::size_t r = fwrite(buf, 1, n, static_cast<FILE *>(m_file));
|
||||
if (r < n)
|
||||
{
|
||||
//printf("%ld %ld %s\n", r, n, strerror(errno));
|
||||
if (ferror(static_cast<FILE *>(m_file)))
|
||||
throw file_write_e(m_filename);
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ namespace plib
|
||||
|
||||
const pstring environment(const pstring &var, const pstring &default_val)
|
||||
{
|
||||
if (getenv(var.c_str()) == nullptr)
|
||||
if (std::getenv(var.c_str()) == nullptr)
|
||||
return default_val;
|
||||
else
|
||||
return pstring(getenv(var.c_str()));
|
||||
return pstring(std::getenv(var.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -693,10 +693,6 @@ int tool_app_t::execute()
|
||||
plib::fpsignalenabler::global_enable(true);
|
||||
plib::fpsignalenabler sigen(plib::FP_ALL & ~plib::FP_INEXACT & ~plib::FP_UNDERFLOW);
|
||||
|
||||
//perr("{}", "WARNING: This is Work In Progress! - It may fail anytime\n");
|
||||
//perr("Update dispatching using method {}\n", pmf_verbose[NL_PMF_TYPE]);
|
||||
//printf("test2 %f\n", std::exp(-14362.38064713));
|
||||
|
||||
if (opt_help())
|
||||
{
|
||||
pout(usage());
|
||||
|
@ -429,7 +429,7 @@ void matrix_solver_t::reset()
|
||||
|
||||
void matrix_solver_t::update() NL_NOEXCEPT
|
||||
{
|
||||
const netlist_time new_timestep = solve();
|
||||
const netlist_time new_timestep = solve(exec().time());
|
||||
update_inputs();
|
||||
|
||||
if (m_params.m_dynamic_ts && has_timestep_devices() && new_timestep > netlist_time::zero())
|
||||
@ -438,9 +438,15 @@ void matrix_solver_t::update() NL_NOEXCEPT
|
||||
}
|
||||
}
|
||||
|
||||
/* update_forced is called from within param_update
|
||||
*
|
||||
* this should only occur outside of execution and thus
|
||||
* using time should be safe.
|
||||
*
|
||||
*/
|
||||
void matrix_solver_t::update_forced()
|
||||
{
|
||||
const netlist_time new_timestep = solve();
|
||||
const netlist_time new_timestep = solve(exec().time());
|
||||
plib::unused_var(new_timestep);
|
||||
|
||||
update_inputs();
|
||||
@ -458,7 +464,7 @@ void matrix_solver_t::step(const netlist_time &delta)
|
||||
m_step_devices[k]->timestep(dd);
|
||||
}
|
||||
|
||||
void matrix_solver_t::solve_base()
|
||||
void matrix_solver_t::solve_base(netlist_time time)
|
||||
{
|
||||
++m_stat_vsolver_calls;
|
||||
if (has_dynamic_devices())
|
||||
@ -487,9 +493,8 @@ void matrix_solver_t::solve_base()
|
||||
}
|
||||
}
|
||||
|
||||
const netlist_time matrix_solver_t::solve()
|
||||
const netlist_time matrix_solver_t::solve(netlist_time now)
|
||||
{
|
||||
const netlist_time now = exec().time();
|
||||
const netlist_time delta = now - m_last_step;
|
||||
|
||||
// We are already up to date. Avoid oscillations.
|
||||
@ -500,7 +505,7 @@ const netlist_time matrix_solver_t::solve()
|
||||
/* update all terminals for new time step */
|
||||
m_last_step = now;
|
||||
step(delta);
|
||||
solve_base();
|
||||
solve_base(now);
|
||||
const netlist_time next_time_step = compute_next_timestep(delta.as_double());
|
||||
|
||||
return next_time_step;
|
||||
@ -614,7 +619,6 @@ netlist_time matrix_solver_t::compute_next_timestep(const double cur_ts)
|
||||
const nl_double DD_n = (n->Q_Analog() - t->m_last_V);
|
||||
const nl_double hn = cur_ts;
|
||||
|
||||
//printf("%f %f %f %f\n", DD_n, t->m_DD_n_m_1, hn, t->m_h_n_m_1);
|
||||
nl_double DD2 = (DD_n / hn - t->m_DD_n_m_1 / t->m_h_n_m_1) / (hn + t->m_h_n_m_1);
|
||||
nl_double new_net_timestep;
|
||||
|
||||
|
@ -143,12 +143,12 @@ public:
|
||||
vsetup(nets);
|
||||
}
|
||||
|
||||
void solve_base();
|
||||
void solve_base(netlist_time time);
|
||||
|
||||
/* after every call to solve, update inputs must be called.
|
||||
* this can be done as well as a batch to ease parallel processing.
|
||||
*/
|
||||
const netlist_time solve();
|
||||
const netlist_time solve(netlist_time now);
|
||||
void update_inputs();
|
||||
|
||||
bool has_dynamic_devices() const { return m_dynamic_devices.size() > 0; }
|
||||
|
@ -161,11 +161,9 @@ unsigned matrix_solver_SOR_mat_t<FT, SIZE>::vsolve_non_dynamic(const bool newton
|
||||
lambda1 = akk;
|
||||
#endif
|
||||
}
|
||||
//printf("lambda: %f %f\n", lambda, 2.0 / (1.0 + 2 * sqrt(lambda)) );
|
||||
|
||||
//ws = 2.0 / (2.0 - lambdaN - lambda1);
|
||||
m_omega = 2.0 / (2.0 - lambda1);
|
||||
//printf("%f %f %f\n", m_omega, lambda1, lambdaN);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -93,9 +93,10 @@ NETLIB_UPDATE(solver)
|
||||
if (m_params.m_dynamic_ts)
|
||||
return;
|
||||
|
||||
netlist_time now(exec().time());
|
||||
/* force solving during start up if there are no time-step devices */
|
||||
/* FIXME: Needs a more elegant solution */
|
||||
bool force_solve = (exec().time() < netlist_time::from_double(2 * m_params.m_max_timestep));
|
||||
bool force_solve = (now < 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());
|
||||
|
||||
@ -104,16 +105,16 @@ NETLIB_UPDATE(solver)
|
||||
if (nthreads > 1 && solvers.size() > 1)
|
||||
{
|
||||
plib::omp::set_num_threads(nthreads);
|
||||
plib::omp::for_static(static_cast<std::size_t>(0), solvers.size(), [&solvers](std::size_t i)
|
||||
plib::omp::for_static(static_cast<std::size_t>(0), solvers.size(), [&solvers, now](std::size_t i)
|
||||
{
|
||||
const netlist_time ts = solvers[i]->solve();
|
||||
const netlist_time ts = solvers[i]->solve(now);
|
||||
plib::unused_var(ts);
|
||||
});
|
||||
}
|
||||
else
|
||||
for (auto & solver : solvers)
|
||||
{
|
||||
const netlist_time ts = solver->solve();
|
||||
const netlist_time ts = solver->solve(now);
|
||||
plib::unused_var(ts);
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,6 @@ void nl_convert_base_t::dump_nl()
|
||||
net_t * net = i.second.get();
|
||||
if (!net->is_no_export())
|
||||
{
|
||||
//printf("Net {}\n", net->name().c_str());
|
||||
out("NET_C({}", net->terminals()[0].c_str() );
|
||||
for (std::size_t j=1; j<net->terminals().size(); j++)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
// copyright-holders:Andrew Gardner, Couriersud
|
||||
#include "netlist/devices/net_lib.h"
|
||||
|
||||
#define USE_FRONTIERS 0
|
||||
#define USE_FRONTIERS 1
|
||||
#define USE_FIXED_STV 1
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
@ -326,8 +326,8 @@ NETLIST_START(kidniki)
|
||||
PARAM(Solver.ACCURACY, 1e-7)
|
||||
PARAM(Solver.NR_LOOPS, 100)
|
||||
PARAM(Solver.GS_LOOPS, 300)
|
||||
//PARAM(Solver.METHOD, "MAT_CR")
|
||||
PARAM(Solver.METHOD, "GMRES")
|
||||
PARAM(Solver.METHOD, "MAT_CR")
|
||||
//PARAM(Solver.METHOD, "GMRES")
|
||||
//PARAM(Solver.SOR_FACTOR, 1.73)
|
||||
//PARAM(Solver.METHOD, "SOR")
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user