mirror of
https://github.com/holub/mame
synced 2025-06-17 17:59:05 +03:00
netlist: simplify pfunction state handling. (nw)
Removes dependency on pstate.h.
This commit is contained in:
parent
b2c40086e6
commit
fdc9787c23
@ -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() != "")
|
||||
|
@ -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>({{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<pstring> inps;
|
||||
for (int i=0; i < m_N(); i++)
|
||||
{
|
||||
|
@ -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<pstring>;
|
||||
using values_container = std::vector<value_type>;
|
||||
|
||||
/// \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 <typename ST, typename STR>
|
||||
void save_state(ST &st, const STR &name)
|
||||
{
|
||||
st.save_item(m_lfsr, name, "m_lfsr");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void compile_postfix(const inputs_container &inputs,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user