From 86965e7757f48b1e79b0bd4216045cb4a7cea300 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sat, 4 Jun 2016 23:35:14 +0200 Subject: [PATCH] Refactored netlist_time. (nw) --- nl_examples/cdelay.c | 11 +++ src/devices/machine/netlist.cpp | 12 +-- src/devices/machine/netlist.h | 2 +- src/lib/netlist/devices/nld_74ls629.cpp | 4 +- src/lib/netlist/devices/nld_mm5837.cpp | 1 + src/lib/netlist/devices/nld_system.cpp | 2 +- src/lib/netlist/devices/nld_truthtable.cpp | 4 +- src/lib/netlist/devices/nld_truthtable.h | 9 +-- src/lib/netlist/devices/nlid_system.h | 4 +- src/lib/netlist/nl_base.cpp | 25 +++--- src/lib/netlist/nl_base.h | 90 ++++++++++------------ src/lib/netlist/nl_lists.h | 6 +- src/lib/netlist/nl_time.h | 90 +++++++++++----------- src/lib/netlist/plib/pconfig.h | 6 -- src/lib/netlist/plib/plists.h | 10 +-- src/lib/netlist/prg/nltool.cpp | 2 +- src/lib/netlist/solver/nld_matrix_solver.h | 1 + src/lib/netlist/solver/nld_solver.cpp | 4 +- 18 files changed, 135 insertions(+), 148 deletions(-) diff --git a/nl_examples/cdelay.c b/nl_examples/cdelay.c index 6f396e8ca07..927a7cfe0a4 100644 --- a/nl_examples/cdelay.c +++ b/nl_examples/cdelay.c @@ -7,6 +7,17 @@ #include "netlist/devices/net_lib.h" +NETLIST_START(perf) + + SOLVER(Solver, 48000) + PARAM(Solver.ACCURACY, 1e-20) + MAINCLOCK(clk, 50000000) + + TTL_7400_NAND(n1,clk,clk) + +NETLIST_END() + + NETLIST_START(7400_astable) /* diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index e929bfad96e..bd65d0b2eef 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -264,7 +264,7 @@ ADDRESS_MAP_END netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, NETLIST_CORE, "Netlist core device", tag, owner, clock, "netlist_core", __FILE__), m_icount(0), - m_old(netlist::netlist_time::zero), + m_old(netlist::netlist_time::zero()), m_netlist(nullptr), m_setup(nullptr), m_setup_func(nullptr) @@ -274,7 +274,7 @@ netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, cons netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *file) : device_t(mconfig, type, name, tag, owner, clock, shortname, file), m_icount(0), - m_old(netlist::netlist_time::zero), + m_old(netlist::netlist_time::zero()), m_netlist(nullptr), m_setup(nullptr), m_setup_func(nullptr) @@ -328,8 +328,8 @@ void netlist_mame_device_t::device_start() save_state(); - m_old = netlist::netlist_time::zero; - m_rem = netlist::netlist_time::zero; + m_old = netlist::netlist_time::zero(); + m_rem = netlist::netlist_time::zero(); LOG_DEV_CALLS(("device_start exit %s\n", tag())); } @@ -344,8 +344,8 @@ void netlist_mame_device_t::device_clock_changed() void netlist_mame_device_t::device_reset() { LOG_DEV_CALLS(("device_reset\n")); - m_old = netlist::netlist_time::zero; - m_rem = netlist::netlist_time::zero; + m_old = netlist::netlist_time::zero(); + m_rem = netlist::netlist_time::zero(); netlist().reset(); } diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 136921af079..8eba71f8ba1 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -569,7 +569,7 @@ public: { m_cur = 0.0; m_last_pos = 0; - m_last_buffer = netlist::netlist_time::zero; + m_last_buffer = netlist::netlist_time::zero(); } ATTR_HOT void sound_update(const netlist::netlist_time &upto) diff --git a/src/lib/netlist/devices/nld_74ls629.cpp b/src/lib/netlist/devices/nld_74ls629.cpp index 569fb38706f..eb9fbd7f712 100644 --- a/src/lib/netlist/devices/nld_74ls629.cpp +++ b/src/lib/netlist/devices/nld_74ls629.cpp @@ -54,7 +54,7 @@ namespace netlist , m_Y(*this, "Y") , m_enableq(1) , m_out(0) - , m_inc(netlist_time::zero) + , m_inc(netlist_time::zero()) { connect_late(m_FB, m_Y); @@ -67,7 +67,7 @@ namespace netlist { m_enableq = 1; m_out = 0; - m_inc = netlist_time::zero; + m_inc = netlist_time::zero(); } NETLIB_UPDATEI(); diff --git a/src/lib/netlist/devices/nld_mm5837.cpp b/src/lib/netlist/devices/nld_mm5837.cpp index 652bec34d15..9624bec2621 100644 --- a/src/lib/netlist/devices/nld_mm5837.cpp +++ b/src/lib/netlist/devices/nld_mm5837.cpp @@ -28,6 +28,7 @@ namespace netlist /* clock */ , m_feedback(*this, "FB") , m_Q(*this, "Q") + , m_inc(0, 1) , m_is_timestep(false) { m_inc = netlist_time::from_hz(56000); diff --git a/src/lib/netlist/devices/nld_system.cpp b/src/lib/netlist/devices/nld_system.cpp index 5ec1235d35d..9f5f68b004a 100644 --- a/src/lib/netlist/devices/nld_system.cpp +++ b/src/lib/netlist/devices/nld_system.cpp @@ -48,7 +48,7 @@ namespace netlist { OUTLOGIC(m_Q, (m_cnt & 1) ^ 1, m_inc[m_cnt] + m_off); m_cnt = (m_cnt + 1) % m_size; - m_off = netlist_time::zero; + m_off = netlist_time::zero(); } // ---------------------------------------------------------------------------------------- diff --git a/src/lib/netlist/devices/nld_truthtable.cpp b/src/lib/netlist/devices/nld_truthtable.cpp index 5aa4be0b572..e921f1411de 100644 --- a/src/lib/netlist/devices/nld_truthtable.cpp +++ b/src/lib/netlist/devices/nld_truthtable.cpp @@ -163,7 +163,7 @@ void truthtable_desc_t::setup(const plib::pstring_vector_t &truthtable, UINT32 d m_outs[j] = ~0L; for (int j=0; j < 16; j++) - m_timing_nt[j] = netlist_time::zero; + m_timing_nt[j] = netlist_time::zero(); while (!ttline.equals("")) { @@ -189,7 +189,7 @@ void truthtable_desc_t::setup(const plib::pstring_vector_t &truthtable, UINT32 d nl_assert_always(outs.equals("0"), "Unknown value (not 0 or 1"); netlist_time t = netlist_time::from_nsec(times[j].trim().as_long()); int k=0; - while (m_timing_nt[k] != netlist_time::zero && m_timing_nt[k] != t) + while (m_timing_nt[k] != netlist_time::zero() && m_timing_nt[k] != t) k++; m_timing_nt[k] = t; tindex.push_back(k); //[j] = k; diff --git a/src/lib/netlist/devices/nld_truthtable.h b/src/lib/netlist/devices/nld_truthtable.h index d4ab92333d9..c227da33fdc 100644 --- a/src/lib/netlist/devices/nld_truthtable.h +++ b/src/lib/netlist/devices/nld_truthtable.h @@ -201,7 +201,7 @@ public: for (int j=0; j < m_size; j++) printf("%05x %04x %04x %04x\n", j, m_ttp->m_outs[j] & ((1 << m_NO)-1), m_ttp->m_outs[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++) + 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 save(NLNAME(m_last_state)); @@ -267,7 +267,7 @@ private: template inline void process() { - netlist_time mt = netlist_time::zero; + netlist_time mt = netlist_time::zero(); UINT32 state = 0; if (m_NI > 1 && !has_state) @@ -294,11 +294,6 @@ private: if (has_state) m_last_state = (state << m_NO) | out; -#if 0 - for (int i = 0; i < m_NI; i++) - if (m_ign & (1 << i)) - m_I[i].inactivate(); -#endif const UINT32 timebase = nstate * m_NO; if (doOUT) { diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 5ecdcac1107..2ae5f9f9c32 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -54,7 +54,7 @@ namespace netlist NETLIB_RESETI() { - m_Q.net().set_time(netlist_time::zero); + m_Q.net().set_time(netlist_time::zero()); } NETLIB_UPDATE_PARAMI() @@ -136,7 +136,7 @@ namespace netlist pati[i] = pat[i].as_long(); total += pati[i]; } - netlist_time ttotal = netlist_time::zero; + netlist_time ttotal = netlist_time::zero(); for (unsigned i=0; im_Q.net().set_time(netlist_time::zero); + m_mainclock->m_Q.net().set_time(netlist_time::zero()); //if (m_solver != nullptr) // m_solver->do_reset(); @@ -336,9 +334,9 @@ void netlist_t::process_queue(const netlist_time &delta) if (m_mainclock == nullptr) { - while ( (m_time < m_stop) && (!m_queue.empty())) + while ( (m_time < m_stop) & (!m_queue.empty())) { - const queue_t::entry_t &e = m_queue.pop(); + const queue_t::entry_t e(m_queue.pop()); m_time = e.m_exec_time; e.m_object->update_devs(); @@ -456,9 +454,6 @@ core_device_t::~core_device_t() void core_device_t::set_delegate_pointer() { -#if (NL_KEEP_STATISTICS) - netlist().m_started_devices.push_back(this); -#endif #if (NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF) void (core_device_t::* pFunc)() = &core_device_t::update; m_static_update = pFunc; @@ -578,7 +573,7 @@ net_t::net_t(netlist_t &nl, const pstring &aname, core_terminal_t *mr) : object_t(nl, aname, NET) , m_new_Q(0) , m_cur_Q (0) - , m_time(netlist_time::zero) + , m_time(netlist_time::zero()) , m_active(0) , m_in_queue(2) , m_railterminal(nullptr) @@ -612,7 +607,7 @@ void net_t::inc_active(core_terminal_t &term) { if (netlist().use_deactivate()) { - railterminal().device().inc_active(); + railterminal().device().do_inc_active(); //m_cur_Q = m_new_Q; } if (m_in_queue == 0) @@ -639,7 +634,7 @@ void net_t::dec_active(core_terminal_t &term) nl_assert(m_active >= 0); m_list_active.remove(term); if (m_active == 0 && netlist().use_deactivate()) - railterminal().device().dec_active(); + railterminal().device().do_dec_active(); } void net_t::rebuild_list() @@ -685,7 +680,7 @@ void net_t::update_devs() void net_t::reset() { - m_time = netlist_time::zero; + m_time = netlist_time::zero(); m_active = 0; m_in_queue = 2; diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index b3bb7923149..1f14d04bce8 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -322,7 +322,7 @@ namespace netlist logic_family_t() : m_logic_family(nullptr) {} ~logic_family_t() { } - const logic_family_desc_t *logic_family() const { return m_logic_family; } + const logic_family_desc_t *logic_family() const { return m_logic_family; } void set_logic_family(const logic_family_desc_t *fam) { m_logic_family = fam; } protected: @@ -366,11 +366,11 @@ namespace netlist plib::pstate_manager_t &state_manager(); - type_t type() const { return m_objtype; } - bool isType(const type_t atype) const { return (m_objtype == atype); } + type_t type() const { return m_objtype; } + bool isType(const type_t atype) const { return (m_objtype == atype); } - netlist_t & netlist() { return m_netlist; } - const netlist_t & netlist() const { return m_netlist; } + netlist_t & netlist() { return m_netlist; } + const netlist_t & netlist() const { return m_netlist; } private: netlist_t & m_netlist; @@ -433,9 +433,9 @@ namespace netlist bool is_logic() const; bool is_analog() const; - bool is_state(const state_e astate) const { return (m_state == astate); } - state_e state() const { return m_state; } - void set_state(const state_e astate) + bool is_state(const state_e astate) const { return (m_state == astate); } + state_e state() const { return m_state; } + void set_state(const state_e astate) { nl_assert(astate != STATE_NONEX); m_state = astate; @@ -485,21 +485,21 @@ namespace netlist terminal_t *m_otherterm; - void set(const nl_double G) + void set(const nl_double G) { set_ptr(m_Idr1, 0); set_ptr(m_go1, G); set_ptr(m_gt1, G); } - void set(const nl_double GO, const nl_double GT) + void set(const nl_double GO, const nl_double GT) { set_ptr(m_Idr1, 0); set_ptr(m_go1, GO); set_ptr(m_gt1, GT); } - void set(const nl_double GO, const nl_double GT, const nl_double I) + void set(const nl_double GO, const nl_double GT, const nl_double I) { set_ptr(m_Idr1, I); set_ptr(m_go1, GO); @@ -551,8 +551,8 @@ namespace netlist devices::nld_base_proxy *get_proxy() const { return m_proxy; } void set_proxy(devices::nld_base_proxy *proxy) { m_proxy = proxy; } - logic_net_t & net(); - const logic_net_t & net() const; + logic_net_t & net(); + const logic_net_t & net() const; protected: @@ -592,7 +592,8 @@ namespace netlist { public: analog_input_t(core_device_t &dev, const pstring &aname); - nl_double Q_Analog() const; + + nl_double Q_Analog() const; protected: virtual void reset() override @@ -683,7 +684,7 @@ namespace netlist netlist_sig_t new_Q() const { return m_new_Q; } void initial(const netlist_sig_t val) { m_cur_Q = m_new_Q = val; } - void set_Q(const netlist_sig_t newQ, const netlist_time &delay) NOEXCEPT + void set_Q(const netlist_sig_t newQ, const netlist_time delay) NOEXCEPT { if (newQ != m_new_Q) { @@ -692,7 +693,7 @@ namespace netlist } } - void set_Q_time(const netlist_sig_t newQ, const netlist_time &at) + void set_Q_time(const netlist_sig_t newQ, const netlist_time at) { if (newQ != m_new_Q) { @@ -745,8 +746,6 @@ namespace netlist P_PREVENT_COPYING(logic_output_t) public: - friend class core_device_t; //FIXME - logic_output_t(core_device_t &dev, const pstring &aname); virtual void reset() override @@ -756,10 +755,10 @@ namespace netlist void initial(const netlist_sig_t val); - void set_Q(const netlist_sig_t newQ, const netlist_time &delay) NOEXCEPT + void set_Q(const netlist_sig_t newQ, const netlist_time delay) NOEXCEPT { //net().set_Q(newQ, delay); - m_my_net.set_Q(newQ, delay); + m_my_net.set_Q(newQ, delay); // take the shortcut } private: @@ -774,7 +773,7 @@ namespace netlist analog_output_t(core_device_t &dev, const pstring &aname); void initial(const nl_double val); - void set_Q(const nl_double newQ); + void set_Q(const nl_double newQ); analog_net_t *m_proxied_net; // only for proxy nets in analog input logic @@ -819,9 +818,9 @@ namespace netlist operator const C() const { return Value(); } - void setTo(const C ¶m); - void initial(const C &val) { m_param = val; } - C Value() const { return m_param; } + void setTo(const C ¶m); + void initial(const C &val) { m_param = val; } + C Value() const { return m_param; } protected: virtual void changed() { } @@ -870,7 +869,7 @@ namespace netlist virtual ~core_device_t(); - void update_dev() + void update_dev() { begin_timing(stat_total_time); inc_stat(stat_update_count); @@ -892,26 +891,21 @@ namespace netlist void set_delegate_pointer(); void stop_dev(); - netlist_sig_t INPLOGIC_PASSIVE(logic_input_t &inp); + void do_inc_active() { inc_active(); } + void do_dec_active() { dec_active(); } + void do_reset() { reset(); } + netlist_sig_t INPLOGIC_PASSIVE(logic_input_t &inp); netlist_sig_t INPLOGIC(const logic_input_t &inp) const { nl_assert(inp.state() != logic_t::STATE_INP_PASSIVE); return inp.Q(); } - void OUTLOGIC(logic_output_t &out, const netlist_sig_t val, const netlist_time &delay) NOEXCEPT; - - nl_double INPANALOG(const analog_input_t &inp) const { return inp.Q_Analog(); } - - nl_double TERMANALOG(const terminal_t &term) const { return term.net().Q_Analog(); } - - void OUTANALOG(analog_output_t &out, const nl_double val) - { - out.set_Q(val); - } - - void do_reset() { reset(); } + void OUTLOGIC(logic_output_t &out, const netlist_sig_t val, const netlist_time delay) NOEXCEPT; + nl_double INPANALOG(const analog_input_t &inp) const { return inp.Q_Analog(); } + nl_double TERMANALOG(const terminal_t &term) const { return term.net().Q_Analog(); } + void OUTANALOG(analog_output_t &out, const nl_double val) { out.set_Q(val); } #if (NL_KEEP_STATISTICS) /* stats */ @@ -923,12 +917,12 @@ namespace netlist protected: virtual void update() NOEXCEPT { } + virtual void inc_active() { } + virtual void dec_active() { } virtual void stop() { } virtual void reset() { } public: - virtual void inc_active() { } - virtual void dec_active() { } virtual void step_time(ATTR_UNUSED const nl_double st) { } virtual void update_terminals() { } @@ -1080,11 +1074,11 @@ namespace netlist devices::NETLIB_NAME(gnd) *gnd() const { return m_gnd; } nl_double gmin() const; - void push_to_queue(net_t &out, const netlist_time &attime) NOEXCEPT; + void push_to_queue(net_t &out, const netlist_time attime) NOEXCEPT; void remove_from_queue(net_t &out); void process_queue(const netlist_time &delta); - void abort_current_queue_slice() { m_stop = netlist_time::zero; } + void abort_current_queue_slice() { m_stop = netlist_time::zero(); } bool use_deactivate() const { return m_use_deactivate; } @@ -1126,10 +1120,6 @@ namespace netlist return ret; } - #if (NL_KEEP_STATISTICS) - pvector_t m_started_devices; - #endif - plib::plog_base &log() { return m_log; } const plib::plog_base &log() const { return m_log; } @@ -1238,7 +1228,7 @@ protected: inline void logic_input_t::inactivate() { - if (EXPECTED(!is_state(STATE_INP_PASSIVE))) + if (!is_state(STATE_INP_PASSIVE)) { set_state(STATE_INP_PASSIVE); net().dec_active(*this); @@ -1292,7 +1282,7 @@ protected: m_time = netlist().time() + delay; m_in_queue = (m_active > 0); /* queued ? */ - if (EXPECTED(m_in_queue)) + if (m_in_queue) { netlist().push_to_queue(*this, m_time); } @@ -1338,7 +1328,7 @@ protected: } } - inline void netlist_t::push_to_queue(net_t &out, const netlist_time &attime) NOEXCEPT + inline void netlist_t::push_to_queue(net_t &out, const netlist_time attime) NOEXCEPT { m_queue.push(attime, &out); } @@ -1348,7 +1338,7 @@ protected: m_queue.remove(&out); } - inline void core_device_t::OUTLOGIC(logic_output_t &out, const netlist_sig_t val, const netlist_time &delay) NOEXCEPT + inline void core_device_t::OUTLOGIC(logic_output_t &out, const netlist_sig_t val, const netlist_time delay) NOEXCEPT { out.set_Q(val, delay); } diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 1692990d14d..92cdbc61c57 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -67,8 +67,8 @@ namespace netlist //nl_assert(m_end - m_list < Size); } - const entry_t & pop() NOEXCEPT { return *(--m_end); } - const entry_t & top() const NOEXCEPT { return *(m_end-1); } + entry_t pop() NOEXCEPT { return *(--m_end); } + entry_t top() const NOEXCEPT { return *(m_end-1); } void remove(const Element &elem) NOEXCEPT { @@ -104,7 +104,7 @@ namespace netlist * the insert algo above will run into this element and doesn't * need a comparison with queue start. */ - m_list[0] = { Time::from_raw(~0), Element(0) }; + m_list[0] = { Time::never(), Element(0) }; m_end++; } diff --git a/src/lib/netlist/nl_time.h b/src/lib/netlist/nl_time.h index e05d6aa6b53..ed28cedc932 100644 --- a/src/lib/netlist/nl_time.h +++ b/src/lib/netlist/nl_time.h @@ -25,7 +25,7 @@ namespace netlist { - struct netlist_time + struct netlist_time final { public: @@ -34,93 +34,93 @@ namespace netlist static const pstate_data_type_e STATETYPE = DT_INT128; #else using INTERNALTYPE = UINT64; - static const pstate_data_type_e STATETYPE = pstate_data_type_e::DT_INT64; + static constexpr pstate_data_type_e STATETYPE = pstate_data_type_e::DT_INT64; #endif - static const INTERNALTYPE RESOLUTION = NETLIST_INTERNAL_RES; - - netlist_time() : m_time(0) {} - explicit netlist_time(const double t) - : m_time((INTERNALTYPE) ( t * (double) RESOLUTION)) { } - explicit netlist_time(const INTERNALTYPE nom, const INTERNALTYPE den) - : m_time(nom * (RESOLUTION / den)) { } + static constexpr INTERNALTYPE RESOLUTION = NETLIST_INTERNAL_RES; + constexpr netlist_time() NOEXCEPT : m_time(0) {} netlist_time(const netlist_time &rhs) NOEXCEPT = default; netlist_time(netlist_time &&rhs) NOEXCEPT = default; - netlist_time &operator+=(const netlist_time &right) { m_time += right.m_time; return *this; } - netlist_time &operator-=(const netlist_time &right) { m_time -= right.m_time; return *this; } + constexpr explicit netlist_time(const double t) + : m_time((INTERNALTYPE) ( t * (double) RESOLUTION)) { } + constexpr explicit netlist_time(const INTERNALTYPE nom, const INTERNALTYPE den) + : m_time(nom * (RESOLUTION / den)) { } - friend netlist_time operator-(netlist_time left, const netlist_time &right) + + netlist_time &operator=(const netlist_time rhs) { m_time = rhs.m_time; return *this; } + + netlist_time &operator+=(const netlist_time &rhs) { m_time += rhs.m_time; return *this; } + netlist_time &operator-=(const netlist_time &rhs) { m_time -= rhs.m_time; return *this; } + + friend netlist_time operator-(netlist_time lhs, const netlist_time &rhs) { - left -= right; - return left; + lhs -= rhs; + return lhs; } - friend netlist_time operator+(netlist_time left, const netlist_time &right) + friend netlist_time operator+(netlist_time lhs, const netlist_time &rhs) { - left += right; - return left; + lhs += rhs; + return lhs; } - friend netlist_time operator*(netlist_time left, const UINT64 factor) + friend netlist_time operator*(netlist_time lhs, const UINT64 factor) { - left.m_time *= factor; - return left; + lhs.m_time *= static_cast(factor); + return lhs; } - friend UINT64 operator/(const netlist_time &left, const netlist_time &right) + friend UINT64 operator/(const netlist_time &lhs, const netlist_time &rhs) { - return left.m_time / right.m_time; + return static_cast(lhs.m_time / rhs.m_time); } - friend bool operator<(const netlist_time &left, const netlist_time &right) + friend bool operator<(const netlist_time &lhs, const netlist_time &rhs) { - return (left.m_time < right.m_time); + return (lhs.m_time < rhs.m_time); } - friend bool operator>(const netlist_time &left, const netlist_time &right) + friend bool operator>(const netlist_time &lhs, const netlist_time &rhs) { - return right < left; + return rhs < lhs; } - friend bool operator<=(const netlist_time &left, const netlist_time &right) + friend bool operator<=(const netlist_time &lhs, const netlist_time &rhs) { - return !(left > right); + return !(lhs > rhs); } - friend bool operator>=(const netlist_time &left, const netlist_time &right) + friend bool operator>=(const netlist_time &lhs, const netlist_time &rhs) { - return !(left < right); + return !(lhs < rhs); } - friend bool operator==(const netlist_time &left, const netlist_time &right) + friend bool operator==(const netlist_time &lhs, const netlist_time &rhs) { - return (left.m_time == right.m_time); + return lhs.m_time == rhs.m_time; } - friend bool operator!=(const netlist_time &left, const netlist_time &right) + friend bool operator!=(const netlist_time &lhs, const netlist_time &rhs) { - return !(left == right); + return lhs.m_time != rhs.m_time; } - netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; } - INTERNALTYPE as_raw() const { return m_time; } double as_double() const { return (double) m_time / (double) RESOLUTION; } // for save states .... INTERNALTYPE *get_internaltype_ptr() { return &m_time; } - static netlist_time from_nsec(const INTERNALTYPE ns) { return netlist_time(ns, U64(1000000000)); } - static netlist_time from_usec(const INTERNALTYPE us) { return netlist_time(us, U64(1000000)); } - static netlist_time from_msec(const INTERNALTYPE ms) { return netlist_time(ms, U64(1000)); } - static netlist_time from_hz(const INTERNALTYPE hz) { return netlist_time(1 , hz); } - static netlist_time from_raw(const INTERNALTYPE raw) { return netlist_time(raw, RESOLUTION); } - - static const netlist_time zero; - - protected: + static inline netlist_time from_nsec(const INTERNALTYPE ns) { return netlist_time(ns, U64(1000000000)); } + static inline netlist_time from_usec(const INTERNALTYPE us) { return netlist_time(us, U64(1000000)); } + static inline netlist_time from_msec(const INTERNALTYPE ms) { return netlist_time(ms, U64(1000)); } + static inline netlist_time from_hz(const INTERNALTYPE hz) { return netlist_time(1 , hz); } + static inline netlist_time from_raw(const INTERNALTYPE raw) { return netlist_time(raw, RESOLUTION); } + static inline netlist_time zero() { return netlist_time(0, RESOLUTION); } + static inline netlist_time quantum() { return netlist_time(1, RESOLUTION); } + static inline netlist_time never() { return netlist_time(std::numeric_limits::max(), RESOLUTION); } private: INTERNALTYPE m_time; }; diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 8ba86bc290b..506c77c6f8d 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -90,13 +90,7 @@ typedef _int128_t INT128; #define MEMBER_ABI #endif -/* not supported in GCC prior to 4.4.x */ -#define __attribute__((hot)) -#define __attribute__((cold)) - #define RESTRICT __restrict__ -#define EXPECTED(x) (x) -#define UNEXPECTED(x) (x) #define ATTR_PRINTF(x,y) __attribute__((format(printf, x, y))) #define ATTR_UNUSED __attribute__((__unused__)) diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index f057adfc366..6448e640ea5 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -168,13 +168,13 @@ public: } } #endif - void insert(LC &elem) + void insert(LC &elem) { elem.m_next = m_head; m_head = &elem; } - void add(LC &elem) + void add(LC &elem) { LC **p = &m_head; while (*p != nullptr) @@ -185,10 +185,10 @@ public: elem.m_next = nullptr; } - void remove(const LC &elem) + void remove(const LC &elem) { - LC **p; - for (p = &m_head; *p != &elem; p = &((*p)->m_next)) + auto p = &m_head; + for ( ; *p != &elem; p = &((*p)->m_next)) { //nl_assert(*p != nullptr); } diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index b9cdeff542e..2e78aceec0a 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -233,7 +233,7 @@ static void run(tool_options_t &opts) t = plib::ticks(); unsigned pos = 0; - netlist::netlist_time nlt = netlist::netlist_time::zero; + netlist::netlist_time nlt = netlist::netlist_time::zero(); while (pos < inps->size() && (*inps)[pos].m_time < netlist::netlist_time(ttr)) { diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index 7d0b74383ca..af47a18e88e 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -115,6 +115,7 @@ public: m_iterative_fail(0), m_iterative_total(0), m_params(*params), + m_last_step(0, 1), m_cur_ts(0), m_fb_sync(*this, "FB_sync"), m_Q_sync(*this, "Q_sync"), diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index b4d866e708b..102aa4e377b 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -382,14 +382,14 @@ void matrix_solver_t::update_dynamic() void matrix_solver_t::reset() { - m_last_step = netlist_time::zero; + m_last_step = netlist_time::zero(); } void matrix_solver_t::update() 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 && has_timestep_devices() && new_timestep > netlist_time::zero()) { m_Q_sync.net().toggle_new_Q(); m_Q_sync.net().reschedule_in_queue(new_timestep);