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]
This commit is contained in:
couriersud 2015-05-13 02:50:05 +02:00
parent bbb49e299e
commit 62521a0c32
9 changed files with 70 additions and 20 deletions

View File

@ -398,7 +398,7 @@ NETLIB_UPDATE(solver)
/* step circuit */ /* step circuit */
if (!m_Q_step.net().is_queued()) 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));
} }
} }

View File

@ -101,9 +101,10 @@ void nl_initialize_factory(netlist_factory_t &factory)
ENTRY(clock, CLOCK, "FREQ") ENTRY(clock, CLOCK, "FREQ")
ENTRY(extclock, EXTCLOCK, "FREQ") ENTRY(extclock, EXTCLOCK, "FREQ")
ENTRY(mainclock, MAINCLOCK, "FREQ") ENTRY(mainclock, MAINCLOCK, "FREQ")
ENTRY(gnd, GND, "-")
ENTRY(netlistparams, PARAMETER, "-")
ENTRY(solver, SOLVER, "FREQ") ENTRY(solver, SOLVER, "FREQ")
ENTRY(res_sw, RES_SWITCH, "+IN,P1,P2") ENTRY(res_sw, RES_SWITCH, "+IN,P1,P2")
ENTRY(gnd, GND, "-")
ENTRY(switch1, SWITCH, "-") ENTRY(switch1, SWITCH, "-")
ENTRY(switch2, SWITCH2, "-") ENTRY(switch2, SWITCH2, "-")
ENTRY(nicRSFF, NETDEV_RSFF, "+S,R") ENTRY(nicRSFF, NETDEV_RSFF, "+S,R")

View File

@ -55,23 +55,29 @@ NETLIB_UPDATE(74193)
int tBorrow = 1; int tBorrow = 1;
if (INPLOGIC(m_CLEAR)) if (INPLOGIC(m_CLEAR))
{ {
printf("%s CLEAR\n", name().cstr());
m_cnt = 0; m_cnt = 0;
} }
else if (!INPLOGIC(m_LOADQ)) else if (!INPLOGIC(m_LOADQ))
{ {
printf("%s LoadQ\n", name().cstr());
m_cnt = (INPLOGIC(m_D) << 3) | (INPLOGIC(m_C) << 2) m_cnt = (INPLOGIC(m_D) << 3) | (INPLOGIC(m_C) << 2)
| (INPLOGIC(m_B) << 1) | (INPLOGIC(m_A) << 0); | (INPLOGIC(m_B) << 1) | (INPLOGIC(m_A) << 0);
} }
else else
{ {
printf("%s Other\n", name().cstr());
if (INPLOGIC(m_CD) && !m_last_CU && INPLOGIC(m_CU)) if (INPLOGIC(m_CD) && !m_last_CU && INPLOGIC(m_CU))
{ {
printf("%s count up\n", name().cstr());
m_cnt++; m_cnt++;
if (m_cnt > MAXCNT) if (m_cnt > MAXCNT)
m_cnt = 0; m_cnt = 0;
} }
if (INPLOGIC(m_CU) && !m_last_CD && INPLOGIC(m_CD)) if (INPLOGIC(m_CU) && !m_last_CD && INPLOGIC(m_CD))
{ {
printf("%s count down\n", name().cstr());
if (m_cnt > 0) if (m_cnt > 0)
m_cnt--; m_cnt--;
else else
@ -88,6 +94,7 @@ NETLIB_UPDATE(74193)
m_last_CD = INPLOGIC(m_CD); m_last_CD = INPLOGIC(m_CD);
m_last_CU = INPLOGIC(m_CU); 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++) for (int i=0; i<4; i++)
OUTLOGIC(m_Q[i], (m_cnt >> i) & 1, delay[i]); OUTLOGIC(m_Q[i], (m_cnt >> i) & 1, delay[i]);

View File

@ -8,6 +8,28 @@
#include "nld_system.h" #include "nld_system.h"
#include "../analog/nld_solver.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 // clock
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------

View File

@ -55,6 +55,18 @@
NET_C(_P1, _name.1) \ NET_C(_P1, _name.1) \
NET_C(_P2, _name.2) \ 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 // mainclock

View File

@ -162,9 +162,9 @@ netlist_base_t::netlist_base_t()
: netlist_object_t(NETLIST, GENERIC), : netlist_object_t(NETLIST, GENERIC),
m_stop(netlist_time::zero), m_stop(netlist_time::zero),
// FIXME:: Use a parameter to set this on a schematics per schematics basis // 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_time(netlist_time::zero),
m_queue(*this), m_queue(*this),
m_use_deactivate(0),
m_mainclock(NULL), m_mainclock(NULL),
m_solver(NULL), m_solver(NULL),
m_gnd(NULL), m_gnd(NULL),
@ -210,17 +210,25 @@ ATTR_COLD void netlist_base_t::start()
m_mainclock = get_single_device<NETLIB_NAME(mainclock)>("mainclock"); m_mainclock = get_single_device<NETLIB_NAME(mainclock)>("mainclock");
m_solver = get_single_device<NETLIB_NAME(solver)>("solver"); m_solver = get_single_device<NETLIB_NAME(solver)>("solver");
m_gnd = get_single_device<NETLIB_NAME(gnd)>("gnd"); m_gnd = get_single_device<NETLIB_NAME(gnd)>("gnd");
m_params = get_single_device<NETLIB_NAME(netlistparams)>("parameter");
/* make sure the solver is started first! */ /* make sure the solver and parameters are started first! */
if (m_solver != NULL) if (m_solver != NULL)
m_solver->start_dev(); 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")); NL_VERBOSE_OUT(("Initializing devices ...\n"));
for (netlist_device_t * const * entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) for (netlist_device_t * const * entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
{ {
netlist_device_t *dev = *entry; netlist_device_t *dev = *entry;
if (dev != m_solver) if (dev != m_solver && dev != m_params)
dev->start_dev(); dev->start_dev();
} }

View File

@ -268,6 +268,7 @@ class netlist_matrix_solver_t;
class NETLIB_NAME(gnd); class NETLIB_NAME(gnd);
class NETLIB_NAME(solver); class NETLIB_NAME(solver);
class NETLIB_NAME(mainclock); class NETLIB_NAME(mainclock);
class NETLIB_NAME(netlistparams);
class NETLIB_NAME(base_d_to_a_proxy); 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 bool isRailNet() const { return !(m_railterminal == NULL); }
ATTR_HOT inline const netlist_core_terminal_t & RESTRICT railterminal() const { return *m_railterminal; } 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 inline void reschedule_in_queue(const netlist_time &delay);
ATTR_HOT bool inline is_queued() const { return m_in_queue == 1; } ATTR_HOT bool inline is_queued() const { return m_in_queue == 1; }
@ -692,7 +693,8 @@ public:
{ {
if (newQ != m_new_Q) if (newQ != m_new_Q)
{ {
push_to_queue(newQ, delay); m_new_Q = newQ;
push_to_queue(delay);
} }
} }
@ -1214,15 +1216,17 @@ protected:
private: private:
netlist_time m_stop; // target time for current queue processing netlist_time m_stop; // target time for current queue processing
bool m_use_deactivate;
netlist_time m_time; netlist_time m_time;
netlist_queue_t m_queue; netlist_queue_t m_queue;
bool m_use_deactivate;
NETLIB_NAME(mainclock) * m_mainclock; NETLIB_NAME(mainclock) * m_mainclock;
NETLIB_NAME(solver) * m_solver; NETLIB_NAME(solver) * m_solver;
NETLIB_NAME(gnd) * m_gnd; NETLIB_NAME(gnd) * m_gnd;
NETLIB_NAME(netlistparams) *m_params;
netlist_setup_t *m_setup; 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)) if (!is_queued() && (num_cons() > 0))
{ {
m_new_Q = newval;
m_time = netlist().time() + delay; m_time = netlist().time() + delay;
m_in_queue = (m_active > 0); /* queued ? */ m_in_queue = (m_active > 0); /* queued ? */
if (m_in_queue) 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); 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) 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) if (newQ != net().as_analog().m_cur_Analog)
{ {
net().as_analog().m_cur_Analog = newQ; net().as_analog().m_cur_Analog = newQ;
net().push_to_queue(0, NLTIME_FROM_NS(1)); net().push_to_queue(NLTIME_FROM_NS(1));
} }
} }

View File

@ -40,7 +40,9 @@
* *
*/ */
#define USE_DEACTIVE_DEVICE (0)
// moved to parameter NETLIST.USE_DEACTIVATE
// #define USE_DEACTIVE_DEVICE (0)
#define USE_TRUTHTABLE (0) #define USE_TRUTHTABLE (0)
@ -64,9 +66,9 @@
// Solver defines // Solver defines
//============================================================ //============================================================
#define USE_MATRIX_GS (0) #define USE_MATRIX_GS (1)
#define USE_PIVOT_SEARCH (0) #define USE_PIVOT_SEARCH (0)
#define USE_GABS (0) #define USE_GABS (1)
// savings are eaten up by effort // savings are eaten up by effort
// FIXME: Convert into solver parameter // FIXME: Convert into solver parameter
#define USE_LINEAR_PREDICTION (0) #define USE_LINEAR_PREDICTION (0)

View File

@ -22,6 +22,7 @@ static NETLIST_START(base)
TTL_INPUT(ttlhigh, 1) TTL_INPUT(ttlhigh, 1)
TTL_INPUT(ttllow, 0) TTL_INPUT(ttllow, 0)
NET_REGISTER_DEV(gnd, GND) NET_REGISTER_DEV(gnd, GND)
NET_REGISTER_DEV(netlistparams, NETLIST)
INCLUDE(diode_models); INCLUDE(diode_models);
INCLUDE(bjt_models); INCLUDE(bjt_models);