mirror of
https://github.com/holub/mame
synced 2025-10-08 09:30:17 +03:00
No whatsnew: Moved device setup out of constructor (again).
This wasn't a good idea because some more advanced stuff like virtual function address caching doesn't work in constructors.
This commit is contained in:
parent
707cc76fd1
commit
15b51ba1c8
@ -47,7 +47,7 @@
|
||||
|
||||
#include "net_lib.h"
|
||||
|
||||
NETLIB_CONSTRUCTOR(netdev_logic_input)
|
||||
NETLIB_START(netdev_logic_input)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
}
|
||||
@ -56,7 +56,7 @@ NETLIB_UPDATE(netdev_logic_input)
|
||||
{
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(netdev_analog_input)
|
||||
NETLIB_START(netdev_analog_input)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
}
|
||||
@ -65,17 +65,17 @@ NETLIB_UPDATE(netdev_analog_input)
|
||||
{
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(netdev_log)
|
||||
NETLIB_START(netdev_log)
|
||||
{
|
||||
register_input("I", m_I);
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(netdev_log)
|
||||
{
|
||||
printf("%s: %d %d\n", name(), (UINT32) (netlist().time().as_raw() / 1000000), INPLOGIC(m_I));
|
||||
printf("%s: %d %d\n", name(), (UINT32) (netlist()->time().as_raw() / 1000000), INPLOGIC(m_I));
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(netdev_clock)
|
||||
NETLIB_START(netdev_clock)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
//register_input("FB", m_feedback);
|
||||
@ -98,7 +98,7 @@ NETLIB_UPDATE(netdev_clock)
|
||||
OUTLOGIC(m_Q, !m_Q.new_Q(), m_inc );
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nicMultiSwitch)
|
||||
NETLIB_START(nicMultiSwitch)
|
||||
{
|
||||
static const char *sIN[8] = { "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8" };
|
||||
int i;
|
||||
@ -130,7 +130,7 @@ NETLIB_UPDATE_PARAM(nicMultiSwitch)
|
||||
update();
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nicMixer8)
|
||||
NETLIB_START(nicMixer8)
|
||||
{
|
||||
static const char *sI[8] = { "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8" };
|
||||
static const char *sR[8] = { "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8" };
|
||||
@ -176,7 +176,7 @@ NETLIB_UPDATE_PARAM(nicMixer8)
|
||||
|
||||
|
||||
|
||||
NETLIB_CONSTRUCTOR(nicRSFF)
|
||||
NETLIB_START(nicRSFF)
|
||||
{
|
||||
register_input("S", m_S);
|
||||
register_input("R", m_R);
|
||||
@ -201,7 +201,7 @@ NETLIB_UPDATE(nicRSFF)
|
||||
}
|
||||
|
||||
|
||||
NETLIB_CONSTRUCTOR(nicNE555N_MSTABLE)
|
||||
NETLIB_START(nicNE555N_MSTABLE)
|
||||
{
|
||||
register_input("TRIG", m_trigger);
|
||||
register_input("CV", m_CV);
|
||||
@ -284,7 +284,7 @@ NETLIB_UPDATE(nicNE555N_MSTABLE)
|
||||
m_last = out;
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7404)
|
||||
NETLIB_START(nic7404)
|
||||
{
|
||||
register_input("I1", m_I);
|
||||
register_output("Q", m_Q);
|
||||
@ -298,7 +298,7 @@ NETLIB_UPDATE(nic7404)
|
||||
OUTLOGIC(m_Q, t, delay[t]);
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7486)
|
||||
NETLIB_START(nic7486)
|
||||
{
|
||||
register_input("I1", m_I0);
|
||||
register_input("I2", m_I1);
|
||||
@ -312,9 +312,10 @@ NETLIB_UPDATE(nic7486)
|
||||
OUTLOGIC(m_Q, t, delay[t]);
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7448)
|
||||
, sub(setup, "sub")
|
||||
NETLIB_START(nic7448)
|
||||
{
|
||||
register_sub(sub, "sub");
|
||||
|
||||
sub.m_state = 0;
|
||||
|
||||
register_input(sub, "A0", sub.m_A0);
|
||||
@ -410,7 +411,7 @@ const UINT8 nic7448_sub::tab7448[16][7] =
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }, /* 15 */
|
||||
};
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7450)
|
||||
NETLIB_START(nic7450)
|
||||
{
|
||||
register_input("I1", m_I0);
|
||||
register_input("I2", m_I1);
|
||||
@ -498,10 +499,10 @@ NETLIB_UPDATE(nic7474)
|
||||
}
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7474)
|
||||
, sub(setup, "sub")
|
||||
NETLIB_START(nic7474)
|
||||
{
|
||||
|
||||
register_sub(sub, "sub");
|
||||
register_input(sub, "CLK", sub.m_clk, net_input_t::INP_STATE_LH);
|
||||
register_input("D", m_D);
|
||||
register_input("CLRQ", m_clrQ);
|
||||
@ -514,7 +515,7 @@ NETLIB_CONSTRUCTOR(nic7474)
|
||||
sub.m_QQ.initial(0);
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7483)
|
||||
NETLIB_START(nic7483)
|
||||
{
|
||||
m_lastr = 0;
|
||||
|
||||
@ -553,7 +554,7 @@ NETLIB_UPDATE(nic7483)
|
||||
}
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7490)
|
||||
NETLIB_START(nic7490)
|
||||
{
|
||||
m_cnt = 0;
|
||||
|
||||
@ -606,12 +607,13 @@ NETLIB_FUNC_VOID(nic7490, update_outputs, (void))
|
||||
}
|
||||
#endif
|
||||
#if !USE_OLD7493
|
||||
NETLIB_CONSTRUCTOR(nic7493)
|
||||
, A(setup, "A")
|
||||
, B(setup, "B")
|
||||
, C(setup, "C")
|
||||
, D(setup, "D")
|
||||
NETLIB_START(nic7493)
|
||||
{
|
||||
register_sub(A, "A");
|
||||
register_sub(B, "B");
|
||||
register_sub(C, "C");
|
||||
register_sub(D, "D");
|
||||
|
||||
register_input(A, "CLKA", A.m_I, net_input_t::INP_STATE_HL);
|
||||
register_input(B, "CLKB", B.m_I, net_input_t::INP_STATE_HL);
|
||||
register_input("R1", m_R1);
|
||||
@ -659,7 +661,7 @@ NETLIB_UPDATE(nic7493)
|
||||
}
|
||||
#else
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic7493)
|
||||
NETLIB_START(nic7493)
|
||||
{
|
||||
m_cnt = 0;
|
||||
|
||||
@ -739,9 +741,10 @@ NETLIB_FUNC_VOID(nic7493, update_outputs, (void))
|
||||
}
|
||||
#endif
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic74107A)
|
||||
, sub(setup, "sub")
|
||||
NETLIB_START(nic74107A)
|
||||
{
|
||||
register_sub(sub, "sub");
|
||||
|
||||
register_input(sub, "CLK", sub.m_clk, net_input_t::INP_STATE_HL);
|
||||
register_input("J", m_J);
|
||||
register_input("K", m_K);
|
||||
@ -816,7 +819,7 @@ NETLIB_UPDATE(nic74107A)
|
||||
// sub.m_clk.activate_hl();
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic74153)
|
||||
NETLIB_START(nic74153)
|
||||
{
|
||||
register_input("A1", m_I[0]);
|
||||
register_input("A2", m_I[1]);
|
||||
@ -844,9 +847,10 @@ NETLIB_UPDATE(nic74153)
|
||||
}
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(nic9316)
|
||||
, sub(setup, "sub")
|
||||
NETLIB_START(nic9316)
|
||||
{
|
||||
register_sub(sub, "sub");
|
||||
|
||||
sub.m_cnt = 0;
|
||||
sub.m_loadq = 1;
|
||||
sub.m_ent = 1;
|
||||
@ -1006,7 +1010,11 @@ net_device_t *net_create_device_by_classname(const char *classname, netlist_setu
|
||||
while (p != NULL)
|
||||
{
|
||||
if (strcmp((*p)->classname(), classname) == 0)
|
||||
return (*p)->Create(setup, icname);
|
||||
{
|
||||
net_device_t *ret = (*p)->Create();
|
||||
ret->setup(setup, icname);
|
||||
return ret;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
fatalerror("Class %s required for IC %s not found!\n", classname, icname);
|
||||
@ -1019,7 +1027,11 @@ net_device_t *net_create_device_by_name(const char *name, netlist_setup_t &setup
|
||||
while (p != NULL)
|
||||
{
|
||||
if (strcmp((*p)->name(), name) == 0)
|
||||
return (*p)->Create(setup, icname);
|
||||
{
|
||||
net_device_t *ret = (*p)->Create();
|
||||
ret->setup(setup, icname);
|
||||
return ret;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
fatalerror("Class %s required for IC %s not found!\n", name, icname);
|
||||
|
@ -383,8 +383,8 @@ NETLIB_DEVICE(nic74107A,
|
||||
class nic74107 : public nic74107A
|
||||
{
|
||||
public:
|
||||
nic74107(netlist_setup_t &setup, const char *name)
|
||||
: nic74107A(setup, name) {}
|
||||
nic74107()
|
||||
: nic74107A() {}
|
||||
|
||||
};
|
||||
|
||||
|
@ -322,6 +322,40 @@ ATTR_HOT ATTR_ALIGN void netlist_timed_queue::push(const entry_t &e)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netdev_mainclock
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_HOT inline void netdev_mainclock::mc_update(net_output_t &Q, const netlist_time &curtime)
|
||||
{
|
||||
Q.m_new_Q = !Q.m_new_Q;
|
||||
Q.set_time(curtime);
|
||||
Q.update_devs();
|
||||
}
|
||||
|
||||
ATTR_COLD NETLIB_START(netdev_mainclock)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
//register_input("FB", m_feedback);
|
||||
|
||||
register_param("FREQ", m_freq, 7159000.0 * 5);
|
||||
m_inc = netlist_time::from_hz(m_freq.Value()*2);
|
||||
|
||||
}
|
||||
|
||||
ATTR_HOT NETLIB_UPDATE_PARAM(netdev_mainclock)
|
||||
{
|
||||
m_inc = netlist_time::from_hz(m_freq.Value()*2);
|
||||
}
|
||||
|
||||
ATTR_HOT NETLIB_UPDATE(netdev_mainclock)
|
||||
{
|
||||
// this is only called during setup ...
|
||||
m_Q.m_new_Q = !m_Q.m_new_Q;
|
||||
m_Q.set_time(m_netlist->time() + m_inc);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netdev_a_to_d
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -329,12 +363,20 @@ ATTR_HOT ATTR_ALIGN void netlist_timed_queue::push(const entry_t &e)
|
||||
class netdev_a_to_d_proxy : public net_device_t
|
||||
{
|
||||
public:
|
||||
netdev_a_to_d_proxy(netlist_setup_t &setup, const char *name, net_input_t &in_proxied)
|
||||
: net_device_t(setup, name)
|
||||
netdev_a_to_d_proxy(net_input_t &in_proxied)
|
||||
: net_device_t()
|
||||
{
|
||||
assert(in_proxied.object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
|
||||
m_I.m_high_thresh_V = in_proxied.m_high_thresh_V;
|
||||
m_I.m_low_thresh_V = in_proxied.m_low_thresh_V;
|
||||
}
|
||||
|
||||
analog_input_t m_I;
|
||||
ttl_output_t m_Q;
|
||||
|
||||
protected:
|
||||
void start()
|
||||
{
|
||||
m_I.init_input(this);
|
||||
|
||||
m_Q.init_terminal(this);
|
||||
@ -349,8 +391,6 @@ public:
|
||||
OUTLOGIC(m_Q, 0, NLTIME_FROM_NS(1));
|
||||
}
|
||||
|
||||
analog_input_t m_I;
|
||||
ttl_output_t m_Q;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -360,12 +400,20 @@ public:
|
||||
class netdev_d_to_a_proxy : public net_device_t
|
||||
{
|
||||
public:
|
||||
netdev_d_to_a_proxy(netlist_setup_t &setup, const char *name, net_output_t &out_proxied)
|
||||
: net_device_t(setup, name)
|
||||
netdev_d_to_a_proxy(net_output_t &out_proxied)
|
||||
: net_device_t()
|
||||
{
|
||||
assert(out_proxied.object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
|
||||
m_low_V = out_proxied.m_low_V;
|
||||
m_high_V = out_proxied.m_high_V;
|
||||
assert(out_proxied.object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
|
||||
}
|
||||
|
||||
ttl_input_t m_I;
|
||||
analog_output_t m_Q;
|
||||
|
||||
protected:
|
||||
void start()
|
||||
{
|
||||
m_I.init_input(this);
|
||||
m_Q.init_terminal(this);
|
||||
m_Q.initial(0);
|
||||
@ -376,9 +424,6 @@ public:
|
||||
OUTANALOG(m_Q, INPLOGIC(m_I) ? m_high_V : m_low_V, NLTIME_FROM_NS(1));
|
||||
}
|
||||
|
||||
ttl_input_t m_I;
|
||||
analog_output_t m_Q;
|
||||
|
||||
private:
|
||||
double m_low_V;
|
||||
double m_high_V;
|
||||
@ -388,7 +433,7 @@ private:
|
||||
// netdev_const
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
NETLIB_CONSTRUCTOR(netdev_ttl_const)
|
||||
NETLIB_START(netdev_ttl_const)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
register_param("CONST", m_const, 0.0);
|
||||
@ -403,7 +448,7 @@ NETLIB_UPDATE_PARAM(netdev_ttl_const)
|
||||
OUTLOGIC(m_Q, m_const.ValueInt(), NLTIME_IMMEDIATE);
|
||||
}
|
||||
|
||||
NETLIB_CONSTRUCTOR(netdev_analog_const)
|
||||
NETLIB_START(netdev_analog_const)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
register_param("CONST", m_const, 0.0);
|
||||
@ -496,6 +541,9 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_list(INT32 &atime)
|
||||
atime = 0;
|
||||
}
|
||||
} else {
|
||||
net_output_t &mcQ = m_mainclock->m_Q;
|
||||
const netlist_time inc = m_mainclock->m_inc;
|
||||
|
||||
while (atime > 0)
|
||||
{
|
||||
if (m_queue.is_not_empty())
|
||||
@ -504,8 +552,7 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_list(INT32 &atime)
|
||||
{
|
||||
update_time(m_mainclock->m_Q.time(), atime);
|
||||
|
||||
m_mainclock->update();
|
||||
m_mainclock->m_Q.update_devs();
|
||||
netdev_mainclock::mc_update(mcQ, time() + inc);
|
||||
|
||||
}
|
||||
const queue_t::entry_t &e = m_queue.pop();
|
||||
@ -517,8 +564,7 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_list(INT32 &atime)
|
||||
} else {
|
||||
update_time(m_mainclock->m_Q.time(), atime);
|
||||
|
||||
m_mainclock->update();
|
||||
m_mainclock->m_Q.update_devs();
|
||||
netdev_mainclock::mc_update(mcQ, time() + inc);
|
||||
}
|
||||
if (FATAL_ERROR_AFTER_NS)
|
||||
if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
|
||||
@ -721,8 +767,9 @@ void netlist_setup_t::resolve_inputs(void)
|
||||
if (out.object_type(net_output_t::SIGNAL_MASK) == net_output_t::SIGNAL_ANALOG
|
||||
&& in->object_type(net_output_t::SIGNAL_MASK) == net_output_t::SIGNAL_DIGITAL)
|
||||
{
|
||||
netdev_a_to_d_proxy *proxy = new netdev_a_to_d_proxy(*this, "abc", *in);
|
||||
netdev_a_to_d_proxy *proxy = new netdev_a_to_d_proxy(*in);
|
||||
|
||||
proxy->setup(*this, "abc");
|
||||
in->set_output(proxy->m_Q);
|
||||
proxy->m_Q.register_con(*in);
|
||||
proxy->m_I.set_output(out);
|
||||
@ -733,8 +780,9 @@ void netlist_setup_t::resolve_inputs(void)
|
||||
&& in->object_type(net_output_t::SIGNAL_MASK) == net_output_t::SIGNAL_ANALOG)
|
||||
{
|
||||
//printf("here 1\n");
|
||||
netdev_d_to_a_proxy *proxy = new netdev_d_to_a_proxy(*this, "abc", out);
|
||||
netdev_d_to_a_proxy *proxy = new netdev_d_to_a_proxy(out);
|
||||
|
||||
proxy->setup(*this, "abc");
|
||||
in->set_output(proxy->m_Q);
|
||||
proxy->m_Q.register_con(*in);
|
||||
proxy->m_I.set_output(out);
|
||||
@ -768,7 +816,7 @@ void netlist_setup_t::resolve_inputs(void)
|
||||
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
|
||||
{
|
||||
net_device_t *dev = entry->object();
|
||||
dev->update();
|
||||
dev->update_dev();
|
||||
}
|
||||
|
||||
#else
|
||||
@ -824,13 +872,36 @@ void netlist_setup_t::print_stats()
|
||||
// net_core_device_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
net_core_device_t::net_core_device_t(netlist_setup_t &setup, const char *name)
|
||||
net_core_device_t::net_core_device_t()
|
||||
: net_object_t(DEVICE)
|
||||
, m_netlist(setup.netlist())
|
||||
, m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD void net_core_device_t::setup(netlist_setup_t &setup, const char *name)
|
||||
{
|
||||
m_netlist = &setup.netlist();
|
||||
m_name = name;
|
||||
|
||||
#if USE_DELEGATES
|
||||
#if USE_PMFDELEGATES
|
||||
void (net_core_device_t::* pFunc)() = &net_core_device_t::update;
|
||||
static_update = reinterpret_cast<net_update_delegate>((this->*pFunc));
|
||||
#else
|
||||
static_update = net_update_delegate(&net_core_device_t::update, "update", this);
|
||||
// get the pointer to the member function
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ATTR_COLD void net_device_t::setup(netlist_setup_t &setup, const char *name)
|
||||
{
|
||||
net_core_device_t::setup(setup, name);
|
||||
m_setup = &setup;
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
net_core_device_t::~net_core_device_t()
|
||||
{
|
||||
}
|
||||
@ -854,9 +925,8 @@ ATTR_HOT ATTR_ALIGN const net_sig_t net_core_device_t::INPLOGIC_PASSIVE(logic_in
|
||||
return ret;
|
||||
}
|
||||
|
||||
net_device_t::net_device_t(netlist_setup_t &setup, const char *name)
|
||||
: net_core_device_t(setup, name),
|
||||
m_setup(setup),
|
||||
net_device_t::net_device_t()
|
||||
: net_core_device_t(),
|
||||
m_variable_input_count(false)
|
||||
{
|
||||
}
|
||||
@ -865,19 +935,24 @@ net_device_t::~net_device_t()
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD void net_device_t::register_sub(net_core_device_t &dev, const char *name)
|
||||
{
|
||||
dev.setup(*m_setup, name);
|
||||
}
|
||||
|
||||
void net_device_t::register_output(net_core_device_t &dev, const char *name, net_output_t &port)
|
||||
{
|
||||
m_setup.register_output(*this, dev, name, port);
|
||||
m_setup->register_output(*this, dev, name, port);
|
||||
}
|
||||
|
||||
void net_device_t::register_output(const char *name, net_output_t &port)
|
||||
{
|
||||
m_setup.register_output(*this,*this,name, port);
|
||||
m_setup->register_output(*this,*this,name, port);
|
||||
}
|
||||
|
||||
void net_device_t::register_input(net_core_device_t &dev, const char *name, net_input_t &inp, net_input_t::net_input_state type)
|
||||
{
|
||||
m_setup.register_input(*this, dev, name, inp, type);
|
||||
m_setup->register_input(*this, dev, name, inp, type);
|
||||
}
|
||||
|
||||
void net_device_t::register_input(const char *name, net_input_t &inp, net_input_t::net_input_state type)
|
||||
@ -902,7 +977,7 @@ void net_device_t::register_param(net_core_device_t &dev, const char *name, net_
|
||||
{
|
||||
param.set_netdev(dev);
|
||||
param.initial(initialVal);
|
||||
m_setup.register_param(name, ¶m);
|
||||
m_setup->register_param(name, ¶m);
|
||||
}
|
||||
|
||||
void net_device_t::register_param(const char *name, net_param_t ¶m, double initialVal)
|
||||
@ -917,7 +992,7 @@ void net_device_t::register_param(const char *name, net_param_t ¶m, double i
|
||||
ATTR_COLD void net_terminal_t::init_terminal(net_core_device_t *dev)
|
||||
{
|
||||
m_netdev = dev;
|
||||
m_netlist = &dev->netlist();
|
||||
m_netlist = dev->netlist();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -928,9 +1003,6 @@ ATTR_COLD void net_input_t::init_input(net_core_device_t *dev, net_input_state a
|
||||
{
|
||||
init_terminal(dev);
|
||||
m_state = astate;
|
||||
#if USE_DELEGATES
|
||||
h = net_update_delegate(&net_core_device_t::update, "update", dev);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -958,11 +1030,7 @@ ATTR_HOT inline void net_output_t::update_dev(const net_input_t *inp, const UINT
|
||||
ATTR_UNUSED net_core_device_t *netdev = inp->netdev();
|
||||
begin_timing(netdev->total_time);
|
||||
inc_stat(netdev->stat_count);
|
||||
#if USE_DELEGATES
|
||||
inp->h();
|
||||
#else
|
||||
netdev->update();
|
||||
#endif
|
||||
netdev->update_dev();
|
||||
end_timing(netdev()->total_time);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,14 @@
|
||||
// SETUP
|
||||
//============================================================
|
||||
|
||||
#define USE_DELEGATES (1)
|
||||
#define USE_DELEGATES (0)
|
||||
|
||||
/*
|
||||
* The next options needs -Wno-pmf-conversions to compile and gcc
|
||||
* This is intended for non-mame usage.
|
||||
*
|
||||
*/
|
||||
#define USE_PMFDELEGATES (0)
|
||||
|
||||
// Next if enabled adds 20% performance ... but is not guaranteed to be absolutely timing correct.
|
||||
#define USE_DEACTIVE_DEVICE (0)
|
||||
@ -127,9 +134,9 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
|
||||
//============================================================
|
||||
|
||||
#define NETLIB_UPDATE(_chip) ATTR_HOT ATTR_ALIGN void _chip :: update(void)
|
||||
//#define NETLIB_START(_chip) ATTR_COLD _chip :: _chip (netlist_setup_t &setup, const char *name)
|
||||
#define NETLIB_CONSTRUCTOR(_chip) ATTR_COLD _chip :: _chip (netlist_setup_t &setup, const char *name) \
|
||||
: net_device_t(setup, name)
|
||||
#define NETLIB_START(_chip) ATTR_COLD void _chip :: start(void)
|
||||
//#define NETLIB_CONSTRUCTOR(_chip) ATTR_COLD _chip :: _chip (netlist_setup_t &setup, const char *name)
|
||||
// : net_device_t(setup, name)
|
||||
|
||||
#define NETLIB_UPDATE_PARAM(_chip) ATTR_HOT ATTR_ALIGN void _chip :: update_param(void)
|
||||
#define NETLIB_FUNC_VOID(_chip, _name, _params) ATTR_HOT ATTR_ALIGN inline void _chip :: _name _params
|
||||
@ -138,17 +145,19 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
|
||||
class _name : public net_signal_t<_num_input, _check, _invert> \
|
||||
{ \
|
||||
public: \
|
||||
_name (netlist_setup_t &setup, const char *name) \
|
||||
: net_signal_t<_num_input, _check, _invert>(setup, name) { } \
|
||||
_name () \
|
||||
: net_signal_t<_num_input, _check, _invert>() { } \
|
||||
};
|
||||
|
||||
#define NETLIB_DEVICE(_name, _priv) \
|
||||
class _name : public net_device_t \
|
||||
{ \
|
||||
public: \
|
||||
_name (netlist_setup_t &setup, const char *name); \
|
||||
ATTR_HOT void update(); \
|
||||
_name () \
|
||||
: net_device_t() { } \
|
||||
protected: \
|
||||
ATTR_HOT void update(); \
|
||||
ATTR_HOT void start(); \
|
||||
_priv \
|
||||
}
|
||||
|
||||
@ -156,11 +165,11 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
|
||||
class _name : public net_core_device_t \
|
||||
{ \
|
||||
public: \
|
||||
_name (netlist_setup_t &setup, const char *name) \
|
||||
: net_core_device_t(setup, name) \
|
||||
_name () \
|
||||
: net_core_device_t() \
|
||||
{ } \
|
||||
ATTR_HOT void update(); \
|
||||
/*protected:*/ \
|
||||
ATTR_HOT void update(); \
|
||||
_priv \
|
||||
}
|
||||
|
||||
@ -168,9 +177,11 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
|
||||
class _name : public net_device_t \
|
||||
{ \
|
||||
public: \
|
||||
_name (netlist_setup_t &setup, const char *name); \
|
||||
_name () \
|
||||
: net_device_t() { } \
|
||||
ATTR_HOT void update_param(); \
|
||||
ATTR_HOT void update(); \
|
||||
ATTR_HOT void start(); \
|
||||
/* protected: */ \
|
||||
_priv \
|
||||
}
|
||||
@ -189,10 +200,15 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
|
||||
// Type definitions
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class net_core_device_t;
|
||||
|
||||
#if USE_DELEGATES
|
||||
#if USE_PMFDELEGATES
|
||||
typedef void (*net_update_delegate)(net_core_device_t *);
|
||||
#else
|
||||
typedef delegate<void ()> net_update_delegate;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef UINT8 net_sig_t;
|
||||
|
||||
@ -472,10 +488,6 @@ public:
|
||||
double m_low_thresh_V;
|
||||
double m_high_thresh_V;
|
||||
|
||||
#if USE_DELEGATES
|
||||
net_update_delegate h;
|
||||
#endif
|
||||
|
||||
private:
|
||||
net_input_state m_state;
|
||||
net_output_t * RESTRICT m_output;
|
||||
@ -541,12 +553,9 @@ public:
|
||||
ATTR_HOT inline const net_sig_t last_Q() const { return m_last_Q; }
|
||||
ATTR_HOT inline const net_sig_t new_Q() const { return m_new_Q; }
|
||||
|
||||
//ATTR_HOT inline net_sig_t *Q_ptr() { return &m_Q; }
|
||||
//ATTR_HOT inline net_sig_t *new_Q_ptr() { return &m_new_Q; }
|
||||
|
||||
ATTR_COLD void register_con(net_input_t &inp);
|
||||
|
||||
ATTR_HOT void update_devs();
|
||||
ATTR_HOT inline void update_devs();
|
||||
|
||||
ATTR_HOT inline void inc_active();
|
||||
ATTR_HOT inline void dec_active();
|
||||
@ -583,6 +592,7 @@ protected:
|
||||
double m_Q_analog;
|
||||
double m_new_Q_analog;
|
||||
|
||||
UINT32 m_num_cons;
|
||||
private:
|
||||
ATTR_HOT void update_dev(const net_input_t *inp, const UINT32 mask);
|
||||
|
||||
@ -592,7 +602,6 @@ private:
|
||||
|
||||
UINT32 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */
|
||||
|
||||
UINT32 m_num_cons;
|
||||
net_input_t *m_cons[OUTPUT_MAX_CONNECTIONS];
|
||||
};
|
||||
|
||||
@ -616,7 +625,8 @@ public:
|
||||
if (EXPECTED(newQ != m_new_Q))
|
||||
{
|
||||
m_new_Q = newQ;
|
||||
push_to_queue(delay);
|
||||
if (m_num_cons)
|
||||
push_to_queue(delay);
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,18 +675,31 @@ class net_core_device_t : public net_object_t
|
||||
{
|
||||
public:
|
||||
|
||||
net_core_device_t(netlist_setup_t &setup, const char *name);
|
||||
net_core_device_t();
|
||||
|
||||
virtual ~net_core_device_t();
|
||||
|
||||
ATTR_COLD virtual void setup(netlist_setup_t &setup, const char *name);
|
||||
|
||||
ATTR_COLD const char *name() const { return m_name; }
|
||||
|
||||
ATTR_HOT virtual void update_param() {}
|
||||
|
||||
ATTR_HOT virtual void update() { }
|
||||
|
||||
ATTR_HOT const net_sig_t INPLOGIC_PASSIVE(logic_input_t &inp);
|
||||
|
||||
ATTR_HOT inline void update_dev()
|
||||
{
|
||||
#if USE_DELEGATES
|
||||
#if USE_PMFDELEGATES
|
||||
static_update(this);
|
||||
#else
|
||||
static_update();
|
||||
#endif
|
||||
#else
|
||||
update();
|
||||
#endif
|
||||
}
|
||||
|
||||
ATTR_HOT inline const net_sig_t INPLOGIC(const logic_input_t &inp) const
|
||||
{
|
||||
assert(inp.state() != net_input_t::INP_STATE_PASSIVE);
|
||||
@ -705,7 +728,7 @@ public:
|
||||
out.set_Q(val, delay);
|
||||
}
|
||||
|
||||
ATTR_HOT inline netlist_base_t &netlist() const { return m_netlist; }
|
||||
ATTR_HOT inline netlist_base_t *netlist() const { return m_netlist; }
|
||||
|
||||
ATTR_HOT virtual void inc_active() { }
|
||||
|
||||
@ -715,15 +738,19 @@ public:
|
||||
osd_ticks_t total_time;
|
||||
INT32 stat_count;
|
||||
|
||||
#if USE_DELEGATES
|
||||
net_update_delegate static_update;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
netlist_base_t &m_netlist;
|
||||
ATTR_HOT virtual void update() { }
|
||||
ATTR_HOT virtual void start() { }
|
||||
|
||||
netlist_base_t *m_netlist;
|
||||
|
||||
private:
|
||||
|
||||
#if USE_DELEGATES
|
||||
net_update_delegate h;
|
||||
#endif
|
||||
const char *m_name;
|
||||
};
|
||||
|
||||
@ -732,16 +759,18 @@ class net_device_t : public net_core_device_t
|
||||
{
|
||||
public:
|
||||
|
||||
net_device_t(netlist_setup_t &setup, const char *name);
|
||||
net_device_t();
|
||||
|
||||
virtual ~net_device_t();
|
||||
|
||||
virtual void update() { }
|
||||
ATTR_COLD void setup(netlist_setup_t &setup, const char *name);
|
||||
|
||||
ATTR_COLD const netlist_setup_t &setup() const { return m_setup; }
|
||||
ATTR_COLD const netlist_setup_t *setup() const { return m_setup; }
|
||||
|
||||
ATTR_COLD bool variable_input_count() { return m_variable_input_count; }
|
||||
|
||||
ATTR_COLD void register_sub(net_core_device_t &dev, const char *name);
|
||||
|
||||
ATTR_COLD void register_output(const char *name, net_output_t &out);
|
||||
ATTR_COLD void register_output(net_core_device_t &dev, const char *name, net_output_t &out);
|
||||
|
||||
@ -755,10 +784,13 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void update() { }
|
||||
ATTR_HOT virtual void start() { }
|
||||
|
||||
ATTR_COLD void register_param(const char *sname, net_param_t ¶m, const double initialVal = 0.0);
|
||||
ATTR_COLD void register_param(net_core_device_t &dev, const char *sname, net_param_t ¶m, const double initialVal = 0.0);
|
||||
|
||||
netlist_setup_t &m_setup;
|
||||
netlist_setup_t *m_setup;
|
||||
bool m_variable_input_count;
|
||||
|
||||
private:
|
||||
@ -794,8 +826,10 @@ template <int _numdev>
|
||||
class net_signal_base_t : public net_device_t
|
||||
{
|
||||
public:
|
||||
net_signal_base_t(netlist_setup_t &setup, const char *name)
|
||||
: net_device_t(setup, name), m_active(1)
|
||||
net_signal_base_t()
|
||||
: net_device_t(), m_active(1) { }
|
||||
|
||||
ATTR_COLD void start()
|
||||
{
|
||||
const char *sIN[8] = { "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8" };
|
||||
|
||||
@ -839,8 +873,10 @@ template <int _numdev, UINT8 _check, UINT8 _invert>
|
||||
class net_signal_t : public net_device_t
|
||||
{
|
||||
public:
|
||||
net_signal_t(netlist_setup_t &setup, const char *name)
|
||||
: net_device_t(setup, name), m_active(1)
|
||||
net_signal_t()
|
||||
: net_device_t(), m_active(1) { }
|
||||
|
||||
ATTR_COLD void start()
|
||||
{
|
||||
const char *sIN[8] = { "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8" };
|
||||
|
||||
@ -908,39 +944,41 @@ template <UINT8 _check, UINT8 _invert>
|
||||
class xx_net_signal_t: public net_device_t
|
||||
{
|
||||
public:
|
||||
xx_net_signal_t(netlist_setup_t &setup, const char *name)
|
||||
: net_device_t(setup, name), m_active(1)
|
||||
{
|
||||
const char *sIN[2] = { "I1", "I2" };
|
||||
xx_net_signal_t()
|
||||
: net_device_t(), m_active(1) { }
|
||||
|
||||
register_output("Q", m_Q);
|
||||
for (int i=0; i < 2; i++)
|
||||
ATTR_COLD void start()
|
||||
{
|
||||
const char *sIN[2] = { "I1", "I2" };
|
||||
|
||||
register_output("Q", m_Q);
|
||||
for (int i=0; i < 2; i++)
|
||||
{
|
||||
register_input(sIN[i], m_i[i], net_input_t::INP_STATE_ACTIVE);
|
||||
}
|
||||
m_Q.initial(1);
|
||||
}
|
||||
|
||||
#if (USE_DEACTIVE_DEVICE)
|
||||
ATTR_HOT void inc_active()
|
||||
{
|
||||
if (m_active == 0)
|
||||
{
|
||||
register_input(sIN[i], m_i[i], net_input_t::INP_STATE_ACTIVE);
|
||||
update();
|
||||
}
|
||||
m_Q.initial(1);
|
||||
m_active++;
|
||||
}
|
||||
|
||||
#if (USE_DEACTIVE_DEVICE)
|
||||
ATTR_HOT void inc_active()
|
||||
ATTR_HOT void dec_active()
|
||||
{
|
||||
m_active--;
|
||||
if (m_active == 0)
|
||||
{
|
||||
if (m_active == 0)
|
||||
{
|
||||
update();
|
||||
}
|
||||
m_active++;
|
||||
m_i[0].inactivate();
|
||||
m_i[1].inactivate();
|
||||
}
|
||||
|
||||
ATTR_HOT void dec_active()
|
||||
{
|
||||
m_active--;
|
||||
if (m_active == 0)
|
||||
{
|
||||
m_i[0].inactivate();
|
||||
m_i[1].inactivate();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ATTR_HOT ATTR_ALIGN void update()
|
||||
@ -977,8 +1015,8 @@ template <UINT8 _check, UINT8 _invert>
|
||||
class net_signal_t<2, _check, _invert> : public xx_net_signal_t<_check, _invert>
|
||||
{
|
||||
public:
|
||||
net_signal_t(netlist_setup_t &setup, const char *name)
|
||||
: xx_net_signal_t<_check, _invert>(setup, name) { }
|
||||
net_signal_t()
|
||||
: xx_net_signal_t<_check, _invert>() { }
|
||||
};
|
||||
|
||||
// The following did not improve performance
|
||||
@ -1149,29 +1187,10 @@ NETLIB_DEVICE_WITH_PARAMS(netdev_mainclock,
|
||||
|
||||
net_param_t m_freq;
|
||||
netlist_time m_inc;
|
||||
|
||||
ATTR_HOT inline static void mc_update(net_output_t &Q, const netlist_time &curtime);
|
||||
);
|
||||
|
||||
inline NETLIB_CONSTRUCTOR(netdev_mainclock)
|
||||
{
|
||||
register_output("Q", m_Q);
|
||||
//register_input("FB", m_feedback);
|
||||
|
||||
register_param("FREQ", m_freq, 7159000.0 * 5);
|
||||
m_inc = netlist_time::from_hz(m_freq.Value()*2);
|
||||
|
||||
}
|
||||
|
||||
inline NETLIB_UPDATE_PARAM(netdev_mainclock)
|
||||
{
|
||||
m_inc = netlist_time::from_hz(m_freq.Value()*2);
|
||||
}
|
||||
|
||||
inline NETLIB_UPDATE(netdev_mainclock)
|
||||
{
|
||||
m_Q.m_new_Q = !m_Q.m_new_Q;
|
||||
m_Q.set_time(m_netlist.time() + m_inc);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netdev_callback
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -1179,8 +1198,10 @@ inline NETLIB_UPDATE(netdev_mainclock)
|
||||
class netdev_analog_callback : public net_device_t
|
||||
{
|
||||
public:
|
||||
netdev_analog_callback(netlist_setup_t &setup, const char *name)
|
||||
: net_device_t(setup, name)
|
||||
netdev_analog_callback()
|
||||
: net_device_t() { }
|
||||
|
||||
ATTR_COLD void start()
|
||||
{
|
||||
register_input("IN", m_in);
|
||||
}
|
||||
@ -1329,7 +1350,7 @@ ATTR_HOT inline const double analog_input_t::Q_Analog() const
|
||||
|
||||
ATTR_HOT inline const bool analog_input_t::is_highz() const
|
||||
{
|
||||
return output()->Q_Analog() == NETLIST_HIGHIMP_V;
|
||||
return (output()->Q_Analog() == NETLIST_HIGHIMP_V);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -1340,7 +1361,7 @@ class net_device_t_base_factory
|
||||
{
|
||||
public:
|
||||
virtual ~net_device_t_base_factory() {}
|
||||
virtual net_device_t *Create(netlist_setup_t &setup, const char *name) const = 0;
|
||||
virtual net_device_t *Create() const = 0;
|
||||
|
||||
const char *name() const { return m_name; }
|
||||
const char *classname() const { return m_classname; }
|
||||
@ -1354,9 +1375,9 @@ class net_device_t_factory : public net_device_t_base_factory
|
||||
{
|
||||
public:
|
||||
net_device_t_factory(const char *name, const char *classname) { m_name = name; m_classname = classname; }
|
||||
net_device_t *Create(netlist_setup_t &setup, const char *name) const
|
||||
net_device_t *Create() const
|
||||
{
|
||||
net_device_t *r = global_alloc_clear(C(setup, name));
|
||||
net_device_t *r = global_alloc_clear(C());
|
||||
//r->init(setup, name);
|
||||
return r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user