diff options
author | Couriersud <couriersud@users.noreply.github.com> | 2013-12-31 15:35:08 +0000 |
---|---|---|
committer | Couriersud <couriersud@users.noreply.github.com> | 2013-12-31 15:35:08 +0000 |
commit | a8a62c3212fe7b0793d580d3fcbacd190485aa30 (patch) | |
tree | b5a43fa5d88898b81d22a1a751396558add6fa77 /src/tools | |
parent | ce8e8234f0b1316c06d9871bc35e55751351f466 (diff) |
Enhanced the netlist parser and cleaned pong.c. Also added a folder nl_examples which contains standalone netlist examples. [couriersud]
The examples have a ".c" suffix. In eclipse, I get automatic syntax parsing and error notifications. The parser treats "#" preprocessor defines/includes just as comments.
All of these examples can be run through nltool:
./nltool -f nl_examples/opamp.c -t 1 -l OUT
runs the opamp example for 1 second of emulation time and logs the terminal named "OUT" to "netlist_log_OUT.log".
I'll post a simple script to the list to visualize those logs using gnuplot.
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/nltool.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/tools/nltool.c b/src/tools/nltool.c index 7c8a11e3485..45cdfe67393 100644 --- a/src/tools/nltool.c +++ b/src/tools/nltool.c @@ -16,6 +16,7 @@ #include "sha1.h" #include "netlist/nl_base.h" #include "netlist/nl_setup.h" +#include "netlist/nl_util.h" #include "options.h" /*************************************************************************** @@ -58,7 +59,8 @@ void free_file_line( void *memory, const char *file, int line ) struct options_entry oplist[] = { - { "time_to_run;ttr", "1.0", OPTION_FLOAT, "time to run the emulation (seconds)" }, + { "time_to_run;t", "1.0", OPTION_FLOAT, "time to run the emulation (seconds)" }, + { "logs;l", "", OPTION_STRING, "colon separated list of terminals to log" }, { "f", "-", OPTION_STRING, "file to process (default is stdin)" }, { "help;h", "0", OPTION_BOOLEAN, "display help" }, { NULL } @@ -91,7 +93,7 @@ const char *filetobuf(pstring fname) long fsize = ftell(f); fseek(f, 0, SEEK_SET); - char *buf = (char *) malloc(fsize); + char *buf = (char *) malloc(fsize + 1); fread(buf, fsize, 1, f); buf[fsize] = 0; fclose(f); @@ -104,7 +106,7 @@ class netlist_tool_t : public netlist_base_t public: netlist_tool_t() - : netlist_base_t(), m_setup(NULL) + : netlist_base_t(), m_logs(""), m_setup(NULL) { } @@ -120,6 +122,7 @@ public: //m_setup_func(*m_setup); m_setup->parse(buffer); + log_setup(); // start devices m_setup->start_devices(); @@ -128,6 +131,20 @@ public: this->reset(); } + void log_setup() + { + NL_VERBOSE_OUT(("Creating dynamic logs ...\n")); + nl_util::pstring_list ll = nl_util::split(m_logs, ":"); + for (int i=0; i < ll.count(); i++) + { + netlist_device_t *nc = m_setup->factory().new_device_by_classname("nld_log", *m_setup); + pstring name = "log_" + ll[i]; + m_setup->register_dev(nc, name); + m_setup->register_link(name + ".I", ll[i]); + } + } + + pstring m_logs; protected: void vfatalerror(const char *format, va_list ap) const @@ -140,6 +157,7 @@ private: netlist_setup_t *m_setup; }; + void usage(core_options &opts) { astring buffer; @@ -178,8 +196,9 @@ int main(int argc, char *argv[]) return 1; } + nt.m_logs = opts.value("l"); nt.read_netlist(filetobuf(opts.value("f"))); - double ttr = opts.float_value("ttr"); + double ttr = opts.float_value("t"); printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() ); printf("runnning ...\n"); |