summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2017-05-28 09:03:17 +0200
committer couriersud <couriersud@gmx.org>2017-05-28 09:03:29 +0200
commite9a5e08b41bd03cfb253b4daddcd5ea5014f4743 (patch)
tree887a805d9a4d8131a599751ec05b531054ef49a2 /src/lib
parent134f4b18a2f958cf14f5871bbc10200c1dc32937 (diff)
Fix state saving for pfunction lfsr. (nw)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.h2
-rw-r--r--src/lib/netlist/devices/nld_system.cpp2
-rw-r--r--src/lib/netlist/devices/nlid_system.h5
-rw-r--r--src/lib/netlist/plib/pfunction.cpp1
-rw-r--r--src/lib/netlist/plib/pfunction.h17
5 files changed, 23 insertions, 4 deletions
diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h
index 578d5b3b367..7778f5f4585 100644
--- a/src/lib/netlist/analog/nlid_twoterm.h
+++ b/src/lib/netlist/analog/nlid_twoterm.h
@@ -392,6 +392,7 @@ public:
, m_R(*this, "R", 0.1)
, m_V(*this, "V", 0.0)
, m_func(*this,"FUNC", "")
+ , m_compiled(this->name() + ".FUNCC", this, this->netlist().state())
{
register_subalias("P", m_P);
register_subalias("N", m_N);
@@ -422,6 +423,7 @@ public:
NETLIB_CONSTRUCTOR_DERIVED(CS, twoterm)
, m_I(*this, "I", 1.0)
, m_func(*this,"FUNC", "")
+ , m_compiled(this->name() + ".FUNCC", this, this->netlist().state())
{
register_subalias("P", m_P);
register_subalias("N", m_N);
diff --git a/src/lib/netlist/devices/nld_system.cpp b/src/lib/netlist/devices/nld_system.cpp
index 98793c657d2..eabc4b4fbff 100644
--- a/src/lib/netlist/devices/nld_system.cpp
+++ b/src/lib/netlist/devices/nld_system.cpp
@@ -137,7 +137,7 @@ namespace netlist
{
m_vals[i] = (*m_I[i])();
}
- m_Q.push(m_precompiled.evaluate(m_vals));
+ m_Q.push(m_compiled.evaluate(m_vals));
}
diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h
index 92fb91d627c..a5574706569 100644
--- a/src/lib/netlist/devices/nlid_system.h
+++ b/src/lib/netlist/devices/nlid_system.h
@@ -306,6 +306,7 @@ namespace netlist
, m_N(*this, "N", 1)
, m_func(*this, "FUNC", "A0")
, m_Q(*this, "Q")
+ , m_compiled(this->name() + ".FUNCC", this, this->netlist().state())
{
std::vector<pstring> inps;
for (int i=0; i < m_N(); i++)
@@ -315,7 +316,7 @@ namespace netlist
inps.push_back(n);
m_vals.push_back(0.0);
}
- m_precompiled.compile(inps, m_func());
+ m_compiled.compile(inps, m_func());
}
protected:
@@ -331,7 +332,7 @@ namespace netlist
std::vector<std::unique_ptr<analog_input_t>> m_I;
std::vector<double> m_vals;
- plib::pfunction m_precompiled;
+ plib::pfunction m_compiled;
};
// -----------------------------------------------------------------------------
diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp
index a1cfb8f3366..79f09cb4a46 100644
--- a/src/lib/netlist/plib/pfunction.cpp
+++ b/src/lib/netlist/plib/pfunction.cpp
@@ -37,7 +37,6 @@ void pfunction::compile_postfix(const std::vector<pstring> &inputs,
for (const pstring &cmd : cmds)
{
- printf("%s %d\n", cmd.c_str(), stk);
rpn_inst rc;
if (cmd == "+")
{ rc.m_cmd = ADD; stk -= 1; }
diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h
index 60d85a3358c..7d5984f9d15 100644
--- a/src/lib/netlist/plib/pfunction.h
+++ b/src/lib/netlist/plib/pfunction.h
@@ -9,6 +9,7 @@
#define PFUNCTION_H_
#include "pstring.h"
+#include "pstate.h"
#include <vector>
@@ -43,6 +44,22 @@ namespace plib {
double m_param;
};
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()
: m_lfsr(0xACE1u)
{