From b7d1e61757dff8d74582aaeb5a4cc595afdbb9ee Mon Sep 17 00:00:00 2001 From: Couriersud Date: Sun, 1 Dec 2013 19:26:34 +0000 Subject: [PATCH] Netlist: logs now write to individual log files --- .gitattributes | 2 ++ src/emu/netlist/devices/net_lib.c | 11 ---------- src/emu/netlist/devices/net_lib.h | 12 +++-------- src/emu/netlist/devices/nld_log.c | 24 ++++++++++++++++++++++ src/emu/netlist/devices/nld_log.h | 34 +++++++++++++++++++++++++++++++ src/emu/netlist/netlist.mak | 1 + 6 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 src/emu/netlist/devices/nld_log.c create mode 100644 src/emu/netlist/devices/nld_log.h diff --git a/.gitattributes b/.gitattributes index 5e8554217c1..90fd946d4a1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2140,6 +2140,8 @@ src/emu/netlist/devices/nld_7486.c svneol=native#text/plain src/emu/netlist/devices/nld_7486.h svneol=native#text/plain src/emu/netlist/devices/nld_NE555.c svneol=native#text/plain src/emu/netlist/devices/nld_NE555.h svneol=native#text/plain +src/emu/netlist/devices/nld_log.c svneol=native#text/plain +src/emu/netlist/devices/nld_log.h svneol=native#text/plain src/emu/netlist/devices/nld_signal.h svneol=native#text/plain src/emu/netlist/devices/nld_system.c svneol=native#text/plain src/emu/netlist/devices/nld_system.h svneol=native#text/plain diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index 4615820e035..6a1c9864d6e 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -68,17 +68,6 @@ NETLIB_UPDATE(analog_input) { } -NETLIB_START(log) -{ - register_input("I", m_I); -} - -NETLIB_UPDATE(log) -{ - printf("%s: %f %f\n", name().cstr(), netlist().time().as_double(), INPANALOG(m_I)); -} - - NETLIB_START(nicMultiSwitch) { static const char *sIN[8] = { "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8" }; diff --git a/src/emu/netlist/devices/net_lib.h b/src/emu/netlist/devices/net_lib.h index 00a94f37ddf..a9a9778cde7 100644 --- a/src/emu/netlist/devices/net_lib.h +++ b/src/emu/netlist/devices/net_lib.h @@ -68,6 +68,8 @@ #include "nld_NE555.h" +#include "nld_log.h" + // this is a bad hack #define USE_OLD7493 (0) @@ -87,7 +89,7 @@ NET_CONNECT(_name, i1, _i1) \ NET_CONNECT(_name, i2, _i2) #define NETDEV_DELAY_RISE(_name, _CLK, _D) \ - NET_REGISTER_DEV(delay_lh, _name) \ + NET_REGISTER_DEV(delay_lh, _name) \ NET_CONNECT(_name, CLK, _CLK) \ NET_CONNECT(_name, D, _D) #define NETDEV_RSFF(_name, _S, _R) \ @@ -95,9 +97,6 @@ NET_CONNECT(_name, S, _S) \ NET_CONNECT(_name, R, _R) -#define NETDEV_LOG(_name, _I) \ - NET_REGISTER_DEV(log, _name) \ - NET_CONNECT(_name, I, _I) // ---------------------------------------------------------------------------------------- @@ -203,11 +202,6 @@ NETLIB_DEVICE(analog_input, netlist_analog_output_t m_Q; ); -NETLIB_DEVICE(log, - netlist_analog_input_t m_I; -); - - // ---------------------------------------------------------------------------------------- // Special devices ... // ---------------------------------------------------------------------------------------- diff --git a/src/emu/netlist/devices/nld_log.c b/src/emu/netlist/devices/nld_log.c new file mode 100644 index 00000000000..d68ce1391ea --- /dev/null +++ b/src/emu/netlist/devices/nld_log.c @@ -0,0 +1,24 @@ +/* + * nld_log.c + * + */ + +#include "nld_log.h" + +NETLIB_START(log) +{ + register_input("I", m_I); + + pstring filename = "netlist_" + name() + ".log"; + m_file = fopen(filename, "w"); +} + +NETLIB_UPDATE(log) +{ + fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I)); +} + +NETLIB_NAME(log)::~NETLIB_NAME(log)() +{ + fclose(m_file); +} diff --git a/src/emu/netlist/devices/nld_log.h b/src/emu/netlist/devices/nld_log.h new file mode 100644 index 00000000000..9b18813a181 --- /dev/null +++ b/src/emu/netlist/devices/nld_log.h @@ -0,0 +1,34 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * nld_log.h + * + * Devices supporting analysis and logging + * + * nld_log: + * + * +---------+ + * | ++ | + * I | | ==> Log to file "netlist_" + name() + ".log" + * | | + * +---------+ + * + */ + +#ifndef NLD_LOG_H_ +#define NLD_LOG_H_ + +#include "../nl_base.h" + +#define NETDEV_LOG(_name, _I) \ + NET_REGISTER_DEV(log, _name) \ + NET_CONNECT(_name, I, _I) + +NETLIB_DEVICE(log, + ~NETLIB_NAME(log)(); + netlist_analog_input_t m_I; +private: + FILE *m_file; +); + +#endif /* NLD_LOG_H_ */ diff --git a/src/emu/netlist/netlist.mak b/src/emu/netlist/netlist.mak index f3f9c0e23b5..0bcce3c2472 100644 --- a/src/emu/netlist/netlist.mak +++ b/src/emu/netlist/netlist.mak @@ -29,4 +29,5 @@ NETLISTOBJS+= \ $(NETLISTOBJ)/devices/nld_7474.o \ $(NETLISTOBJ)/devices/nld_7486.o \ $(NETLISTOBJ)/devices/nld_NE555.o \ + $(NETLISTOBJ)/devices/nld_log.o \