From 5d4634c5589568ab9869944da8a71f0e1f6aa56f Mon Sep 17 00:00:00 2001 From: Couriersud Date: Sun, 12 Jan 2014 15:50:37 +0000 Subject: [PATCH] Made GND a device of it's own (actually a terminal container). No WN --- src/emu/netlist/devices/net_lib.c | 1 + src/emu/netlist/devices/nld_system.h | 38 ++++++++++++++++++++++++++++ src/emu/netlist/nl_base.c | 5 ++++ src/emu/netlist/nl_base.h | 17 ++++++++----- src/emu/netlist/nl_setup.c | 10 +++++++- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index 498a40ef140..9a184fc670d 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -267,6 +267,7 @@ void netlist_factory_t::initialize() ENTRY(clock, NETDEV_CLOCK, "-") // FIXME ENTRY(mainclock, NETDEV_MAINCLOCK, "-") // FIXME ENTRY(solver, NETDEV_SOLVER, "-") // FIXME + ENTRY(gnd, NETDEV_GND, "-") ENTRY(switch2, NETDEV_SWITCH2, "+i1,i2") ENTRY(nicRSFF, NETDEV_RSFF, "+S,R") ENTRY(7400, TTL_7400_NAND, "+A,B") diff --git a/src/emu/netlist/devices/nld_system.h b/src/emu/netlist/devices/nld_system.h index 943a158a4be..93675a52671 100644 --- a/src/emu/netlist/devices/nld_system.h +++ b/src/emu/netlist/devices/nld_system.h @@ -30,6 +30,9 @@ #define NETDEV_CLOCK(_name) \ NET_REGISTER_DEV(clock, _name) +#define NETDEV_GND() \ + NET_REGISTER_DEV(gnd, GND) + // ---------------------------------------------------------------------------------------- // mainclock // ---------------------------------------------------------------------------------------- @@ -73,6 +76,41 @@ NETLIB_DEVICE_WITH_PARAMS(analog_input, netlist_param_double_t m_IN; ); +// ---------------------------------------------------------------------------------------- +// nld_gnd +// ---------------------------------------------------------------------------------------- + +class nld_gnd : public netlist_device_t +{ +public: + ATTR_COLD nld_gnd() + : netlist_device_t(GND) { } + + ATTR_COLD virtual ~nld_gnd() {} + +protected: + + ATTR_COLD void start() + { + register_output("Q", m_Q); + } + + ATTR_COLD void reset() + { + m_Q.initial(0.001); // Make sure update outputs something + } + + ATTR_HOT ATTR_ALIGN void update() + { + OUTANALOG(m_Q, 0.0, NLTIME_IMMEDIATE); + } + +private: + netlist_analog_output_t m_Q; + +}; + + // ---------------------------------------------------------------------------------------- // netdev_a_to_d // ---------------------------------------------------------------------------------------- diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c index f9e3efded56..6db9674c02a 100644 --- a/src/emu/netlist/nl_base.c +++ b/src/emu/netlist/nl_base.c @@ -165,6 +165,11 @@ ATTR_COLD void netlist_base_t::set_solver_dev(NETLIB_NAME(solver) *dev) m_solver = dev; } +ATTR_COLD void netlist_base_t::set_gnd_dev(NETLIB_NAME(gnd) *dev) +{ + m_gnd = dev; +} + ATTR_COLD void netlist_base_t::reset() { m_time_ps = netlist_time::zero; diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h index 2c01b9dd2cb..a9d4139025e 100644 --- a/src/emu/netlist/nl_base.h +++ b/src/emu/netlist/nl_base.h @@ -245,9 +245,10 @@ class netlist_param_t; class netlist_setup_t; class netlist_base_t; class netlist_matrix_solver_t; +class NETLIB_NAME(gnd); class NETLIB_NAME(solver); class NETLIB_NAME(mainclock); -class nld_d_to_a_proxy; +class NETLIB_NAME(d_to_a_proxy); // ---------------------------------------------------------------------------------------- // netlist_object_t @@ -279,6 +280,7 @@ public: VCVS = 8, // Voltage controlled voltage source VCCS = 9, // Voltage controlled voltage source BJT_EB = 10, // BJT(Ebers-Moll) + GND = 11, // BJT(Ebers-Moll) }; ATTR_COLD netlist_object_t(const type_t atype, const family_t afamily); @@ -1039,8 +1041,6 @@ public: m_queue.push(netlist_queue_t::entry_t(attime, out)); } - ATTR_HOT NETLIB_NAME(solver) *solver() const { return m_solver; } - ATTR_HOT void process_queue(const netlist_time delta); ATTR_HOT inline void abort_current_queue_slice() { m_stop = netlist_time::zero; } @@ -1048,12 +1048,14 @@ public: ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev); ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev); + ATTR_COLD void set_gnd_dev(NETLIB_NAME(gnd) *dev); ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup; } - ATTR_COLD netlist_net_t *find_net(const pstring &name); + ATTR_HOT NETLIB_NAME(solver) *solver() const { return m_solver; } + ATTR_HOT NETLIB_NAME(gnd) *gnd() const { return m_gnd; } + ATTR_COLD netlist_setup_t &setup() { return *m_setup; } - ATTR_COLD netlist_setup_t &setup() { return *m_setup; } - ATTR_COLD void reset(); + ATTR_COLD netlist_net_t *find_net(const pstring &name); ATTR_COLD void error(const char *format, ...) const; @@ -1065,6 +1067,8 @@ protected: // any derived netlist must override this ... virtual void vfatalerror(const char *format, va_list ap) const = 0; + /* from netlist_object */ + ATTR_COLD virtual void reset(); ATTR_COLD virtual void save_register() { save(NAME(m_queue.callback())); @@ -1087,6 +1091,7 @@ private: NETLIB_NAME(mainclock) * m_mainclock; NETLIB_NAME(solver) * m_solver; + NETLIB_NAME(gnd) * m_gnd; netlist_setup_t *m_setup; }; diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c index ad2dd4185ca..fbeed164750 100644 --- a/src/emu/netlist/nl_setup.c +++ b/src/emu/netlist/nl_setup.c @@ -16,7 +16,7 @@ static NETLIST_START(base) NETDEV_TTL_INPUT(ttlhigh, 1) NETDEV_TTL_INPUT(ttllow, 0) - NETDEV_ANALOG_INPUT(GND, 0) + NETDEV_GND() NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") NET_MODEL(".model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") @@ -639,6 +639,7 @@ void netlist_setup_t::start_devices() /* find the main clock and solver ... */ bool has_mainclock = false; bool has_solver = false; + bool has_gnd = false; for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) { @@ -657,6 +658,13 @@ void netlist_setup_t::start_devices() m_netlist.set_solver_dev(dynamic_cast(dev)); has_solver = true; } + if (dynamic_cast(dev) != NULL) + { + if (has_gnd) + m_netlist.error("Found more than one gnd node"); + m_netlist.set_gnd_dev(dynamic_cast(dev)); + has_gnd = true; + } } NL_VERBOSE_OUT(("Initializing devices ...\n"));