summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/prg/nltool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/prg/nltool.cpp')
-rw-r--r--src/lib/netlist/prg/nltool.cpp82
1 files changed, 50 insertions, 32 deletions
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index 6fd7c03b446..af1e212439e 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -218,8 +218,24 @@ public:
for (auto & r : roms)
setup().register_source(plib::make_unique<netlist_data_folder_t>(r));
+#if 0
using a = plib::psource_str_t<plib::psource_t>;
+#if USE_EVAL
+ const pstring content =
+ "#define RES_R(res) (res) \n"
+ "#define RES_K(res) ((res) * 1e3) \n"
+ "#define RES_M(res) ((res) * 1e6) \n"
+ "#define CAP_U(cap) ((cap) * 1e-6) \n"
+ "#define CAP_N(cap) ((cap) * 1e-9) \n"
+ "#define CAP_P(cap) ((cap) * 1e-12) \n"
+ "#define IND_U(ind) ((ind) * 1e-6) \n"
+ "#define IND_N(ind) ((ind) * 1e-9) \n"
+ "#define IND_P(ind) ((ind) * 1e-12) \n";
+ setup().add_include(plib::make_unique<a>("netlist/devices/net_lib.h", content));
+#else
setup().add_include(plib::make_unique<a>("netlist/devices/net_lib.h",""));
+#endif
+#endif
for (auto & i : includes)
setup().add_include(plib::make_unique<netlist_data_folder_t>(i));
@@ -352,7 +368,7 @@ static std::vector<input_t> read_input(const netlist::setup_t &setup, const pstr
std::vector<input_t> ret;
if (fname != "")
{
- plib::putf8_reader r = plib::putf8_reader(std::ifstream(plib::filesystem::u8path(fname)));
+ plib::putf8_reader r = plib::putf8_reader(plib::make_unique<std::ifstream>(plib::filesystem::u8path(fname)));
if (r.stream().fail())
throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(fname));
r.stream().imbue(std::locale::classic());
@@ -400,28 +416,31 @@ void tool_app_t::run()
pout("startup time ==> {1:5.3f}\n", t.as_seconds<nl_fptype>() );
+ // FIXME: error handling
+ if (opt_loadstate.was_specified())
+ {
+ std::ifstream strm(plib::filesystem::u8path(opt_loadstate()));
+ if (strm.fail())
+ throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(opt_loadstate()));
+ strm.imbue(std::locale::classic());
+ plib::pbinary_reader reader(strm);
+ std::vector<char> loadstate;
+ reader.read(loadstate);
+ nt.load_state(loadstate);
+ pout("Loaded state, run will continue at {1:.6f}\n", nt.exec().time().as_double());
+ }
+
t.reset();
- netlist::netlist_time_ext nlt = nt.exec().time();
+ netlist::netlist_time_ext nlstart = nt.exec().time();
{
auto t_guard(t.guard());
- // FIXME: error handling
- if (opt_loadstate.was_specified())
- {
- std::ifstream strm(plib::filesystem::u8path(opt_loadstate()));
- if (strm.fail())
- throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(opt_loadstate()));
- strm.imbue(std::locale::classic());
- plib::pbinary_reader reader(strm);
- std::vector<char> loadstate;
- reader.read(loadstate);
- nt.load_state(loadstate);
- pout("Loaded state, run will continue at {1:.6f}\n", nt.exec().time().as_double());
- }
+ pout("runnning ...\n");
unsigned pos = 0;
+ netlist::netlist_time_ext nlt = nlstart;
while (pos < inps.size()
&& inps[pos].m_time < ttr
@@ -433,8 +452,6 @@ void tool_app_t::run()
pos++;
}
- pout("runnning ...\n");
-
if (ttr > nlt)
nt.exec().process_queue(ttr - nlt);
else
@@ -444,24 +461,25 @@ void tool_app_t::run()
ttr = nlt;
}
- if (opt_savestate.was_specified())
- {
- auto savestate = nt.save_state();
- std::ofstream strm(plib::filesystem::u8path(opt_savestate()), std::ios_base::binary);
- if (strm.fail())
- throw plib::file_open_e(opt_savestate());
- strm.imbue(std::locale::classic());
-
- plib::pbinary_writer writer(strm);
- writer.write(savestate);
- }
- nt.exec().stop();
}
+ if (opt_savestate.was_specified())
+ {
+ auto savestate = nt.save_state();
+ std::ofstream strm(plib::filesystem::u8path(opt_savestate()), std::ios_base::binary);
+ if (strm.fail())
+ throw plib::file_open_e(opt_savestate());
+ strm.imbue(std::locale::classic());
+
+ plib::pbinary_writer writer(strm);
+ writer.write(savestate);
+ }
+ nt.exec().stop();
+
auto emutime(t.as_seconds<nl_fptype>());
pout("{1:f} seconds emulation took {2:f} real time ==> {3:5.2f}%\n",
- (ttr - nlt).as_fp<nl_fptype>(), emutime,
- (ttr - nlt).as_fp<nl_fptype>() / emutime * netlist::nlconst::magic(100.0));
+ (ttr - nlstart).as_fp<nl_fptype>(), emutime,
+ (ttr - nlstart).as_fp<nl_fptype>() / emutime * netlist::nlconst::magic(100.0));
}
void tool_app_t::validate()
@@ -562,7 +580,7 @@ struct doc_ext
static doc_ext read_docsrc(const pstring &fname, const pstring &id)
{
//printf("file %s\n", fname.c_str());
- plib::putf8_reader r = plib::putf8_reader(std::ifstream(plib::filesystem::u8path(fname)));
+ plib::putf8_reader r = plib::putf8_reader(plib::make_unique<std::ifstream>(plib::filesystem::u8path(fname)));
if (r.stream().fail())
throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(fname));
r.stream().imbue(std::locale::classic());