From fdc9787c23f7bb462fec24e8cc0f40cf2ae8c12d Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 3 May 2020 18:00:34 +0200 Subject: [PATCH] netlist: simplify pfunction state handling. (nw) Removes dependency on pstate.h. --- src/lib/netlist/analog/nlid_twoterm.h | 6 ++++-- src/lib/netlist/devices/nlid_system.h | 6 ++++-- src/lib/netlist/plib/pfunction.h | 22 +++++++--------------- src/lib/netlist/plib/prandom.h | 2 +- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index c815c2c4b3f..161e1fc924f 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -553,9 +553,10 @@ namespace analog , m_R(*this, "RI", nlconst::magic(0.1)) , m_V(*this, "V", nlconst::zero()) , m_func(*this,"FUNC", "") - , m_compiled(this->name() + ".FUNCC", this, this->state().run_state_manager()) + , m_compiled() , m_funcparam({nlconst::zero()}) { + m_compiled.save_state(*this, "m_compiled"); register_subalias("P", P()); register_subalias("N", N()); if (m_func() != "") @@ -601,9 +602,10 @@ namespace analog , m_t(*this, "m_t", nlconst::zero()) , m_I(*this, "I", nlconst::one()) , m_func(*this,"FUNC", "") - , m_compiled(this->name() + ".FUNCC", this, this->state().run_state_manager()) + , m_compiled() , m_funcparam({nlconst::zero()}) { + m_compiled.save_state(*this, "m_compiled"); register_subalias("P", P()); register_subalias("N", N()); if (m_func() != "") diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 2e55d181e9f..9e0531f80cb 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -127,9 +127,10 @@ namespace devices , m_feedback(*this, "FB") , m_Q(*this, "Q") , m_func(*this,"FUNC", "") - , m_compiled(this->name() + ".FUNCC", this, this->state().run_state_manager()) + , m_compiled() , m_funcparam({nlconst::zero()}) { + m_compiled.save_state(*this, "m_compiled"); if (m_func() != "") m_compiled.compile(m_func(), std::vector({{pstring("T")}})); connect(m_feedback, m_Q); @@ -395,8 +396,9 @@ namespace devices , m_N(*this, "N", 1) , m_func(*this, "FUNC", "A0") , m_Q(*this, "Q") - , m_compiled(this->name() + ".FUNCC", this, this->state().run_state_manager()) + , m_compiled() { + m_compiled.save_state(*this, "m_compiled"); std::vector inps; for (int i=0; i < m_N(); i++) { diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h index e5c1417bb7f..bf76b3f14d1 100644 --- a/src/lib/netlist/plib/pfunction.h +++ b/src/lib/netlist/plib/pfunction.h @@ -9,7 +9,6 @@ /// #include "pmath.h" -#include "pstate.h" #include "pstring.h" #include "putil.h" @@ -57,20 +56,7 @@ namespace plib { using inputs_container = std::vector; using values_container = std::vector; - /// \brief Constructor with state saving support - /// - /// \param name Name of this object - /// \param owner Owner of this object - /// \param state_manager State manager to handle saving object state - /// - /// - pfunction(const pstring &name, const void *owner, state_manager_t &state_manager) - : m_lfsr(0xace1U) // NOLINT - { - state_manager.save_item(owner, m_lfsr, name + ".lfsr"); - } - - /// \brief Constructor without state saving support + /// \brief Constructor /// pfunction() : m_lfsr(0xace1U) // NOLINT @@ -106,6 +92,12 @@ namespace plib { /// value_type evaluate(const values_container &values = values_container()) noexcept; + template + void save_state(ST &st, const STR &name) + { + st.save_item(m_lfsr, name, "m_lfsr"); + } + private: void compile_postfix(const inputs_container &inputs, diff --git a/src/lib/netlist/plib/prandom.h b/src/lib/netlist/plib/prandom.h index 5aebb9ccca4..8c607719930 100644 --- a/src/lib/netlist/plib/prandom.h +++ b/src/lib/netlist/plib/prandom.h @@ -199,7 +199,7 @@ namespace plib } else { - // last value with error for log(s)/s + // last value without error for log(s)/s // double: 1.000000e-305 // float: 9.999999e-37 // FIXME: with 128 bit randoms log(s)/w will fail 1/(2^128) ~ 2.9e-39