summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/netlist/nl_base.c
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2013-12-14 01:19:18 +0000
committer Couriersud <couriersud@users.noreply.github.com>2013-12-14 01:19:18 +0000
commit21a89dcf8be4c9cf55f7ce654990027d1dede112 (patch)
tree14151e5844ba64f4bd09302114d1fc245e9058ce /src/emu/netlist/nl_base.c
parentb9df6731637bed91d7ebce7854639728a9a76384 (diff)
Netlist:
- pongf now runs 4 analog NE555s and video mixing. - performance down by 20% abs on my machine (155% to 135%) - happy :-) - minor bugfixes - pong still running, pongf still (though analog) still faster :-)
Diffstat (limited to 'src/emu/netlist/nl_base.c')
-rw-r--r--src/emu/netlist/nl_base.c291
1 files changed, 146 insertions, 145 deletions
diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c
index ae535c1eac6..6db0168175e 100644
--- a/src/emu/netlist/nl_base.c
+++ b/src/emu/netlist/nl_base.c
@@ -61,11 +61,11 @@ ATTR_COLD void netlist_owned_object_t::init_object(netlist_core_device_t &dev,
// ----------------------------------------------------------------------------------------
netlist_base_t::netlist_base_t()
- : m_time_ps(netlist_time::zero),
- m_rem(0),
- m_div(NETLIST_DIV),
- m_mainclock(NULL),
- m_solver(NULL)
+ : m_time_ps(netlist_time::zero),
+ m_rem(0),
+ m_div(NETLIST_DIV),
+ m_mainclock(NULL),
+ m_solver(NULL)
{
}
@@ -76,7 +76,7 @@ netlist_base_t::~netlist_base_t()
ATTR_COLD void netlist_base_t::set_mainclock_dev(NETLIB_NAME(mainclock) *dev)
{
- m_mainclock = dev;
+ m_mainclock = dev;
}
ATTR_COLD void netlist_base_t::set_solver_dev(NETLIB_NAME(solver) *dev)
@@ -97,95 +97,95 @@ ATTR_COLD void netlist_base_t::reset()
void netlist_base_t::set_clock_freq(UINT64 clockfreq)
{
- m_div = netlist_time::from_hz(clockfreq).as_raw();
- m_rem = 0;
- assert_always(m_div == NETLIST_DIV, "netlist: illegal clock!");
- NL_VERBOSE_OUT(("Setting clock %" I64FMT "d and divisor %d\n", clockfreq, m_div));
+ m_div = netlist_time::from_hz(clockfreq).as_raw();
+ m_rem = 0;
+ assert_always(m_div == NETLIST_DIV, "netlist: illegal clock!");
+ NL_VERBOSE_OUT(("Setting clock %" I64FMT "d and divisor %d\n", clockfreq, m_div));
}
ATTR_HOT ATTR_ALIGN inline void netlist_base_t::update_time(const netlist_time t, INT32 &atime)
{
- if (NETLIST_DIV_BITS == 0)
- {
- const netlist_time delta = t - m_time_ps;
- m_time_ps = t;
- atime -= delta.as_raw();
- } else {
- const netlist_time delta = t - m_time_ps + netlist_time::from_raw(m_rem);
- m_time_ps = t;
- m_rem = delta.as_raw() & NETLIST_MASK;
- atime -= (delta.as_raw() >> NETLIST_DIV_BITS);
-
- // The folling is suitable for non-power of 2 m_divs ...
- // atime -= divu_64x32_rem(delta.as_raw(), m_div, &m_rem);
- }
+ if (NETLIST_DIV_BITS == 0)
+ {
+ const netlist_time delta = t - m_time_ps;
+ m_time_ps = t;
+ atime -= delta.as_raw();
+ } else {
+ const netlist_time delta = t - m_time_ps + netlist_time::from_raw(m_rem);
+ m_time_ps = t;
+ m_rem = delta.as_raw() & NETLIST_MASK;
+ atime -= (delta.as_raw() >> NETLIST_DIV_BITS);
+
+ // The folling is suitable for non-power of 2 m_divs ...
+ // atime -= divu_64x32_rem(delta.as_raw(), m_div, &m_rem);
+ }
}
ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(INT32 &atime)
{
- if (m_mainclock == NULL)
- {
- while ( (atime > 0) && (m_queue.is_not_empty()))
- {
- const queue_t::entry_t &e = m_queue.pop();
- update_time(e.time(), atime);
+ if (m_mainclock == NULL)
+ {
+ while ( (atime > 0) && (m_queue.is_not_empty()))
+ {
+ const queue_t::entry_t &e = m_queue.pop();
+ update_time(e.time(), atime);
- //if (FATAL_ERROR_AFTER_NS)
- // NL_VERBOSE_OUT(("%s\n", e.object().netdev()->name().cstr());
+ //if (FATAL_ERROR_AFTER_NS)
+ // NL_VERBOSE_OUT(("%s\n", e.object().netdev()->name().cstr());
- e.object().update_devs();
+ e.object().update_devs();
- add_to_stat(m_perf_out_processed, 1);
+ add_to_stat(m_perf_out_processed, 1);
- if (FATAL_ERROR_AFTER_NS)
- if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
- fatalerror("Stopped");
- }
+ if (FATAL_ERROR_AFTER_NS)
+ if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
+ fatalerror("Stopped");
+ }
- if (atime > 0)
- {
- m_time_ps += netlist_time::from_raw(atime * m_div);
- atime = 0;
- }
- } else {
- netlist_net_t &mcQ = m_mainclock->m_Q.net();
- const netlist_time inc = m_mainclock->m_inc;
+ if (atime > 0)
+ {
+ m_time_ps += netlist_time::from_raw(atime * m_div);
+ atime = 0;
+ }
+ } else {
+ netlist_net_t &mcQ = m_mainclock->m_Q.net();
+ const netlist_time inc = m_mainclock->m_inc;
- while (atime > 0)
- {
- if (m_queue.is_not_empty())
- {
- while (m_queue.peek().time() > mcQ.time())
- {
- update_time(mcQ.time(), atime);
+ while (atime > 0)
+ {
+ if (m_queue.is_not_empty())
+ {
+ while (m_queue.peek().time() > mcQ.time())
+ {
+ update_time(mcQ.time(), atime);
- NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc);
+ NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc);
- }
- const queue_t::entry_t &e = m_queue.pop();
+ }
+ const queue_t::entry_t &e = m_queue.pop();
- update_time(e.time(), atime);
+ update_time(e.time(), atime);
- e.object().update_devs();
+ e.object().update_devs();
- } else {
- update_time(mcQ.time(), atime);
+ } else {
+ update_time(mcQ.time(), atime);
- NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc);
- }
- if (FATAL_ERROR_AFTER_NS)
- if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
- fatalerror("Stopped");
+ NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc);
+ }
+ if (FATAL_ERROR_AFTER_NS)
+ if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
+ fatalerror("Stopped");
- add_to_stat(m_perf_out_processed, 1);
- }
+ add_to_stat(m_perf_out_processed, 1);
+ }
- if (atime > 0)
- {
- m_time_ps += netlist_time::from_raw(atime * m_div);
- atime = 0;
- }
- }
+ if (atime > 0)
+ {
+ m_time_ps += netlist_time::from_raw(atime * m_div);
+ atime = 0;
+ }
+ }
}
// ----------------------------------------------------------------------------------------
@@ -214,11 +214,11 @@ ATTR_COLD void netlist_core_device_t::init(netlist_setup_t &setup, const pstring
#if USE_DELEGATES
#if USE_PMFDELEGATES
- void (netlist_core_device_t::* pFunc)() = &netlist_core_device_t::update;
- static_update = reinterpret_cast<net_update_delegate>((this->*pFunc));
+ void (netlist_core_device_t::* pFunc)() = &netlist_core_device_t::update;
+ static_update = reinterpret_cast<net_update_delegate>((this->*pFunc));
#else
- static_update = net_update_delegate(&netlist_core_device_t::update, "update", this);
- // get the pointer to the member function
+ static_update = net_update_delegate(&netlist_core_device_t::update, "update", this);
+ // get the pointer to the member function
#endif
#endif
@@ -256,29 +256,29 @@ netlist_device_t::~netlist_device_t()
ATTR_HOT ATTR_ALIGN const netlist_sig_t netlist_core_device_t::INPLOGIC_PASSIVE(netlist_logic_input_t &inp)
{
- if (inp.state() == netlist_input_t::STATE_INP_PASSIVE)
- {
- inp.activate();
- const netlist_sig_t ret = inp.Q();
- inp.inactivate();
- return ret;
- }
- else
- return inp.Q();
+ if (inp.state() == netlist_input_t::STATE_INP_PASSIVE)
+ {
+ inp.activate();
+ const netlist_sig_t ret = inp.Q();
+ inp.inactivate();
+ return ret;
+ }
+ else
+ return inp.Q();
}
ATTR_COLD void netlist_device_t::init(netlist_setup_t &setup, const pstring &name)
{
- netlist_core_device_t::init(setup, name);
- m_setup = &setup;
- start();
+ netlist_core_device_t::init(setup, name);
+ m_setup = &setup;
+ start();
}
ATTR_COLD void netlist_device_t::register_sub(netlist_device_t &dev, const pstring &name)
{
- dev.init(*m_setup, this->name() + "." + name);
+ dev.init(*m_setup, this->name() + "." + name);
}
ATTR_COLD void netlist_device_t::register_subalias(const pstring &name, const netlist_core_terminal_t &term)
@@ -300,7 +300,7 @@ ATTR_COLD void netlist_device_t::register_terminal(const pstring &name, netlist_
ATTR_COLD void netlist_device_t::register_output(const pstring &name, netlist_output_t &port)
{
- m_setup->register_object(*this,*this,name, port, netlist_terminal_t::STATE_OUT);
+ m_setup->register_object(*this,*this,name, port, netlist_terminal_t::STATE_OUT);
}
ATTR_COLD void netlist_device_t::register_input(const pstring &name, netlist_input_t &inp, netlist_input_t::state_e type)
@@ -326,6 +326,7 @@ static void init_term(netlist_core_device_t &dev, netlist_core_terminal_t &term,
break;
default:
fatalerror("Unknown terminal type");
+ break;
}
}
}
@@ -340,7 +341,7 @@ ATTR_COLD void netlist_device_t::register_link_internal(netlist_core_device_t &d
ATTR_COLD void netlist_device_t::register_link_internal(netlist_input_t &in, netlist_output_t &out, const netlist_input_t::state_e aState)
{
- register_link_internal(*this, in, out, aState);
+ register_link_internal(*this, in, out, aState);
}
template <class C, class T>
@@ -425,48 +426,48 @@ ATTR_COLD void netlist_net_t::register_con(netlist_core_terminal_t &terminal)
ATTR_HOT inline void netlist_net_t::update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const
{
- if ((inp->state() & mask) != 0)
- {
- netlist_core_device_t &netdev = inp->netdev();
- begin_timing(netdev.total_time);
- inc_stat(netdev.stat_count);
- netdev.update_dev();
- end_timing(netdev().total_time);
- }
+ if ((inp->state() & mask) != 0)
+ {
+ netlist_core_device_t &netdev = inp->netdev();
+ begin_timing(netdev.total_time);
+ inc_stat(netdev.stat_count);
+ netdev.update_dev();
+ end_timing(netdev().total_time);
+ }
}
ATTR_HOT inline void netlist_net_t::update_devs()
{
- assert(m_num_cons != 0);
-
- assert(this->isRailNet());
- {
-
- const UINT32 masks[4] = { 1, 5, 3, 1 };
- m_cur = m_new;
- m_in_queue = 2; /* mark as taken ... */
-
- const UINT32 mask = masks[ (m_last.Q << 1) | m_cur.Q ];
-
- netlist_core_terminal_t *p = m_head;
- switch (m_num_cons)
- {
- case 2:
- update_dev(p, mask);
- p = p->m_update_list_next;
- case 1:
- update_dev(p, mask);
- break;
- default:
- do
- {
- update_dev(p, mask);
- p = p->m_update_list_next;
- } while (p != NULL);
- break;
- }
- m_last = m_cur;
- }
+ assert(m_num_cons != 0);
+
+ assert(this->isRailNet());
+ {
+
+ const UINT32 masks[4] = { 1, 5, 3, 1 };
+ m_cur = m_new;
+ m_in_queue = 2; /* mark as taken ... */
+
+ const UINT32 mask = masks[ (m_last.Q << 1) | m_cur.Q ];
+
+ netlist_core_terminal_t *p = m_head;
+ switch (m_num_cons)
+ {
+ case 2:
+ update_dev(p, mask);
+ p = p->m_update_list_next;
+ case 1:
+ update_dev(p, mask);
+ break;
+ default:
+ do
+ {
+ update_dev(p, mask);
+ p = p->m_update_list_next;
+ } while (p != NULL);
+ break;
+ }
+ m_last = m_cur;
+ }
}
// ----------------------------------------------------------------------------------------
@@ -493,8 +494,8 @@ ATTR_COLD netlist_terminal_t::netlist_terminal_t()
ATTR_COLD void netlist_core_terminal_t::init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate)
{
- set_state(astate);
- netlist_owned_object_t::init_object(dev, aname);
+ set_state(astate);
+ netlist_owned_object_t::init_object(dev, aname);
}
ATTR_COLD void netlist_core_terminal_t::set_net(netlist_net_t &anet)
@@ -511,9 +512,9 @@ ATTR_COLD void netlist_core_terminal_t::set_net(netlist_net_t &anet)
// ----------------------------------------------------------------------------------------
netlist_output_t::netlist_output_t(const type_t atype, const family_t afamily)
- : netlist_core_terminal_t(atype, afamily)
- , m_low_V(0.0)
- , m_high_V(0.0)
+ : netlist_core_terminal_t(atype, afamily)
+ , m_low_V(0.0)
+ , m_high_V(0.0)
, m_my_net(NET, afamily)
{
//m_net = new net_net_t(NET_DIGITAL);
@@ -592,28 +593,28 @@ ATTR_COLD double netlist_param_multi_t::dValue(const pstring &entity, const doub
ATTR_HOT inline void NETLIB_NAME(mainclock)::mc_update(netlist_net_t &net, const netlist_time curtime)
{
- net.m_new.Q = !net.m_new.Q;
- net.set_time(curtime);
- net.update_devs();
+ net.m_new.Q = !net.m_new.Q;
+ net.set_time(curtime);
+ net.update_devs();
}
NETLIB_START(mainclock)
{
- register_output("Q", m_Q);
+ register_output("Q", m_Q);
- register_param("FREQ", m_freq, 7159000.0 * 5);
- m_inc = netlist_time::from_hz(m_freq.Value()*2);
+ register_param("FREQ", m_freq, 7159000.0 * 5);
+ m_inc = netlist_time::from_hz(m_freq.Value()*2);
}
NETLIB_UPDATE_PARAM(mainclock)
{
- m_inc = netlist_time::from_hz(m_freq.Value()*2);
+ m_inc = netlist_time::from_hz(m_freq.Value()*2);
}
NETLIB_UPDATE(mainclock)
{
netlist_net_t &net = m_Q.net();
- // this is only called during setup ...
- net.m_new.Q = !net.m_new.Q;
- net.set_time(netlist().time() + m_inc);
+ // this is only called during setup ...
+ net.m_new.Q = !net.m_new.Q;
+ net.set_time(netlist().time() + m_inc);
}