From 62521a0c321943e2005b776b0605b8f8b39ba024 Mon Sep 17 00:00:00 2001 From: couriersud Date: Wed, 13 May 2015 02:50:05 +0200 Subject: [PATCH] Added netlist-level parameter NETLIST.USE_DEACTIVATE. Device deactivation optimisations can now be enabled within the netlist provided the circuit can deal with them. [Couriersud] --- src/emu/netlist/analog/nld_solver.c | 2 +- src/emu/netlist/devices/net_lib.c | 3 ++- src/emu/netlist/devices/nld_74193.c | 7 +++++++ src/emu/netlist/devices/nld_system.c | 22 ++++++++++++++++++++++ src/emu/netlist/devices/nld_system.h | 12 ++++++++++++ src/emu/netlist/nl_base.c | 14 +++++++++++--- src/emu/netlist/nl_base.h | 21 +++++++++------------ src/emu/netlist/nl_config.h | 8 +++++--- src/emu/netlist/nl_setup.c | 1 + 9 files changed, 70 insertions(+), 20 deletions(-) diff --git a/src/emu/netlist/analog/nld_solver.c b/src/emu/netlist/analog/nld_solver.c index d674a3b8338..5c3277e00f9 100644 --- a/src/emu/netlist/analog/nld_solver.c +++ b/src/emu/netlist/analog/nld_solver.c @@ -398,7 +398,7 @@ NETLIB_UPDATE(solver) /* step circuit */ if (!m_Q_step.net().is_queued()) { - m_Q_step.net().push_to_queue(0, netlist_time::from_double(m_params.m_max_timestep)); + m_Q_step.net().push_to_queue(netlist_time::from_double(m_params.m_max_timestep)); } } diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index a30b3707561..07d87556e9c 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -101,9 +101,10 @@ void nl_initialize_factory(netlist_factory_t &factory) ENTRY(clock, CLOCK, "FREQ") ENTRY(extclock, EXTCLOCK, "FREQ") ENTRY(mainclock, MAINCLOCK, "FREQ") + ENTRY(gnd, GND, "-") + ENTRY(netlistparams, PARAMETER, "-") ENTRY(solver, SOLVER, "FREQ") ENTRY(res_sw, RES_SWITCH, "+IN,P1,P2") - ENTRY(gnd, GND, "-") ENTRY(switch1, SWITCH, "-") ENTRY(switch2, SWITCH2, "-") ENTRY(nicRSFF, NETDEV_RSFF, "+S,R") diff --git a/src/emu/netlist/devices/nld_74193.c b/src/emu/netlist/devices/nld_74193.c index ccfd29b6feb..7889a8be58c 100644 --- a/src/emu/netlist/devices/nld_74193.c +++ b/src/emu/netlist/devices/nld_74193.c @@ -55,23 +55,29 @@ NETLIB_UPDATE(74193) int tBorrow = 1; if (INPLOGIC(m_CLEAR)) { + printf("%s CLEAR\n", name().cstr()); m_cnt = 0; } else if (!INPLOGIC(m_LOADQ)) { + printf("%s LoadQ\n", name().cstr()); m_cnt = (INPLOGIC(m_D) << 3) | (INPLOGIC(m_C) << 2) | (INPLOGIC(m_B) << 1) | (INPLOGIC(m_A) << 0); } else { + printf("%s Other\n", name().cstr()); + if (INPLOGIC(m_CD) && !m_last_CU && INPLOGIC(m_CU)) { + printf("%s count up\n", name().cstr()); m_cnt++; if (m_cnt > MAXCNT) m_cnt = 0; } if (INPLOGIC(m_CU) && !m_last_CD && INPLOGIC(m_CD)) { + printf("%s count down\n", name().cstr()); if (m_cnt > 0) m_cnt--; else @@ -88,6 +94,7 @@ NETLIB_UPDATE(74193) m_last_CD = INPLOGIC(m_CD); m_last_CU = INPLOGIC(m_CU); + printf("%s cnt %d B %d C %d\n", name().cstr(), m_cnt, tBorrow, tCarry); for (int i=0; i<4; i++) OUTLOGIC(m_Q[i], (m_cnt >> i) & 1, delay[i]); diff --git a/src/emu/netlist/devices/nld_system.c b/src/emu/netlist/devices/nld_system.c index 2bf995a0c7c..b87c2e1e6bf 100644 --- a/src/emu/netlist/devices/nld_system.c +++ b/src/emu/netlist/devices/nld_system.c @@ -8,6 +8,28 @@ #include "nld_system.h" #include "../analog/nld_solver.h" +// ---------------------------------------------------------------------------------------- +// netlistparams +// ---------------------------------------------------------------------------------------- + +NETLIB_START(netlistparams) +{ + register_param("USE_DEACTIVATE", m_use_deactivate, 0); +} + +NETLIB_RESET(netlistparams) +{ +} + +NETLIB_UPDATE_PARAM(netlistparams) +{ +} + +NETLIB_UPDATE(netlistparams) +{ +} + + // ---------------------------------------------------------------------------------------- // clock // ---------------------------------------------------------------------------------------- diff --git a/src/emu/netlist/devices/nld_system.h b/src/emu/netlist/devices/nld_system.h index 623cd0cd889..67164f7123a 100644 --- a/src/emu/netlist/devices/nld_system.h +++ b/src/emu/netlist/devices/nld_system.h @@ -55,6 +55,18 @@ NET_C(_P1, _name.1) \ NET_C(_P2, _name.2) \ +/* Default device to hold netlist parameters */ +#define PARAMETERS(_name) \ + NET_REGISTER_DEV(netlistparams, _name) \ + +// ----------------------------------------------------------------------------- +// mainclock +// ----------------------------------------------------------------------------- + +NETLIB_DEVICE_WITH_PARAMS(netlistparams, +public: + netlist_param_logic_t m_use_deactivate; +); // ----------------------------------------------------------------------------- // mainclock diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c index 41127178995..d80fb8adf3c 100644 --- a/src/emu/netlist/nl_base.c +++ b/src/emu/netlist/nl_base.c @@ -162,9 +162,9 @@ netlist_base_t::netlist_base_t() : netlist_object_t(NETLIST, GENERIC), m_stop(netlist_time::zero), // FIXME:: Use a parameter to set this on a schematics per schematics basis - m_use_deactivate(USE_DEACTIVE_DEVICE), m_time(netlist_time::zero), m_queue(*this), + m_use_deactivate(0), m_mainclock(NULL), m_solver(NULL), m_gnd(NULL), @@ -210,17 +210,25 @@ ATTR_COLD void netlist_base_t::start() m_mainclock = get_single_device("mainclock"); m_solver = get_single_device("solver"); m_gnd = get_single_device("gnd"); + m_params = get_single_device("parameter"); - /* make sure the solver is started first! */ + /* make sure the solver and parameters are started first! */ if (m_solver != NULL) m_solver->start_dev(); + if (m_params != NULL) + { + m_params->start_dev(); + } + + m_use_deactivate = (m_params->m_use_deactivate.Value() ? true : false); + NL_VERBOSE_OUT(("Initializing devices ...\n")); for (netlist_device_t * const * entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) { netlist_device_t *dev = *entry; - if (dev != m_solver) + if (dev != m_solver && dev != m_params) dev->start_dev(); } diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h index 8bbcc3444f0..4fddb58c22b 100644 --- a/src/emu/netlist/nl_base.h +++ b/src/emu/netlist/nl_base.h @@ -268,6 +268,7 @@ class netlist_matrix_solver_t; class NETLIB_NAME(gnd); class NETLIB_NAME(solver); class NETLIB_NAME(mainclock); +class NETLIB_NAME(netlistparams); class NETLIB_NAME(base_d_to_a_proxy); // ----------------------------------------------------------------------------- @@ -618,7 +619,7 @@ public: ATTR_HOT inline bool isRailNet() const { return !(m_railterminal == NULL); } ATTR_HOT inline const netlist_core_terminal_t & RESTRICT railterminal() const { return *m_railterminal; } - ATTR_HOT inline void push_to_queue(const netlist_sig_t newval, const netlist_time &delay); + ATTR_HOT inline void push_to_queue(const netlist_time &delay); ATTR_HOT inline void reschedule_in_queue(const netlist_time &delay); ATTR_HOT bool inline is_queued() const { return m_in_queue == 1; } @@ -692,7 +693,8 @@ public: { if (newQ != m_new_Q) { - push_to_queue(newQ, delay); + m_new_Q = newQ; + push_to_queue(delay); } } @@ -1214,15 +1216,17 @@ protected: private: netlist_time m_stop; // target time for current queue processing - bool m_use_deactivate; netlist_time m_time; netlist_queue_t m_queue; + bool m_use_deactivate; + NETLIB_NAME(mainclock) * m_mainclock; NETLIB_NAME(solver) * m_solver; NETLIB_NAME(gnd) * m_gnd; + NETLIB_NAME(netlistparams) *m_params; netlist_setup_t *m_setup; }; @@ -1318,11 +1322,10 @@ ATTR_HOT inline void netlist_logic_input_t::activate_lh() } -ATTR_HOT inline void netlist_net_t::push_to_queue(const netlist_sig_t newval, const netlist_time &delay) +ATTR_HOT inline void netlist_net_t::push_to_queue(const netlist_time &delay) { if (!is_queued() && (num_cons() > 0)) { - m_new_Q = newval; m_time = netlist().time() + delay; m_in_queue = (m_active > 0); /* queued ? */ if (m_in_queue) @@ -1330,12 +1333,6 @@ ATTR_HOT inline void netlist_net_t::push_to_queue(const netlist_sig_t newval, c netlist().push_to_queue(*this, m_time); } } - else - { - m_cur_Q = m_new_Q; - m_new_Q = newval; - } - } ATTR_HOT inline void netlist_net_t::reschedule_in_queue(const netlist_time &delay) @@ -1368,7 +1365,7 @@ ATTR_HOT inline void netlist_analog_output_t::set_Q(const nl_double newQ) if (newQ != net().as_analog().m_cur_Analog) { net().as_analog().m_cur_Analog = newQ; - net().push_to_queue(0, NLTIME_FROM_NS(1)); + net().push_to_queue(NLTIME_FROM_NS(1)); } } diff --git a/src/emu/netlist/nl_config.h b/src/emu/netlist/nl_config.h index 27cab18cdb5..387c2dcdd17 100644 --- a/src/emu/netlist/nl_config.h +++ b/src/emu/netlist/nl_config.h @@ -40,7 +40,9 @@ * */ -#define USE_DEACTIVE_DEVICE (0) + +// moved to parameter NETLIST.USE_DEACTIVATE +// #define USE_DEACTIVE_DEVICE (0) #define USE_TRUTHTABLE (0) @@ -64,9 +66,9 @@ // Solver defines //============================================================ -#define USE_MATRIX_GS (0) +#define USE_MATRIX_GS (1) #define USE_PIVOT_SEARCH (0) -#define USE_GABS (0) +#define USE_GABS (1) // savings are eaten up by effort // FIXME: Convert into solver parameter #define USE_LINEAR_PREDICTION (0) diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c index 487bbae44b6..8fe226a2159 100644 --- a/src/emu/netlist/nl_setup.c +++ b/src/emu/netlist/nl_setup.c @@ -22,6 +22,7 @@ static NETLIST_START(base) TTL_INPUT(ttlhigh, 1) TTL_INPUT(ttllow, 0) NET_REGISTER_DEV(gnd, GND) + NET_REGISTER_DEV(netlistparams, NETLIST) INCLUDE(diode_models); INCLUDE(bjt_models);