summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2013-12-16 12:55:46 +0000
committer Couriersud <couriersud@users.noreply.github.com>2013-12-16 12:55:46 +0000
commit5777263839b59276aff2aad39885475fba1d6c18 (patch)
tree05caaddb53a75f6172f84c9b255a4721d3713af4 /src
parent1ffc016289b3db44af6bcaab3d4eb80575c06036 (diff)
Netlist:
- separated mame specific code into netlist.h - Diode model now uses a fast exp function which is approx. 3x faster than build-in at the expense of reduced accuracy. We are emulating real device with tolerances, so this is not an issue.
Diffstat (limited to 'src')
-rw-r--r--src/emu/machine/netlist.c8
-rw-r--r--src/emu/machine/netlist.h92
-rw-r--r--src/emu/netlist/devices/net_lib.c3
-rw-r--r--src/emu/netlist/devices/nld_system.c11
-rw-r--r--src/emu/netlist/devices/nld_system.h32
-rw-r--r--src/emu/netlist/devices/nld_twoterm.c3
-rw-r--r--src/emu/netlist/devices/nld_twoterm.h82
-rw-r--r--src/emu/netlist/nl_base.c6
-rw-r--r--src/emu/netlist/nl_base.h19
-rw-r--r--src/emu/netlist/nl_config.h7
-rw-r--r--src/emu/netlist/nl_setup.c33
-rw-r--r--src/emu/netlist/nl_setup.h18
-rw-r--r--src/mame/drivers/pong.c50
13 files changed, 237 insertions, 127 deletions
diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c
index 55fbb9782b5..94024f86355 100644
--- a/src/emu/machine/netlist.c
+++ b/src/emu/machine/netlist.c
@@ -44,6 +44,7 @@
****************************************************************************/
+#include "emu.h"
#include "netlist.h"
#include "netlist/nl_base.h"
#include "netlist/nl_setup.h"
@@ -78,12 +79,15 @@ void netlist_mame_device::device_config_complete()
void netlist_mame_device::device_start()
{
- //double dt = clocks_to_attotime(1).as_double();
- m_netlist = global_alloc_clear(netlist_t(*this));
+ m_netlist = global_alloc_clear(netlist_mame_t(*this));
m_netlist->set_clock_freq(this->clock());
m_setup = global_alloc_clear(netlist_setup_t(*m_netlist));
+ // register additional devices
+
+ m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback");
+
m_setup_func(*m_setup);
m_setup->start_devices();
diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h
index 8730ee9bf89..3ee8526af38 100644
--- a/src/emu/machine/netlist.h
+++ b/src/emu/machine/netlist.h
@@ -54,7 +54,7 @@
#include "netlist/nl_base.h"
#include "netlist/nl_setup.h"
-// MAME specific
+// MAME specific configuration
#define MCFG_NETLIST_ADD(_tag, _setup ) \
MCFG_DEVICE_ADD(_tag, NETLIST, NETLIST_CLOCK) \
@@ -65,33 +65,51 @@
#define MCFG_NETLIST_SETUP(_setup) \
netlist_mame_device::static_set_constructor(*device, NETLIST_NAME(_setup));
+// ----------------------------------------------------------------------------------------
+// Extensions to interface netlist with MAME code ....
+// ----------------------------------------------------------------------------------------
+#define NETLIST_MEMREGION(_name) \
+ netlist.parse((char *)downcast<netlist_mame_t &>(netlist.netlist()).machine().root_device().memregion(_name)->base());
+#define NETDEV_ANALOG_CALLBACK(_name, _IN, _class, _member, _tag) \
+ { \
+ NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>(netlist.register_dev(NET_NEW(analog_callback), # _name)); \
+ netlist_analog_output_delegate d = netlist_analog_output_delegate(& _class :: _member, # _class "::" # _member, _tag, (_class *) 0); \
+ dev->register_callback(d); \
+ } \
+ NET_CONNECT(_name, IN, _IN)
+#define NETDEV_ANALOG_CALLBACK_MEMBER(_name) \
+ void _name(const double data, const attotime &time)
-// ----------------------------------------------------------------------------------------
-// MAME glue classes
-// ----------------------------------------------------------------------------------------
-
+class netlist_mame_device;
-class netlist_t : public netlist_base_t
+class netlist_mame_t : public netlist_base_t
{
public:
- netlist_t(device_t &parent)
- : netlist_base_t(),
- m_parent(parent)
- {}
- virtual ~netlist_t() { };
+ netlist_mame_t(netlist_mame_device &parent)
+ : netlist_base_t(),
+ m_parent(parent)
+ {}
+ virtual ~netlist_mame_t() { };
- inline running_machine &machine() { return m_parent.machine(); }
+ inline running_machine &machine();
- device_t &parent() { return m_parent; }
+ netlist_mame_device &parent() { return m_parent; }
private:
- device_t &m_parent;
+ netlist_mame_device &m_parent;
};
+// ----------------------------------------------------------------------------------------
+// MAME glue classes
+// ----------------------------------------------------------------------------------------
+
+
+
+
// ======================> netlist_mame_device
class netlist_mame_device : public device_t,
@@ -119,7 +137,7 @@ public:
static void static_set_constructor(device_t &device, void (*setup_func)(netlist_setup_t &));
netlist_setup_t &setup() { return *m_setup; }
- netlist_t &netlist() { return *m_netlist; }
+ netlist_mame_t &netlist() { return *m_netlist; }
typedef netlist_list_t<on_device_start *> device_start_list_t;
@@ -138,7 +156,7 @@ protected:
ATTR_HOT virtual void execute_run();
- netlist_t *m_netlist;
+ netlist_mame_t *m_netlist;
netlist_setup_t *m_setup;
@@ -153,6 +171,48 @@ private:
};
+inline running_machine &netlist_mame_t::machine()
+{
+ return m_parent.machine();
+}
+
+// ----------------------------------------------------------------------------------------
+// netdev_callback
+// ----------------------------------------------------------------------------------------
+
+typedef device_delegate<void (const double, const attotime &)> netlist_analog_output_delegate;
+
+class NETLIB_NAME(analog_callback) : public netlist_device_t
+{
+public:
+ NETLIB_NAME(analog_callback)()
+ : netlist_device_t() { }
+
+ ATTR_COLD void start()
+ {
+ register_input("IN", m_in);
+ m_callback.bind_relative_to(downcast<netlist_mame_t &>(netlist()).machine().root_device());
+ }
+
+ ATTR_COLD void register_callback(netlist_analog_output_delegate callback)
+ {
+ m_callback = callback;
+ }
+
+ ATTR_HOT void update()
+ {
+ // FIXME: Remove after device cleanup
+ if (!m_callback.isnull())
+ m_callback(INPANALOG(m_in), downcast<netlist_mame_t &>(netlist()).parent().local_time());
+ }
+
+private:
+ netlist_analog_input_t m_in;
+ netlist_analog_output_delegate m_callback;
+};
+
+
+
// ======================> netlist_output_finder
class netlist_mame_device::on_device_start
diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c
index 21fc47621c8..3082082ca43 100644
--- a/src/emu/netlist/devices/net_lib.c
+++ b/src/emu/netlist/devices/net_lib.c
@@ -335,7 +335,7 @@ NETLIB_UPDATE(nic74153)
#define xstr(s) # s
-#define ENTRY1(_nic, _name) m_list.add(new net_device_t_factory< _nic >( # _name, xstr(_nic) ));
+#define ENTRY1(_nic, _name) register_device<_nic>( # _name, xstr(_nic) );
#define ENTRY(_nic, _name) ENTRY1(NETLIB_NAME(_nic), _name)
netlist_factory::netlist_factory()
@@ -372,7 +372,6 @@ void netlist_factory::initialize()
ENTRY(clock, NETDEV_CLOCK)
ENTRY(mainclock, NETDEV_MAINCLOCK)
ENTRY(solver, NETDEV_SOLVER)
- ENTRY(analog_callback, NETDEV_CALLBACK)
ENTRY(nicMultiSwitch, NETDEV_SWITCH2)
ENTRY(nicRSFF, NETDEV_RSFF)
ENTRY(nicMixer8, NETDEV_MIXER)
diff --git a/src/emu/netlist/devices/nld_system.c b/src/emu/netlist/devices/nld_system.c
index abdc856c0af..f1ab75e9f8e 100644
--- a/src/emu/netlist/devices/nld_system.c
+++ b/src/emu/netlist/devices/nld_system.c
@@ -41,17 +41,6 @@ NETLIB_UPDATE_PARAM(analog_const)
}
// ----------------------------------------------------------------------------------------
-// analog_callback
-// ----------------------------------------------------------------------------------------
-
-NETLIB_UPDATE(analog_callback)
-{
- // FIXME: Remove after device cleanup
- if (!m_callback.isnull())
- m_callback(INPANALOG(m_in));
-}
-
-// ----------------------------------------------------------------------------------------
// clock
// ----------------------------------------------------------------------------------------
diff --git a/src/emu/netlist/devices/nld_system.h b/src/emu/netlist/devices/nld_system.h
index 4cd39720a23..0859d9cddef 100644
--- a/src/emu/netlist/devices/nld_system.h
+++ b/src/emu/netlist/devices/nld_system.h
@@ -36,10 +36,6 @@
#define NETDEV_ANALOG_INPUT(_name) \
NET_REGISTER_DEV(analog_input, _name)
-#define NETDEV_CALLBACK(_name, _IN) \
- NET_REGISTER_DEV(analog_callback, _name) \
- NET_CONNECT(_name, IN, _IN)
-
// ----------------------------------------------------------------------------------------
// netdev_*_const
// ----------------------------------------------------------------------------------------
@@ -82,34 +78,6 @@ NETLIB_DEVICE_WITH_PARAMS(clock,
// ----------------------------------------------------------------------------------------
-// netdev_callback
-// ----------------------------------------------------------------------------------------
-
-class NETLIB_NAME(analog_callback) : public netlist_device_t
-{
-public:
- NETLIB_NAME(analog_callback)()
- : netlist_device_t() { }
-
- ATTR_COLD void start()
- {
- register_input("IN", m_in);
- }
-
- ATTR_COLD void register_callback(netlist_output_delegate callback)
- {
- m_callback = callback;
- }
-
- ATTR_HOT void update();
-
-
-private:
- netlist_analog_input_t m_in;
- netlist_output_delegate m_callback;
-};
-
-// ----------------------------------------------------------------------------------------
// Special support devices ...
// ----------------------------------------------------------------------------------------
diff --git a/src/emu/netlist/devices/nld_twoterm.c b/src/emu/netlist/devices/nld_twoterm.c
index 4e6e59d00f4..5f8fe211c6f 100644
--- a/src/emu/netlist/devices/nld_twoterm.c
+++ b/src/emu/netlist/devices/nld_twoterm.c
@@ -76,6 +76,7 @@ NETLIB_START(POT)
register_param("R", m_R, 1.0 / NETLIST_GMIN);
register_param("DIAL", m_Dial, 0.5);
+
}
NETLIB_UPDATE(POT)
@@ -125,6 +126,7 @@ NETLIB_START(D)
m_Vd = 0.7;
}
+
NETLIB_UPDATE_PARAM(D)
{
m_Is = m_model.dValue("Is", 1e-15);
@@ -135,7 +137,6 @@ NETLIB_UPDATE_PARAM(D)
m_Vcrit = m_Vt * log(m_Vt / m_Is / sqrt(2.0));
m_VtInv = 1.0 / m_Vt;
NL_VERBOSE_OUT(("VCutoff: %f\n", m_Vcrit));
- printf("VCutoff: %f %f\n", m_Vcrit, m_Is);
}
NETLIB_UPDATE(D)
diff --git a/src/emu/netlist/devices/nld_twoterm.h b/src/emu/netlist/devices/nld_twoterm.h
index 1bfc72ab9d0..0c72a46884e 100644
--- a/src/emu/netlist/devices/nld_twoterm.h
+++ b/src/emu/netlist/devices/nld_twoterm.h
@@ -55,9 +55,15 @@
/* Generic Diode */
#define NETDEV_D(_name, _model) \
NET_REGISTER_DEV(D, _name) \
- NETDEV_PARAMI(_name, model, _model)
+ NETDEV_PARAMI(_name, model, # _model)
-#define NETDEV_1N914(_name) NETDEV_D(_name, "Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon")
+#define NETDEV_QPNP(_name, _model) \
+ NET_REGISTER_DEV(QPNP_switch, _name) \
+ NETDEV_PARAMI(_name, model, # _model)
+
+#define NETDEV_QNPN(_name, _model) \
+ NET_REGISTER_DEV(QNPN_switch, _name) \
+ NETDEV_PARAMI(_name, model, # _model)
// ----------------------------------------------------------------------------------------
// Implementation
@@ -154,6 +160,33 @@ protected:
// nld_D
// ----------------------------------------------------------------------------------------
+
+// this one has an accuracy of better than 5%. That's enough for our purpose
+// add c3 and it'll be better than 1%
+
+inline double fastexp_h(const double x)
+{
+ static const double ln2r = 1.442695040888963387;
+ static const double ln2 = 0.693147180559945286;
+ //static const double c3 = 0.166666666666666667;
+
+ const double y = x * ln2r;
+ const unsigned int t = y;
+ const double z = (x - ln2 * (double) t);
+ const double zz = z * z;
+ //const double zzz = zz * z;
+
+ return (double)(1 << t)*(1.0 + z + 0.5 * zz); // + c3*zzz;
+}
+
+inline double fastexp(const double x)
+{
+ if (x<0)
+ return 1.0 / fastexp_h(-x);
+ else
+ return fastexp_h(x);
+}
+
class NETLIB_NAME(D) : public NETLIB_NAME(twoterm)
{
public:
@@ -164,15 +197,36 @@ public:
const double nVd = m_P.net().Q_Analog()- m_N.net().Q_Analog();
//FIXME: Optimize cutoff case
- m_Vd = (nVd > m_Vcrit) ? m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt : nVd;
- const double eVDVt = exp(m_Vd * m_VtInv);
- const double Id = m_Is * (eVDVt - 1.0);
+ double Id;
+ double G;
+
+ if (nVd < -5.0 * m_Vt)
+ {
+ m_Vd = nVd;
+ G = NETLIST_GMIN;
+ Id = - m_Is;
+ }
+ else if (nVd < m_Vcrit)
+ {
+ m_Vd = nVd;
+
+ const double eVDVt = fastexp(m_Vd * m_VtInv);
+ Id = m_Is * (eVDVt - 1.0);
+ G = m_Is * m_VtInv * eVDVt;
+ }
+ else
+ {
+ //m_Vd = m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt;
+ m_Vd = m_Vd + log1p((nVd - m_Vd) * m_VtInv) * m_Vt;
+
+ const double eVDVt = fastexp(m_Vd * m_VtInv);
+ Id = m_Is * (eVDVt - 1.0);
- double G = m_Is * m_VtInv * eVDVt;
+ G = m_Is * m_VtInv * eVDVt;
+ }
double I = (Id - m_Vd * G);
-
set(G, 0.0, I);
}
@@ -181,7 +235,7 @@ protected:
ATTR_COLD virtual void update_param();
ATTR_HOT ATTR_ALIGN void update();
- netlist_param_multi_t m_model;
+ netlist_param_model_t m_model;
double m_Vt;
double m_Is;
@@ -206,16 +260,6 @@ protected:
* E
*/
-#define NETDEV_QPNP(_name, _model) \
- NET_REGISTER_DEV(QPNP_switch, _name) \
- NETDEV_PARAMI(_name, model, _model)
-
-#define NETDEV_QNPN(_name, _model) \
- NET_REGISTER_DEV(QNPN_switch, _name) \
- NETDEV_PARAMI(_name, model, _model)
-
-#define NETDEV_BC238B(_name) NETDEV_QNPN(_name, "IS=1.8E-14 ISE=5.0E-14 ISC=1.72E-13 XTI=3 BF=400 BR=35.5 IKF=0.14 IKR=0.03 XTB=1.5 VAF=80 VAR=12.5 VJE=0.58 VJC=0.54 RE=0.6 RC=0.25 RB=0.56 CJE=13E-12 CJC=4E-12 XCJC=0.75 FC=0.5 NF=0.9955 NR=1.005 NE=1.46 NC=1.27 MJE=0.33 MJC=0.33 TF=0.64E-9 TR=50.72E-9 EG=1.11 KF=0 AF=1 VCEO=45V ICRATING=100M MFG=ZETEX")
-
// Have a common start for transistors
class NETLIB_NAME(Q) : public netlist_device_t
@@ -236,7 +280,7 @@ protected:
ATTR_COLD virtual void start();
ATTR_HOT ATTR_ALIGN void update();
- netlist_param_multi_t m_model;
+ netlist_param_model_t m_model;
private:
q_type m_qtype;
};
diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c
index 68c9a7de4a4..e6d7b628721 100644
--- a/src/emu/netlist/nl_base.c
+++ b/src/emu/netlist/nl_base.c
@@ -355,9 +355,9 @@ ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, cons
template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_double_t &param, const double initialVal);
template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_int_t &param, const int initialVal);
template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_logic_t &param, const int initialVal);
-template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_str_t &param, const char * initialVal);
+template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_str_t &param, const char * const initialVal);
template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_str_t &param, const pstring &initialVal);
-template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_multi_t &param, const char * const initialVal);
+template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_model_t &param, const char * const initialVal);
// ----------------------------------------------------------------------------------------
@@ -553,7 +553,7 @@ ATTR_COLD void netlist_logic_output_t::set_levels(const double low, const double
// netlist_param_t & friends
// ----------------------------------------------------------------------------------------
-ATTR_COLD double netlist_param_multi_t::dValue(const pstring &entity, const double defval) const
+ATTR_COLD double netlist_param_model_t::dValue(const pstring &entity, const double defval) const
{
pstring tmp = this->Value();
// .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)
diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h
index 4e51a4b057a..e194ed04b9b 100644
--- a/src/emu/netlist/nl_base.h
+++ b/src/emu/netlist/nl_base.h
@@ -665,6 +665,7 @@ class netlist_param_t : public netlist_owned_object_t
public:
enum param_type_t {
+ MODEL,
STRING,
DOUBLE,
INTEGER,
@@ -741,17 +742,23 @@ private:
pstring m_param;
};
-class netlist_param_multi_t : public netlist_param_str_t
+class netlist_param_model_t : public netlist_param_t
{
public:
- netlist_param_multi_t()
- : netlist_param_str_t()
+ netlist_param_model_t()
+ : netlist_param_t(MODEL)
+ , m_param("")
{ }
+ ATTR_COLD inline void initial(const pstring &val) { m_param = val; }
+
+ ATTR_HOT inline const pstring &Value() const { return m_param; }
+
/* these should be cached! */
ATTR_COLD double dValue(const pstring &entity, const double defval = 0.0) const;
private:
+ pstring m_param;
};
// ----------------------------------------------------------------------------------------
@@ -1209,6 +1216,12 @@ public:
void initialize();
+ template<class _C>
+ void register_device(const pstring &name, const pstring &classname)
+ {
+ m_list.add(new net_device_t_factory< _C >(name, classname) );
+ }
+
netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
diff --git a/src/emu/netlist/nl_config.h b/src/emu/netlist/nl_config.h
index cc39e827f96..d6c26c851d1 100644
--- a/src/emu/netlist/nl_config.h
+++ b/src/emu/netlist/nl_config.h
@@ -36,18 +36,13 @@
#define NETLIST_MASK (NETLIST_DIV-1)
#define NETLIST_CLOCK (NETLIST_INTERNAL_RES / NETLIST_DIV)
+//FIXME: LEGACY
#define NETLIST_HIGHIMP_V (1.23456e20) /* some voltage we should never see */
#define NETLIST_GMIN (1e-9)
typedef UINT8 netlist_sig_t;
-/* FIXME: We need a different solution to output delegates !
- * More something like a callback object
- */
-
-typedef delegate<void (const double)> netlist_output_delegate;
-
//============================================================
// DEBUGGING
//============================================================
diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c
index 83c79a990e5..0e8d18aaf3a 100644
--- a/src/emu/netlist/nl_setup.c
+++ b/src/emu/netlist/nl_setup.c
@@ -16,6 +16,11 @@ static NETLIST_START(base)
NETDEV_TTL_CONST(ttlhigh, 1)
NETDEV_TTL_CONST(ttllow, 0)
NETDEV_ANALOG_CONST(NC, NETLIST_HIGHIMP_V)
+
+ NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)")
+ NET_MODEL(".model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)")
+ NET_MODEL(".MODEL BC237B NPN(IS=1.8E-14 ISE=5.0E-14 ISC=1.72E-13 XTI=3 BF=400 BR=35.5 IKF=0.14 IKR=0.03 XTB=1.5 VAF=80 VAR=12.5 VJE=0.58 VJC=0.54 RE=0.6 RC=0.25 RB=0.56 CJE=13E-12 CJC=4E-12 XCJC=0.75 FC=0.5 NF=0.9955 NR=1.005 NE=1.46 NC=1.27 MJE=0.33 MJC=0.33 TF=0.64E-9 TR=50.72E-9 EG=1.11 KF=0 AF=1 VCEO=45V ICRATING=100M MFG=ZETEX)")
+
NETLIST_END
@@ -28,7 +33,7 @@ netlist_setup_t::netlist_setup_t(netlist_base_t &netlist)
, m_proxy_cnt(0)
{
m_factory.initialize();
- NETLIST_NAME(base)(*this);
+ NETLIST_NAME(base)(*this);
}
template <class T>
@@ -100,6 +105,7 @@ void netlist_setup_t::remove_dev(const pstring &name)
m_devices.remove(name);
}
+#if 0
void netlist_setup_t::register_callback(const pstring &devname, netlist_output_delegate delegate)
{
NETLIB_NAME(analog_callback) *dev = (NETLIB_NAME(analog_callback) *) m_devices.find(devname);
@@ -107,6 +113,12 @@ void netlist_setup_t::register_callback(const pstring &devname, netlist_output_d
fatalerror("did not find device %s\n", devname.cstr());
dev->register_callback(delegate);
}
+#endif
+
+void netlist_setup_t::register_model(const pstring &model)
+{
+ m_models.add(model);
+}
void netlist_setup_t::register_alias(const pstring &alias, const pstring &out)
{
@@ -196,6 +208,25 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
dynamic_cast<netlist_param_str_t &>(param).initial(val);
}
break;
+ case netlist_param_t::MODEL:
+ {
+ pstring search = (".model " + val + " ").ucase();
+ bool found = false;
+ for (int i=0; i < m_models.count(); i++)
+ {
+ if (m_models[i].ucase().startsWith(search))
+ {
+ int pl=m_models[i].find("(");
+ int pr=m_models[i].find("(");
+ dynamic_cast<netlist_param_model_t &>(param).initial(m_models[i].substr(pl+1,pr-pl-1));
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ fatalerror("Model %s not found\n", val.cstr());
+ }
+ break;
default:
fatalerror("Parameter is not supported %s : %s\n", temp.cstr(), val.cstr());
}
diff --git a/src/emu/netlist/nl_setup.h b/src/emu/netlist/nl_setup.h
index 5e15409ea80..aef51dddf31 100644
--- a/src/emu/netlist/nl_setup.h
+++ b/src/emu/netlist/nl_setup.h
@@ -18,18 +18,26 @@
#define NET_STR(_x) # _x
+#define NET_MODEL(_model) \
+ netlist.register_model(_model);
+
#define NET_ALIAS(_alias, _name) \
netlist.register_alias(# _alias, # _name);
+
#define NET_NEW(_type) netlist.factory().new_device_by_classname(NETLIB_NAME_STR(_type), netlist)
#define NET_REGISTER_DEV(_type, _name) \
netlist.register_dev(NET_NEW(_type), # _name);
+
#define NET_REMOVE_DEV(_name) \
netlist.remove_dev(# _name);
+
#define NET_REGISTER_SIGNAL(_type, _name) \
NET_REGISTER_DEV(_type ## _ ## sig, _name)
+
#define NET_CONNECT(_name, _input, _output) \
netlist.register_link(# _name "." # _input, # _output);
+
#define NET_C(_input, _output) \
netlist.register_link(NET_STR(_input) , NET_STR(_output));
@@ -49,9 +57,6 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
#define NETLIST_INCLUDE(_name) \
NETLIST_NAME(_name)(netlist);
-#define NETLIST_MEMREGION(_name) \
- netlist.parse((char *)downcast<netlist_t &>(netlist.netlist()).machine().root_device().memregion(_name)->base());
-
// ----------------------------------------------------------------------------------------
// FIXME: Clean this up
// ----------------------------------------------------------------------------------------
@@ -103,6 +108,7 @@ public:
netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name);
void remove_dev(const pstring &name);
+ void register_model(const pstring &model);
void register_alias(const pstring &alias, const pstring &out);
void register_link(const pstring &sin, const pstring &sout);
void register_param(const pstring &param, const pstring &value);
@@ -115,9 +121,9 @@ public:
netlist_core_terminal_t *find_terminal(const pstring &outname_in, netlist_object_t::type_t atype, bool required = true);
netlist_param_t *find_param(const pstring &param_in, bool required = true);
-
+#if 0
void register_callback(const pstring &devname, netlist_output_delegate delegate);
-
+#endif
void parse(char *buf);
void start_devices(void);
@@ -143,6 +149,8 @@ private:
netlist_factory m_factory;
+ netlist_list_t<pstring> m_models;
+
int m_proxy_cnt;
void connect_terminals(netlist_core_terminal_t &in, netlist_core_terminal_t &out);
diff --git a/src/mame/drivers/pong.c b/src/mame/drivers/pong.c
index 8bb933801cc..132163b93e0 100644
--- a/src/mame/drivers/pong.c
+++ b/src/mame/drivers/pong.c
@@ -379,7 +379,7 @@ static NETLIST_START(pong_schematics)
NETDEV_R(ic_b9_R, RES_K(71))
NETDEV_C(ic_b9_C, CAP_U(.1))
- NETDEV_1N914(ic_b9_D)
+ NETDEV_D(ic_b9_D, 1N914)
NETDEV_NE555(ic_b9)
NET_C(ic_b9.VCC, V5)
@@ -418,7 +418,7 @@ static NETLIST_START(pong_schematics)
NETDEV_R(ic_a9_R, RES_K(71))
NETDEV_C(ic_a9_C, CAP_U(.1))
- NETDEV_1N914(ic_a9_D)
+ NETDEV_D(ic_a9_D, 1N914)
NETDEV_NE555(ic_a9)
NET_C(ic_a9.VCC, V5)
@@ -783,24 +783,6 @@ static NETLIST_START(pong_schematics)
NETLIST_END
-static NETLIST_START(pong)
-
- //NETLIST_INCLUDE(pong_schematics)
- NETLIST_MEMREGION("maincpu")
- NETDEV_CALLBACK(sound_cb, sound)
- NETDEV_CALLBACK(video_cb, videomix)
-
-NETLIST_END
-
-static NETLIST_START(pong_fast)
-
- NETLIST_INCLUDE(pong_schematics)
-
- NETDEV_CALLBACK(sound_cb, sound)
- NETDEV_CALLBACK(video_cb, videomix)
-
-NETLIST_END
-
class pong_state : public driver_device
{
public:
@@ -849,16 +831,16 @@ public:
DECLARE_INPUT_CHANGED_MEMBER(input_changed);
- void sound_cb(double newval)
+ NETDEV_ANALOG_CALLBACK_MEMBER(sound_cb)
{
//printf("snd %f\n", newval);
//dac_w(m_dac, 0, newval*64);
- m_dac->write_unsigned8(64*newval);
+ m_dac->write_unsigned8(64*data);
}
- void video_cb(double newval)
+ NETDEV_ANALOG_CALLBACK_MEMBER(video_cb)
{
- m_video->update_vid(newval, m_maincpu->local_time());
+ m_video->update_vid(data, time);
//printf("%20.15f\n", newval);
}
@@ -874,6 +856,24 @@ private:
};
+static NETLIST_START(pong)
+
+ //NETLIST_INCLUDE(pong_schematics)
+ NETLIST_MEMREGION("maincpu")
+
+ NETDEV_ANALOG_CALLBACK(sound_cb, sound, pong_state, sound_cb, "")
+ NETDEV_ANALOG_CALLBACK(video_cb, videomix, pong_state, video_cb, "")
+NETLIST_END
+
+static NETLIST_START(pong_fast)
+
+ NETLIST_INCLUDE(pong_schematics)
+
+ NETDEV_ANALOG_CALLBACK(sound_cb, sound, pong_state, sound_cb, "")
+ NETDEV_ANALOG_CALLBACK(video_cb, videomix, pong_state, video_cb, "")
+
+NETLIST_END
+
void pong_state::machine_start()
{
if (strcmp(this->shortname(),"pong")==0)
@@ -889,8 +889,6 @@ void pong_state::machine_reset()
void pong_state::video_start()
{
- m_maincpu->setup().register_callback("sound_cb", netlist_output_delegate(&pong_state::sound_cb, "pong_state::sound_cb", this));
- m_maincpu->setup().register_callback("video_cb", netlist_output_delegate(&pong_state::video_cb, "pong_state::video_cb", this));
}