mirror of
https://github.com/holub/mame
synced 2025-06-27 22:54:42 +03:00
Fix state saving for pfunction lfsr. (nw)
This commit is contained in:
parent
a0e5e36bd5
commit
2f31991e76
@ -392,6 +392,7 @@ public:
|
|||||||
, m_R(*this, "R", 0.1)
|
, m_R(*this, "R", 0.1)
|
||||||
, m_V(*this, "V", 0.0)
|
, m_V(*this, "V", 0.0)
|
||||||
, m_func(*this,"FUNC", "")
|
, m_func(*this,"FUNC", "")
|
||||||
|
, m_compiled(this->name() + ".FUNCC", this, this->netlist().state())
|
||||||
{
|
{
|
||||||
register_subalias("P", m_P);
|
register_subalias("P", m_P);
|
||||||
register_subalias("N", m_N);
|
register_subalias("N", m_N);
|
||||||
@ -422,6 +423,7 @@ public:
|
|||||||
NETLIB_CONSTRUCTOR_DERIVED(CS, twoterm)
|
NETLIB_CONSTRUCTOR_DERIVED(CS, twoterm)
|
||||||
, m_I(*this, "I", 1.0)
|
, m_I(*this, "I", 1.0)
|
||||||
, m_func(*this,"FUNC", "")
|
, m_func(*this,"FUNC", "")
|
||||||
|
, m_compiled(this->name() + ".FUNCC", this, this->netlist().state())
|
||||||
{
|
{
|
||||||
register_subalias("P", m_P);
|
register_subalias("P", m_P);
|
||||||
register_subalias("N", m_N);
|
register_subalias("N", m_N);
|
||||||
|
@ -137,7 +137,7 @@ namespace netlist
|
|||||||
{
|
{
|
||||||
m_vals[i] = (*m_I[i])();
|
m_vals[i] = (*m_I[i])();
|
||||||
}
|
}
|
||||||
m_Q.push(m_precompiled.evaluate(m_vals));
|
m_Q.push(m_compiled.evaluate(m_vals));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,6 +306,7 @@ namespace netlist
|
|||||||
, m_N(*this, "N", 1)
|
, m_N(*this, "N", 1)
|
||||||
, m_func(*this, "FUNC", "A0")
|
, m_func(*this, "FUNC", "A0")
|
||||||
, m_Q(*this, "Q")
|
, m_Q(*this, "Q")
|
||||||
|
, m_compiled(this->name() + ".FUNCC", this, this->netlist().state())
|
||||||
{
|
{
|
||||||
std::vector<pstring> inps;
|
std::vector<pstring> inps;
|
||||||
for (int i=0; i < m_N(); i++)
|
for (int i=0; i < m_N(); i++)
|
||||||
@ -315,7 +316,7 @@ namespace netlist
|
|||||||
inps.push_back(n);
|
inps.push_back(n);
|
||||||
m_vals.push_back(0.0);
|
m_vals.push_back(0.0);
|
||||||
}
|
}
|
||||||
m_precompiled.compile(inps, m_func());
|
m_compiled.compile(inps, m_func());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -331,7 +332,7 @@ namespace netlist
|
|||||||
std::vector<std::unique_ptr<analog_input_t>> m_I;
|
std::vector<std::unique_ptr<analog_input_t>> m_I;
|
||||||
|
|
||||||
std::vector<double> m_vals;
|
std::vector<double> m_vals;
|
||||||
plib::pfunction m_precompiled;
|
plib::pfunction m_compiled;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -37,7 +37,6 @@ void pfunction::compile_postfix(const std::vector<pstring> &inputs,
|
|||||||
|
|
||||||
for (const pstring &cmd : cmds)
|
for (const pstring &cmd : cmds)
|
||||||
{
|
{
|
||||||
printf("%s %d\n", cmd.c_str(), stk);
|
|
||||||
rpn_inst rc;
|
rpn_inst rc;
|
||||||
if (cmd == "+")
|
if (cmd == "+")
|
||||||
{ rc.m_cmd = ADD; stk -= 1; }
|
{ rc.m_cmd = ADD; stk -= 1; }
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#define PFUNCTION_H_
|
#define PFUNCTION_H_
|
||||||
|
|
||||||
#include "pstring.h"
|
#include "pstring.h"
|
||||||
|
#include "pstate.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -43,6 +44,22 @@ namespace plib {
|
|||||||
double m_param;
|
double m_param;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
|
/*! 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)
|
||||||
|
{
|
||||||
|
state_manager.save_item(owner, m_lfsr, name + ".lfsr");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Constructor without state saving support
|
||||||
|
*
|
||||||
|
*/
|
||||||
pfunction()
|
pfunction()
|
||||||
: m_lfsr(0xACE1u)
|
: m_lfsr(0xACE1u)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user