Minor netlist updates with focus on performance. Also added 16bit int to pstate.

This commit is contained in:
Couriersud 2014-02-23 14:08:10 +00:00
parent 355c0c472a
commit e65dd38acf
8 changed files with 133 additions and 54 deletions

View File

@ -440,6 +440,9 @@ ATTR_COLD void netlist_mame_device_t::save_state()
case DT_INT64:
save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count);
break;
case DT_INT16:
save_pointer((INT16 *) s->m_ptr, s->m_name, s->m_count);
break;
case DT_INT8:
save_pointer((INT8 *) s->m_ptr, s->m_name, s->m_count);
break;

View File

@ -123,29 +123,26 @@ public:
}
#endif
virtual void update()
{
static const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) };
int pos = -1;
virtual void update()
{
static const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) };
for (int i = 0; i< _numdev; i++)
{
this->m_i[i].activate();
if (INPLOGIC(this->m_i[i]) == _check)
{
OUTLOGIC(this->m_Q, _check ^ (1 ^ _invert), times[_check]);// ? 15000 : 22000);
pos = i;
break;
}
}
if (pos >= 0)
{
for (int i = 0; i < _numdev; i++)
if (i != pos)
this->m_i[i].inactivate();
} else
OUTLOGIC(this->m_Q,_check ^ (_invert), times[1-_check]);// ? 22000 : 15000);
}
for (int i = 0; i< _numdev; i++)
{
this->m_i[i].activate();
if (INPLOGIC(this->m_i[i]) == _check)
{
for (int j = 0; j < i; j++)
this->m_i[j].inactivate();
for (int j = i + 1; j < _numdev; j++)
this->m_i[j].inactivate();
OUTLOGIC(this->m_Q, _check ^ (1 ^ _invert), times[_check]);// ? 15000 : 22000);
return;
}
}
OUTLOGIC(this->m_Q,_check ^ (_invert), times[1-_check]);// ? 22000 : 15000);
}
public:
netlist_ttl_input_t m_i[_numdev];
@ -178,7 +175,7 @@ public:
}
#if (USE_DEACTIVE_DEVICE)
ATTR_HOT void inc_active()
ATTR_HOT virtual void inc_active()
{
if (++m_active == 1)
{
@ -186,7 +183,7 @@ public:
}
}
ATTR_HOT void dec_active()
ATTR_HOT virtual void dec_active()
{
if (--m_active == 0)
{
@ -196,14 +193,14 @@ public:
}
#endif
ATTR_HOT ATTR_ALIGN void update()
{
static const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) };
static const netlist_time times[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22)};
int res = _invert ^ 1 ^_check;
m_i[0].activate();
m_i[1].activate();
#if 0
UINT8 res = _invert ^ 1 ^_check;
if (INPLOGIC(m_i[0]) ^ _check)
{
if (INPLOGIC(m_i[1]) ^ _check)
@ -216,7 +213,24 @@ public:
if (INPLOGIC(m_i[1]) ^ _check)
m_i[1].inactivate();
}
OUTLOGIC(m_Q, res, times[(res & 1) ^ 1]);// ? 22000 : 15000);
OUTLOGIC(m_Q, res, times[res & 1]);// ? 22000 : 15000);
#else
UINT8 val = (INPLOGIC(m_i[0]) ^ _check) | ((INPLOGIC(m_i[1]) ^ _check) << 1);
UINT8 res = _invert ^ 1 ^_check;
switch (val)
{
case 1:
m_i[0].inactivate();
break;
case 2:
m_i[1].inactivate();
break;
case 3:
res = _invert ^ _check;
break;
}
OUTLOGIC(m_Q, res, times[res]);// ? 22000 : 15000);
#endif
}
public:

View File

@ -47,7 +47,11 @@ public:
netlist_param_double_t m_freq;
netlist_time m_inc;
ATTR_HOT inline static void mc_update(netlist_net_t &net, const netlist_time curtime);
#if 0
ATTR_HOT inline static void mc_update(netlist_net_t &net, const netlist_time curtime);
#else
ATTR_HOT inline static void mc_update(netlist_net_t &net);
#endif
);
// ----------------------------------------------------------------------------------------

View File

@ -239,6 +239,7 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(const netlist_time delta)
m_time = m_stop;
} else {
#if 0
netlist_net_t &mcQ = m_mainclock->m_Q.net();
const netlist_time inc = m_mainclock->m_inc;
@ -266,6 +267,43 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(const netlist_time delta)
add_to_stat(m_perf_out_processed, 1);
}
#else
netlist_net_t &mcQ = m_mainclock->m_Q.net();
const netlist_time inc = m_mainclock->m_inc;
netlist_time mc_time = mcQ.time();
netlist_time cur_time = m_time;
while (cur_time < m_stop)
{
if (m_queue.is_not_empty())
{
while (m_queue.peek().time() > mc_time)
{
cur_time = mc_time;
mc_time += inc;
m_time = cur_time;
NETLIB_NAME(mainclock)::mc_update(mcQ);
}
const netlist_queue_t::entry_t &e = m_queue.pop();
cur_time = e.time();
m_time = cur_time;
e.object()->update_devs();
} else {
cur_time = mc_time;
mc_time += inc;
m_time = cur_time;
NETLIB_NAME(mainclock)::mc_update(mcQ);
}
if (FATAL_ERROR_AFTER_NS)
if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
error("Stopped");
add_to_stat(m_perf_out_processed, 1);
}
mcQ.set_time(mc_time);
m_time = cur_time;
#endif
}
}
@ -533,7 +571,7 @@ ATTR_COLD void netlist_net_t::register_con(netlist_core_terminal_t &terminal)
m_active++;
}
ATTR_HOT inline void netlist_net_t::update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const
ATTR_HOT inline static void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask)
{
if ((inp->state() & mask) != 0)
{
@ -548,7 +586,6 @@ ATTR_HOT inline void netlist_net_t::update_dev(const netlist_core_terminal_t *in
ATTR_HOT inline void netlist_net_t::update_devs()
{
assert(m_num_cons != 0);
assert(this->isRailNet());
static const UINT32 masks[4] = { 1, 5, 3, 1 };
@ -559,6 +596,7 @@ ATTR_HOT inline void netlist_net_t::update_devs()
netlist_core_terminal_t *p = m_head;
#if 1
switch (m_num_cons)
{
case 2:
@ -574,8 +612,15 @@ ATTR_HOT inline void netlist_net_t::update_devs()
p = p->m_update_list_next;
} while (p != NULL);
break;
}
#else
while (p != NULL)
{
update_dev(p, mask);
p = p->m_update_list_next;
}
#endif
}
m_last = m_cur;
}
@ -780,12 +825,20 @@ ATTR_COLD double netlist_param_model_t::model_value(const pstring &entity, const
// mainclock
// ----------------------------------------------------------------------------------------
#if 0
ATTR_HOT inline void NETLIB_NAME(mainclock)::mc_update(netlist_net_t &net, const netlist_time curtime)
{
net.m_new.Q ^= 1;
net.set_time(curtime);
net.update_devs();
}
#else
ATTR_HOT inline void NETLIB_NAME(mainclock)::mc_update(netlist_net_t &net)
{
net.m_new.Q ^= 1;
net.update_devs();
}
#endif
NETLIB_START(mainclock)
{

View File

@ -586,8 +586,6 @@ public:
ATTR_HOT inline void inc_active();
ATTR_HOT inline void dec_active();
ATTR_HOT inline const int active_count() const { return m_active; }
ATTR_HOT inline const netlist_sig_t Q() const
{
assert(family() == LOGIC);
@ -647,7 +645,7 @@ public:
protected: //FIXME: needed by current solver code
UINT32 m_num_cons;
UINT16 m_num_cons;
public:
hybrid_t m_last;
@ -673,11 +671,9 @@ protected:
private:
ATTR_HOT void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const;
netlist_time m_time;
INT32 m_active;
UINT32 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */
UINT8 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */
netlist_core_terminal_t * RESTRICT m_railterminal;
};
@ -693,6 +689,7 @@ class netlist_output_t : public netlist_core_terminal_t
public:
ATTR_COLD netlist_output_t(const type_t atype, const family_t afamily);
ATTR_COLD virtual ~netlist_output_t() {}
ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname);
ATTR_COLD virtual void reset()
@ -1223,13 +1220,12 @@ ATTR_HOT inline void netlist_input_t::activate_lh()
ATTR_HOT inline void netlist_net_t::push_to_queue(const netlist_time delay)
{
if (is_queued())
if (is_queued() || m_num_cons == 0)
return;
m_time = netlist().time() + delay;
m_in_queue = (m_active > 0) ? 1 : 0; /* queued ? */
m_in_queue = (m_active > 0); /* queued ? */
if (m_in_queue)
{
//m_in_queue = 1; /* pending */
netlist().push_to_queue(this, m_time);
}
}
@ -1238,11 +1234,14 @@ ATTR_HOT inline void netlist_net_t::inc_active()
{
m_active++;
if (USE_DEACTIVE_DEVICE && m_active == 1 && m_in_queue > 0)
if (USE_DEACTIVE_DEVICE)
{
m_last = m_cur;
railterminal().netdev().inc_active();
m_cur = m_new;
if (m_active == 1 && m_in_queue > 0)
{
m_last = m_cur;
railterminal().netdev().inc_active();
m_cur = m_new;
}
}
if (m_active == 1 && m_in_queue == 0)
@ -1263,9 +1262,11 @@ ATTR_HOT inline void netlist_net_t::inc_active()
ATTR_HOT inline void netlist_net_t::dec_active()
{
m_active--;
if (USE_DEACTIVE_DEVICE && (m_active == 0))
railterminal().netdev().dec_active();
if (USE_DEACTIVE_DEVICE)
{
if (m_active == 0)
railterminal().netdev().dec_active();
}
}
ATTR_HOT inline const netlist_sig_t netlist_logic_input_t::Q() const

View File

@ -146,7 +146,6 @@ private:
int m_count;
_ListClass * m_list;
int m_num_elements;
//_ListClass m_list[_NumElements];
};
// ----------------------------------------------------------------------------------------
@ -164,9 +163,9 @@ public:
public:
ATTR_HOT inline entry_t()
: m_time(), m_object() {}
ATTR_HOT inline entry_t(const _Time atime, _Element elem) : m_time(atime), m_object(elem) {}
ATTR_HOT inline _Time time() const { return m_time; }
ATTR_HOT inline _Element object() const { return m_object; }
ATTR_HOT inline entry_t(const _Time atime, const _Element elem) : m_time(atime), m_object(elem) {}
ATTR_HOT inline const _Time time() const { return m_time; }
ATTR_HOT inline const _Element object() const { return m_object; }
private:
_Time m_time;
@ -183,7 +182,7 @@ public:
ATTR_HOT inline bool is_empty() const { return (m_end == &m_list[0]); }
ATTR_HOT inline bool is_not_empty() const { return (m_end > &m_list[0]); }
ATTR_HOT ATTR_ALIGN void push(const entry_t &e)
ATTR_HOT ATTR_ALIGN inline void push(const entry_t &e)
{
entry_t * RESTRICT i = m_end++;
while ((i > &m_list[0]) && (e.time() > (i - 1)->time()) )
@ -197,7 +196,7 @@ public:
assert(m_end - m_list < _Size);
}
ATTR_HOT inline entry_t pop()
ATTR_HOT inline const entry_t &pop()
{
return *--m_end;
}

View File

@ -17,8 +17,10 @@ ATTR_COLD void pstate_manager_t::save_state_ptr(const pstring &stname, const pst
pstring fullname = stname;
ATTR_UNUSED pstring ts[] = {
"NOT_SUPPORTED",
"DT_CUSTOM",
"DT_DOUBLE",
"DT_INT64",
"DT_INT16",
"DT_INT8",
"DT_INT",
"DT_BOOLEAN"

View File

@ -29,6 +29,7 @@ enum pstate_data_type_e {
DT_CUSTOM,
DT_DOUBLE,
DT_INT64,
DT_INT16,
DT_INT8,
DT_INT,
DT_BOOLEAN
@ -48,6 +49,8 @@ NETLIST_SAVE_TYPE(UINT64, DT_INT64);
NETLIST_SAVE_TYPE(bool, DT_BOOLEAN);
NETLIST_SAVE_TYPE(UINT32, DT_INT);
NETLIST_SAVE_TYPE(INT32, DT_INT);
NETLIST_SAVE_TYPE(UINT16, DT_INT16);
NETLIST_SAVE_TYPE(INT16, DT_INT16);
//NETLIST_SAVE_TYPE(netlist_time::INTERNALTYPE, DT_INT64);
class pstate_manager_t;