summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2017-02-12 23:48:34 +0100
committer couriersud <couriersud@gmx.org>2017-02-13 00:54:51 +0100
commit3c60882f93e6179717ec558c4714e2387df42813 (patch)
tree31b42e38629474551aa1cf5a27c0df538021ff1e /src/lib/netlist
parent3e42594830ac3524fe67745de32429c99e86c90b (diff)
Start adding save state support to nltool.
Save states are needed for regression tests going forward. (nw)
Diffstat (limited to 'src/lib/netlist')
-rw-r--r--src/lib/netlist/prg/nltool.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index 446f9b6e2a8..c3cd8edc842 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -15,6 +15,8 @@
#include "netlist/tools/nl_convert.h"
#include "netlist/solver/nld_solver.h"
+#include <cstring>
+
class tool_app_t : public plib::app
{
public:
@@ -177,6 +179,27 @@ public:
}
}
+ void save_state()
+ {
+ state().pre_save();
+ std::size_t size = 0;
+ for (auto const & s : state().save_list())
+ size += ((s->m_dt.size * s->m_count + sizeof(unsigned) - 1) / sizeof(unsigned));
+
+ auto buf = plib::palloc_array<unsigned>(size);
+ auto p = buf;
+
+ for (auto const & s : state().save_list())
+ {
+ std::size_t sz = s->m_dt.size * s->m_count;
+ if (s->m_dt.is_float || s->m_dt.is_integral)
+ std::memcpy(p, s->m_ptr, sz );
+ else
+ log().fatal("found unsupported save element {1}\n", s->m_name);
+ p += ((sz + sizeof(unsigned) - 1) / sizeof(unsigned));
+ }
+ }
+
protected:
void vlog(const plib::plog_level &l, const pstring &ls) const override;
@@ -292,6 +315,7 @@ void tool_app_t::run()
pos++;
}
nt.process_queue(netlist::netlist_time::from_double(ttr) - nlt);
+ nt.save_state();
nt.stop();
t.stop();