Improve readability and remove some trampolines. (nw)

This commit is contained in:
couriersud 2017-01-10 23:57:51 +01:00
parent c8c7e9a770
commit b1c3586789
16 changed files with 176 additions and 218 deletions

View File

@ -119,15 +119,15 @@ namespace netlist
NETLIB_UPDATE(74153)
{
m_sub.m_chan = (m_A() | (m_B()<<1));
m_sub.do_update();
m_sub.update_dev();
}
NETLIB_UPDATE(74153_dip)
{
m_2.m_chan = m_1.m_chan = (m_A() | (m_B()<<1));
m_1.do_update();
m_2.do_update();
m_1.update_dev();
m_2.update_dev();
}
NETLIB_DEVICE_IMPL(74153)

View File

@ -173,6 +173,41 @@ namespace netlist
m_Q.push(stack[ptr-1]);
}
void NETLIB_NAME(function)::compile()
{
plib::pstring_vector_t cmds(m_func(), " ");
m_precompiled.clear();
for (std::size_t i=0; i < cmds.size(); i++)
{
pstring cmd = cmds[i];
rpn_inst rc;
if (cmd == "+")
rc.m_cmd = ADD;
else if (cmd == "-")
rc.m_cmd = SUB;
else if (cmd == "*")
rc.m_cmd = MULT;
else if (cmd == "/")
rc.m_cmd = DIV;
else if (cmd == "pow")
rc.m_cmd = POW;
else if (cmd.startsWith("A"))
{
rc.m_cmd = PUSH_INPUT;
rc.m_param = cmd.substr(1).as_long();
}
else
{
bool err = false;
rc.m_cmd = PUSH_CONST;
rc.m_param = cmd.as_double(&err);
if (err)
netlist().log().fatal("nld_function: unknown/misformatted token <{1}> in <{2}>", cmd, m_func());
}
m_precompiled.push_back(rc);
}
}
NETLIB_DEVICE_IMPL(dummy_input)
NETLIB_DEVICE_IMPL(frontier)

View File

@ -298,7 +298,7 @@ void tt_factory_create(setup_t &setup, tt_desc &desc)
}
ret->m_desc = desc.desc;
if (desc.family != "")
ret->m_family = setup.family_from_model(desc.family);
ret->m_family = setup.netlist().family_from_model(desc.family);
setup.factory().register_device(std::unique_ptr<netlist_base_factory_truthtable_t>(ret));
}

View File

@ -175,7 +175,7 @@ namespace netlist
/* make sure we get the family first */
, m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)")
{
set_logic_family(netlist().setup().family_from_model(m_FAMILY()));
set_logic_family(netlist().family_from_model(m_FAMILY()));
}
NETLIB_UPDATE_AFTER_PARAM_CHANGE()
@ -311,41 +311,7 @@ namespace netlist
{
for (int i=0; i < m_N(); i++)
m_I.push_back(plib::make_unique<analog_input_t>(*this, plib::pfmt("A{1}")(i)));
plib::pstring_vector_t cmds(m_func(), " ");
m_precompiled.clear();
for (std::size_t i=0; i < cmds.size(); i++)
{
pstring cmd = cmds[i];
rpn_inst rc;
if (cmd == "+")
rc.m_cmd = ADD;
else if (cmd == "-")
rc.m_cmd = SUB;
else if (cmd == "*")
rc.m_cmd = MULT;
else if (cmd == "/")
rc.m_cmd = DIV;
else if (cmd == "pow")
rc.m_cmd = POW;
else if (cmd.startsWith("A"))
{
rc.m_cmd = PUSH_INPUT;
rc.m_param = cmd.substr(1).as_long();
}
else
{
bool err = false;
rc.m_cmd = PUSH_CONST;
rc.m_param = cmd.as_double(&err);
if (err)
netlist().log().fatal("nld_function: unknown/misformatted token <{1}> in <{2}>", cmd, m_func());
}
m_precompiled.push_back(rc);
}
compile();
}
protected:
@ -373,6 +339,8 @@ namespace netlist
nl_double m_param;
};
void compile();
param_int_t m_N;
param_str_t m_func;
analog_output_t m_Q;

View File

@ -16,6 +16,7 @@
#include "nl_base.h"
#include "devices/nlid_system.h"
#include "devices/nlid_proxy.h"
#include "macro/nlm_base.h"
namespace netlist
{
@ -132,6 +133,25 @@ const logic_family_desc_t *family_CD4XXX()
return &obj;
}
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,
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;
};
plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_std_proxy_t::create_d_a_proxy(netlist_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
{
return plib::owned_ptr<devices::nld_base_a_to_d_proxy>::Create<devices::nld_a_to_d_proxy>(anetlist, name, proxied);
}
// ----------------------------------------------------------------------------------------
// queue_t
// ----------------------------------------------------------------------------------------
@ -180,7 +200,7 @@ void detail::queue_t::on_post_load()
detail::net_t *n = netlist().find_net(m_names[i].m_buf);
//log().debug("Got {1} ==> {2}\n", qtemp[i].m_name, n));
//log().debug("schedule time {1} ({2})\n", n->time().as_double(), netlist_time::from_raw(m_times[i]).as_double()));
this->push(netlist_time::from_raw(m_times[i]), n);
this->push(n, netlist_time::from_raw(m_times[i]));
}
}
@ -238,8 +258,7 @@ detail::device_object_t::type_t detail::device_object_t::type() const
// ----------------------------------------------------------------------------------------
netlist_t::netlist_t(const pstring &aname)
: m_state()
, m_time(netlist_time::zero())
: m_time(netlist_time::zero())
, m_queue(*this)
, m_mainclock(nullptr)
, m_solver(nullptr)
@ -247,10 +266,13 @@ netlist_t::netlist_t(const pstring &aname)
, m_name(aname)
, m_log(this)
, m_lib(nullptr)
, m_state()
{
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 = new setup_t(*this);
/* FIXME: doesn't really belong here */
NETLIST_NAME(base)(*m_setup);
}
netlist_t::~netlist_t()
@ -269,7 +291,7 @@ nl_double netlist_t::gmin() const
return solver()->gmin();
}
void netlist_t::register_dev(plib::owned_ptr<device_t> dev)
void netlist_t::register_dev(plib::owned_ptr<core_device_t> dev)
{
for (auto & d : m_devices)
if (d->name() == dev->name())
@ -277,9 +299,41 @@ void netlist_t::register_dev(plib::owned_ptr<device_t> dev)
m_devices.push_back(std::move(dev));
}
const logic_family_desc_t *netlist_t::family_from_model(const pstring &model)
{
model_map_t map;
setup().model_parse(model, map);
if (setup().model_value_str(map, "TYPE") == "TTL")
return family_TTL();
if (setup().model_value_str(map, "TYPE") == "CD4XXX")
return family_CD4XXX();
for (auto & e : m_family_cache)
if (e.first == model)
return e.second.get();
auto ret = plib::make_unique_base<logic_family_desc_t, logic_family_std_proxy_t>();
ret->m_fixed_V = setup().model_value(map, "FV");
ret->m_low_thresh_PCNT = setup().model_value(map, "IVL");
ret->m_high_thresh_PCNT = setup().model_value(map, "IVH");
ret->m_low_VO = setup().model_value(map, "OVL");
ret->m_high_VO = setup().model_value(map, "OVH");
ret->m_R_low = setup().model_value(map, "ORL");
ret->m_R_high = setup().model_value(map, "ORH");
auto retp = ret.get();
m_family_cache.emplace_back(model, std::move(ret));
return retp;
}
void netlist_t::start()
{
setup().start_devices1();
setup().start_devices();
/* load the library ... */
@ -337,7 +391,7 @@ void netlist_t::start()
m_lib = plib::palloc<plib::dynlib>(libpath);
/* resolve inputs */
setup().resolve_inputs1();
setup().resolve_inputs();
log().verbose("initialize solver ...\n");
@ -345,7 +399,7 @@ void netlist_t::start()
{
for (auto &p : m_nets)
if (p->is_analog())
log().fatal("No solver found for this net although analog elements are present\n");
log().fatal("No solver found for this netlist although analog elements are present\n");
}
else
m_solver->post_start();
@ -425,7 +479,7 @@ void netlist_t::process_queue(const netlist_time &delta)
{
netlist_time stop(m_time + delta);
m_queue.push(stop, nullptr);
m_queue.push(nullptr, stop);
m_stat_mainloop.start();
@ -560,7 +614,7 @@ core_device_t::core_device_t(core_device_t &owner, const pstring &name)
set_logic_family(owner.logic_family());
if (logic_family() == nullptr)
set_logic_family(family_TTL());
owner.netlist().m_devices.push_back(plib::owned_ptr<core_device_t>(this, false));
owner.netlist().register_dev(plib::owned_ptr<core_device_t>(this, false));
}
core_device_t::~core_device_t()
@ -637,7 +691,7 @@ void device_t::connect_post_start(detail::core_terminal_t &t1, detail::core_term
detail::family_setter_t::family_setter_t(core_device_t &dev, const char *desc)
{
dev.set_logic_family(dev.netlist().setup().family_from_model(desc));
dev.set_logic_family(dev.netlist().family_from_model(desc));
}
detail::family_setter_t::family_setter_t(core_device_t &dev, const logic_family_desc_t *desc)
@ -692,7 +746,7 @@ void detail::net_t::inc_active(core_terminal_t &term) NL_NOEXCEPT
if (m_time > netlist().time())
{
m_in_queue = 1; /* pending */
netlist().push_to_queue(*this, m_time);
netlist().queue().push(this, m_time);
}
else
{

View File

@ -999,17 +999,6 @@ namespace netlist
m_stat_total_time.stop();
}
void do_update() NL_NOEXCEPT
{
#if (NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF)
(this->*m_static_update)();
#elif ((NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF_CONV) || (NL_PMF_TYPE == NL_PMF_TYPE_INTERNAL))
m_static_update(this);
#else
update();
#endif
}
void set_delegate_pointer();
void do_inc_active() NL_NOEXCEPT
@ -1026,6 +1015,7 @@ namespace netlist
if (m_hint_deactivate)
dec_active();
}
void do_reset() { reset(); }
void set_hint_deactivate(bool v) { m_hint_deactivate = v; }
@ -1041,6 +1031,17 @@ namespace netlist
virtual void dec_active() NL_NOEXCEPT { }
virtual void reset() { }
void do_update() NL_NOEXCEPT
{
#if (NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF)
(this->*m_static_update)();
#elif ((NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF_CONV) || (NL_PMF_TYPE == NL_PMF_TYPE_INTERNAL))
m_static_update(this);
#else
update();
#endif
}
public:
virtual void timestep(ATTR_UNUSED const nl_double st) { }
virtual void update_terminals() { }
@ -1161,10 +1162,7 @@ namespace netlist
explicit netlist_t(const pstring &aname);
virtual ~netlist_t();
pstring name() const { return m_name; }
void start();
void stop();
/* run functions */
const netlist_time time() const { return m_time; }
devices::NETLIB_NAME(solver) *solver() const { return m_solver; }
@ -1172,19 +1170,26 @@ namespace netlist
/* never use this in constructors! */
nl_double gmin() const;
void push_to_queue(detail::net_t &out, const netlist_time attime) NL_NOEXCEPT;
void remove_from_queue(detail::net_t &out) NL_NOEXCEPT;
void process_queue(const netlist_time &delta);
void abort_current_queue_slice() { m_queue.retime(m_time, nullptr); }
void abort_current_queue_slice() { m_queue.retime(nullptr, m_time); }
void rebuild_lists(); /* must be called after post_load ! */
/* Control functions */
void start();
void stop();
void reset();
const detail::queue_t &queue() const { return m_queue; }
detail::queue_t &queue() { return m_queue; }
/* netlist build functions */
setup_t &setup() { return *m_setup; }
void register_dev(plib::owned_ptr<device_t> dev);
void register_dev(plib::owned_ptr<core_device_t> dev);
detail::net_t *find_net(const pstring &name);
const logic_family_desc_t *family_from_model(const pstring &model);
template<class device_class>
std::vector<device_class *> get_device_list()
@ -1217,38 +1222,36 @@ namespace netlist
return ret;
}
/* logging and name */
pstring name() const { return m_name; }
plib::plog_base<NL_DEBUG> &log() { return m_log; }
const plib::plog_base<NL_DEBUG> &log() const { return m_log; }
/* state related */
plib::state_manager_t &state() { return m_state; }
template<typename O, typename C> void save(O &owner, C &state, const pstring &stname)
{
this->state().save_item(static_cast<void *>(&owner), state, pstring(owner.name()) + "." + stname);
this->state().save_item(static_cast<void *>(&owner), state, owner.name() + pstring(".") + stname);
}
template<typename O, typename C> void save(O &owner, C *state, const pstring &stname, const std::size_t count)
{
this->state().save_state_ptr(static_cast<void *>(&owner), pstring(owner.name()) + "." + stname, plib::state_manager_t::datatype_f<C>::f(), count, state);
this->state().save_state_ptr(static_cast<void *>(&owner), owner.name() + pstring(".") + stname, plib::state_manager_t::datatype_f<C>::f(), count, state);
}
virtual void reset();
void rebuild_lists(); /* must be called after post_load ! */
plib::dynlib &lib() { return *m_lib; }
std::vector<plib::owned_ptr<core_device_t>> m_devices;
/* sole use is to manage lifetime of net objects */
std::vector<plib::owned_ptr<detail::net_t>> m_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;
const detail::queue_t &queue() const { return m_queue; }
detail::queue_t &queue() { return m_queue; }
protected:
void print_stats() const;
private:
plib::state_manager_t m_state;
/* mostly rw */
netlist_time m_time;
detail::queue_t m_queue;
@ -1264,11 +1267,17 @@ namespace netlist
plib::plog_base<NL_DEBUG> m_log;
plib::dynlib * m_lib; // external lib needs to be loaded as long as netlist exists
plib::state_manager_t m_state;
// performance
nperftime_t m_stat_mainloop;
nperfcount_t m_perf_out_processed;
nperfcount_t m_perf_inp_processed;
nperfcount_t m_perf_inp_active;
std::vector<plib::owned_ptr<core_device_t>> m_devices;
/* sole use is to manage lifetime of family objects */
std::vector<std::pair<pstring, std::unique_ptr<logic_family_desc_t>>> m_family_cache;
};
// -----------------------------------------------------------------------------
@ -1387,23 +1396,19 @@ namespace netlist
m_time = netlist().time() + delay;
m_in_queue = (m_active > 0); /* queued ? */
if (m_in_queue)
{
netlist().push_to_queue(*this, m_time);
}
netlist().queue().push(this, m_time);
}
}
inline void detail::net_t::reschedule_in_queue(const netlist_time delay) NL_NOEXCEPT
{
if (is_queued())
netlist().remove_from_queue(*this);
netlist().queue().remove(this);
m_time = netlist().time() + delay;
m_in_queue = (m_active > 0); /* queued ? */
if (m_in_queue)
{
netlist().push_to_queue(*this, m_time);
}
netlist().queue().push(this, m_time);
}
inline const analog_net_t & analog_t::net() const NL_NOEXCEPT
@ -1448,16 +1453,6 @@ namespace netlist
}
}
inline void netlist_t::push_to_queue(detail::net_t &out, const netlist_time attime) NL_NOEXCEPT
{
m_queue.push(attime, &out);
}
inline void netlist_t::remove_from_queue(detail::net_t &out) NL_NOEXCEPT
{
m_queue.remove(&out);
}
template <typename T>
template <typename O>
state_var<T>::state_var(O &owner, const pstring name, const T &value)

View File

@ -47,7 +47,7 @@ namespace netlist
std::size_t capacity() const { return m_list.size(); }
bool empty() const { return (m_end == &m_list[1]); }
void push(const Time t, Element o) noexcept
void push(Element o, const Time t) noexcept
{
#if HAS_OPENMP && USE_OPENMP
/* Lock */
@ -97,10 +97,10 @@ namespace netlist
#endif
}
void retime(const Time t, const Element &elem) noexcept
void retime(const Element &elem, const Time t) noexcept
{
remove(elem);
push(t, elem);
push(elem, t);
}
void clear()

View File

@ -21,7 +21,6 @@
#include "devices/nlid_proxy.h"
#include "analog/nld_twoterm.h"
#include "solver/nld_solver.h"
#include "macro/nlm_base.h"
// ----------------------------------------------------------------------------------------
// setup_t
@ -36,7 +35,6 @@ setup_t::setup_t(netlist_t &netlist)
, m_frontier_cnt(0)
{
initialize_factory(m_factory);
NETLIST_NAME(base)(*this);
}
setup_t::~setup_t()
@ -494,13 +492,6 @@ void setup_t::connect_input_output(detail::core_terminal_t &in, detail::core_ter
{
if (out.is_analog() && in.is_logic())
{
#if 0
logic_input_t &incast = dynamic_cast<logic_input_t &>(in);
pstring x = plib::pfmt("proxy_ad_{1}_{2}")(in.name())( m_proxy_cnt);
auto proxy = plib::owned_ptr<devices::nld_a_to_d_proxy>::Create(netlist(), x, &incast);
incast.set_proxy(proxy.get());
m_proxy_cnt++;
#endif
auto proxy = get_a_d_proxy(in);
out.net().add_terminal(proxy->proxy_term());
@ -531,14 +522,6 @@ void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &
else if (inp.is_logic())
{
netlist().log().verbose("connect terminal {1} (in, {2}) to {3}\n", inp.name(), pstring(inp.is_analog() ? "analog" : inp.is_logic() ? "logic" : "?"), term.name());
#if 0
logic_input_t &incast = dynamic_cast<logic_input_t &>(inp);
log().debug("connect_terminal_input: connecting proxy\n");
pstring x = plib::pfmt("proxy_ad_{1}_{2}")(inp.name())(m_proxy_cnt);
auto proxy = plib::owned_ptr<devices::nld_a_to_d_proxy>::Create(netlist(), x, &incast);
incast.set_proxy(proxy.get());
m_proxy_cnt++;
#endif
auto proxy = get_a_d_proxy(inp);
//out.net().register_con(proxy->proxy_term());
@ -701,7 +684,7 @@ bool setup_t::connect(detail::core_terminal_t &t1_in, detail::core_terminal_t &t
return ret;
}
void setup_t::resolve_inputs1()
void setup_t::resolve_inputs()
{
log().verbose("Resolving inputs ...");
@ -778,7 +761,7 @@ void setup_t::resolve_inputs1()
}
}
void setup_t::start_devices1()
void setup_t::start_devices()
{
pstring env = plib::util::environment("NL_LOGS");
@ -808,59 +791,9 @@ const plib::plog_base<NL_DEBUG> &setup_t::log() const
// ----------------------------------------------------------------------------------------
// Model / family
// Model
// ----------------------------------------------------------------------------------------
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,
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;
};
plib::owned_ptr<devices::nld_base_d_to_a_proxy> logic_family_std_proxy_t::create_d_a_proxy(netlist_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
{
return plib::owned_ptr<devices::nld_base_a_to_d_proxy>::Create<devices::nld_a_to_d_proxy>(anetlist, name, proxied);
}
const logic_family_desc_t *setup_t::family_from_model(const pstring &model)
{
model_map_t map;
model_parse(model, map);
if (setup_t::model_value_str(map, "TYPE") == "TTL")
return family_TTL();
if (setup_t::model_value_str(map, "TYPE") == "CD4XXX")
return family_CD4XXX();
for (auto & e : netlist().m_family_cache)
if (e.first == model)
return e.second.get();
auto ret = plib::make_unique_base<logic_family_desc_t, logic_family_std_proxy_t>();
ret->m_fixed_V = setup_t::model_value(map, "FV");
ret->m_low_thresh_PCNT = setup_t::model_value(map, "IVL");
ret->m_high_thresh_PCNT = setup_t::model_value(map, "IVH");
ret->m_low_VO = setup_t::model_value(map, "OVL");
ret->m_high_VO = setup_t::model_value(map, "OVH");
ret->m_R_low = setup_t::model_value(map, "ORL");
ret->m_R_high = setup_t::model_value(map, "ORH");
auto retp = ret.get();
netlist().m_family_cache.emplace_back(model, std::move(ret));
return retp;
}
static pstring model_string(model_map_t &map)
{
pstring ret = map["COREMODEL"] + "(";

View File

@ -227,8 +227,8 @@ namespace netlist
param_t *find_param(const pstring &param_in, bool required = true) const;
void start_devices1();
void resolve_inputs1();
void start_devices();
void resolve_inputs();
/* handle namespace */
@ -238,6 +238,7 @@ namespace netlist
/* parse a source */
void include(const pstring &netlist_name);
std::unique_ptr<plib::pistream> get_data_stream(const pstring name);
bool parse_stream(plib::pistream &istrm, const pstring &name);
@ -257,7 +258,6 @@ namespace netlist
/* model / family related */
const logic_family_desc_t *family_from_model(const pstring &model);
const pstring model_value_str(model_map_t &map, const pstring &entity);
nl_double model_value(model_map_t &map, const pstring &entity);

View File

@ -140,33 +140,6 @@ private:
template<> void state_manager_t::save_item(const void *owner, callback_t &state, const pstring &stname);
#if 0
template <typename T>
class pstate_interface_t
{
public:
pstate_interface_t() { }
template<typename C> void save(C &state, const pstring &stname)
{
state_manager_t &manager = static_cast<T*>(this)->state_manager();
pstring module = static_cast<T*>(this)->name();
manager.save_item(this, state, module + "." + stname);
}
template<typename C, std::size_t N> void save(C (&state)[N], const pstring &stname)
{
state_manager_t &manager = static_cast<T*>(this)->state_manager();
pstring module = static_cast<T*>(this)->name();
manager.save_state_ptr(this, module + "." + stname, state_manager_t::datatype_f<C>::f(), N, &(state[0]));
}
template<typename C> void save(C *state, const pstring &stname, const int count)
{
state_manager_t &manager = static_cast<T*>(this)->state_manager();
pstring module = static_cast<T*>(this)->name();
manager.save_state_ptr(this, module + "." + stname, state_manager_t::datatype_f<C>::f(), count, state);
}
};
#endif
}
#endif /* PSTATE_H_ */

View File

@ -379,7 +379,7 @@ void matrix_solver_t::update() NL_NOEXCEPT
{
const netlist_time new_timestep = solve();
if (m_params.m_dynamic && has_timestep_devices() && new_timestep > netlist_time::zero())
if (m_params.m_dynamic_ts && has_timestep_devices() && new_timestep > netlist_time::zero())
{
m_Q_sync.net().force_queue_execution();
m_Q_sync.net().reschedule_in_queue(new_timestep);
@ -390,7 +390,7 @@ void matrix_solver_t::update_forced()
{
ATTR_UNUSED const netlist_time new_timestep = solve();
if (m_params.m_dynamic && has_timestep_devices())
if (m_params.m_dynamic_ts && has_timestep_devices())
{
m_Q_sync.net().force_queue_execution();
m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(m_params.m_min_timestep));
@ -488,7 +488,7 @@ netlist_time matrix_solver_t::compute_next_timestep(const double cur_ts)
{
nl_double new_solver_timestep = m_params.m_max_timestep;
if (m_params.m_dynamic)
if (m_params.m_dynamic_ts)
{
/*
* FIXME: We should extend the logic to use either all nets or
@ -509,7 +509,7 @@ netlist_time matrix_solver_t::compute_next_timestep(const double cur_ts)
t->m_h_n_m_1 = hn;
t->m_DD_n_m_1 = DD_n;
if (std::fabs(DD2) > NL_FCONST(1e-60)) // avoid div-by-zero
new_net_timestep = std::sqrt(m_params.m_lte / std::fabs(NL_FCONST(0.5)*DD2));
new_net_timestep = std::sqrt(m_params.m_dynamic_lte / std::fabs(NL_FCONST(0.5)*DD2));
else
new_net_timestep = m_params.m_max_timestep;

View File

@ -24,11 +24,11 @@ namespace netlist
{
int m_pivot;
nl_double m_accuracy;
nl_double m_lte;
nl_double m_dynamic_lte;
nl_double m_min_timestep;
nl_double m_max_timestep;
nl_double m_sor;
bool m_dynamic;
nl_double m_gs_sor;
bool m_dynamic_ts;
unsigned m_gs_loops;
unsigned m_nr_loops;
netlist_time m_nr_recalc_delay;

View File

@ -170,7 +170,7 @@ nl_double matrix_solver_direct_t<m_N, storage_N>::compute_next_timestep()
{
nl_double new_solver_timestep = m_params.m_max_timestep;
if (m_params.m_dynamic)
if (m_params.m_dynamic_ts)
{
/*
* FIXME: We should extend the logic to use either all nets or
@ -189,7 +189,7 @@ nl_double matrix_solver_direct_t<m_N, storage_N>::compute_next_timestep()
n->m_h_n_m_1 = hn;
n->m_DD_n_m_1 = DD_n;
if (std::abs(DD2) > NL_FCONST(1e-30)) // avoid div-by-zero
new_net_timestep = std::sqrt(m_params.m_lte / std::abs(NL_FCONST(0.5)*DD2));
new_net_timestep = std::sqrt(m_params.m_dynamic_lte / std::abs(NL_FCONST(0.5)*DD2));
else
new_net_timestep = m_params.m_max_timestep;

View File

@ -67,7 +67,7 @@ unsigned matrix_solver_SOR_t<m_N, storage_N>::vsolve_non_dynamic(const bool newt
* omega = 2.0 / (1.0 + std::sqrt(1-rho))
*/
const nl_double ws = this->m_params.m_sor;
const nl_double ws = this->m_params.m_gs_sor;
nl_double w[storage_N];
nl_double one_m_w[storage_N];

View File

@ -32,7 +32,7 @@ public:
matrix_solver_SOR_mat_t(netlist_t &anetlist, const pstring &name, const solver_parameters_t *params, const unsigned 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_sor)
, m_omega(*this, "m_omega", params->m_gs_sor)
, m_lp_fact(*this, "m_lp_fact", 0)
, m_gs_fail(*this, "m_gs_fail", 0)
, m_gs_total(*this, "m_gs_total", 0)

View File

@ -84,7 +84,7 @@ NETLIB_NAME(solver)::~NETLIB_NAME(solver)()
NETLIB_UPDATE(solver)
{
if (m_params.m_dynamic)
if (m_params.m_dynamic_ts)
return;
/* force solving during start up if there are no time-step devices */
@ -256,14 +256,14 @@ void NETLIB_NAME(solver)::post_start()
m_params.m_gs_loops = static_cast<unsigned>(m_gs_loops());
m_params.m_nr_loops = static_cast<unsigned>(m_nr_loops());
m_params.m_nr_recalc_delay = netlist_time::from_double(m_nr_recalc_delay());
m_params.m_lte = m_dynamic_lte();
m_params.m_sor = m_gs_sor();
m_params.m_dynamic_lte = m_dynamic_lte();
m_params.m_gs_sor = m_gs_sor();
m_params.m_min_timestep = m_dynamic_min_ts();
m_params.m_dynamic = (m_dynamic_ts() == 1 ? true : false);
m_params.m_dynamic_ts = (m_dynamic_ts() == 1 ? true : false);
m_params.m_max_timestep = netlist_time::from_double(1.0 / m_freq()).as_double();
if (m_params.m_dynamic)
if (m_params.m_dynamic_ts)
{
m_params.m_max_timestep *= 1;//NL_FCONST(1000.0);
}