From fb9bf71e40e80f4207768a56d24ce401a4e371b2 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 10 May 2015 19:28:45 +0200 Subject: [PATCH] Fixed recursive call in nl_math. Straightened some code. (nw) --- src/emu/netlist/analog/nld_bjt.c | 2 +- src/emu/netlist/nl_base.c | 23 +++++++++++++---------- src/emu/netlist/nl_base.h | 6 ++++++ src/emu/netlist/nl_util.h | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/emu/netlist/analog/nld_bjt.c b/src/emu/netlist/analog/nld_bjt.c index 4f78195c082..332860342cd 100644 --- a/src/emu/netlist/analog/nld_bjt.c +++ b/src/emu/netlist/analog/nld_bjt.c @@ -27,7 +27,7 @@ public: } nl_double I(const nl_double V) const { return m_Is * nl_math::exp(V * m_VT_inv) - m_Is; } nl_double g(const nl_double V) const { return m_Is * m_VT_inv * nl_math::exp(V * m_VT_inv); } - nl_double V(const nl_double I) const { return nl_math::log1p(I / m_Is) * m_VT; } // log1p(x)=log(1.0 + x) + nl_double V(const nl_double I) const { return nl_math::e_log1p(I / m_Is) * m_VT; } // log1p(x)=log(1.0 + x) nl_double gI(const nl_double I) const { return m_VT_inv * (I + m_Is); } private: diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c index 15f4852e16f..7fe017a73ca 100644 --- a/src/emu/netlist/nl_base.c +++ b/src/emu/netlist/nl_base.c @@ -610,16 +610,12 @@ ATTR_COLD void netlist_net_t::save_register() netlist_object_t::save_register(); } -ATTR_HOT /*ATTR_ALIGN*/ static inline void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) +ATTR_HOT inline void netlist_core_terminal_t::update_dev(const UINT32 mask) { - netlist_core_device_t &netdev = inp->netdev(); - inc_stat(netdev.stat_call_count); - if ((inp->state() & mask) != 0) + inc_stat(netdev().stat_call_count); + if ((state() & mask) != 0) { - begin_timing(netdev.stat_total_time); - inc_stat(netdev.stat_update_count); - netdev.update_dev(); - end_timing(netdev.stat_total_time); + netdev().update_dev(); } } @@ -635,9 +631,9 @@ ATTR_HOT /*ATTR_ALIGN*/ inline void netlist_net_t::update_devs() m_in_queue = 2; /* mark as taken ... */ m_cur_Q = m_new_Q; +#if 0 switch (m_active) { -#if 0 case 2: update_dev(p, mask); p = m_list_active.next(p); @@ -645,7 +641,6 @@ ATTR_HOT /*ATTR_ALIGN*/ inline void netlist_net_t::update_devs() case 1: update_dev(p, mask); break; -#endif default: while (p != NULL) { @@ -654,6 +649,14 @@ ATTR_HOT /*ATTR_ALIGN*/ inline void netlist_net_t::update_devs() } break; } +#else + while (p != NULL) + { + //update_dev(p, mask); + p->update_dev(mask); + p = m_list_active.next(p); + } +#endif } diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h index 173348a6838..5161d7660ee 100644 --- a/src/emu/netlist/nl_base.h +++ b/src/emu/netlist/nl_base.h @@ -449,6 +449,9 @@ public: m_state = astate; } + /* inline, only intended to be called from nl_base.c */ + ATTR_HOT inline void update_dev(const UINT32 mask); + protected: ATTR_COLD virtual void save_register() { @@ -955,11 +958,14 @@ public: ATTR_HOT inline void update_dev() { + begin_timing(stat_total_time); + inc_stat(stat_update_count); #if USE_PMFDELEGATES static_update(this); #else update(); #endif + end_timing(stat_total_time); } ATTR_COLD void start_dev(); diff --git a/src/emu/netlist/nl_util.h b/src/emu/netlist/nl_util.h index 461552ce578..6aea597977a 100644 --- a/src/emu/netlist/nl_util.h +++ b/src/emu/netlist/nl_util.h @@ -57,8 +57,8 @@ public: ATTR_HOT inline static double log1p(const double x) { return nl_math::log(1.0 + x); } ATTR_HOT inline static float log1p(const float x) { return nl_math::log(1.0 + x); } #else - ATTR_HOT inline static double log1p(const double x) { return log1p(x); } - ATTR_HOT inline static float log1p(const float x) { return log1pf(x); } + ATTR_HOT inline static double e_log1p(const double x) { return log1p(x); } + ATTR_HOT inline static float e_log1p(const float x) { return log1pf(x); } #endif ATTR_HOT inline static double sqrt(const double x) { return std::sqrt(x); } ATTR_HOT inline static float sqrt(const float x) { return std::sqrt(x); }