mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
Netlist: Reworked object model a bit.
There is a slight performance drop (7%). Memory allocation order seems to be an issue here.
This commit is contained in:
parent
c06fb77b68
commit
4bd4380e80
@ -88,6 +88,8 @@ void netlist_mame_device::device_start()
|
||||
|
||||
m_setup_func(*m_setup);
|
||||
|
||||
m_setup->start_devices();
|
||||
|
||||
bool allok = true;
|
||||
for (on_device_start **ods = m_device_start_list.first(); ods <= m_device_start_list.last(); ods++)
|
||||
allok &= (*ods)->OnDeviceStart();
|
||||
|
@ -243,7 +243,7 @@ public:
|
||||
virtual bool OnDeviceStart()
|
||||
{
|
||||
this->m_target = &m_netlist->setup().find_param(m_output);
|
||||
return this->report_missing(this->m_target != NULL, "output", true);
|
||||
return this->report_missing(this->m_target != NULL, "parameter", true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -194,7 +194,7 @@ NETLIB_START(nicNE555N_MSTABLE)
|
||||
register_param("VS", m_VS, 5.0);
|
||||
register_param("VL", m_VL, 0.0 *5.0);
|
||||
|
||||
m_THRESHOLD_OUT.init_terminal(*this, "THRESHOLD");
|
||||
m_THRESHOLD_OUT.init_object(*this, "THRESHOLD");
|
||||
register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, netlist_input_t::STATE_INP_ACTIVE);
|
||||
|
||||
m_Q.initial(5.0 * 0.4);
|
||||
@ -987,7 +987,7 @@ static const net_device_t_base_factory *netregistry[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup, const astring &icname)
|
||||
netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup)
|
||||
{
|
||||
const net_device_t_base_factory **p = &netregistry[0];
|
||||
while (*p != NULL)
|
||||
@ -995,16 +995,15 @@ netlist_device_t *net_create_device_by_classname(const astring &classname, netli
|
||||
if (strcmp((*p)->classname(), classname) == 0)
|
||||
{
|
||||
netlist_device_t *ret = (*p)->Create();
|
||||
ret->init(setup, icname);
|
||||
return ret;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
fatalerror("Class %s required for IC %s not found!\n", classname.cstr(), icname.cstr());
|
||||
fatalerror("Class %s not found!\n", classname.cstr());
|
||||
return NULL; // appease code analysis
|
||||
}
|
||||
|
||||
netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup, const astring &icname)
|
||||
netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup)
|
||||
{
|
||||
const net_device_t_base_factory **p = &netregistry[0];
|
||||
while (*p != NULL)
|
||||
@ -1012,11 +1011,11 @@ netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t
|
||||
if (strcmp((*p)->name(), name) == 0)
|
||||
{
|
||||
netlist_device_t *ret = (*p)->Create();
|
||||
ret->init(setup, icname);
|
||||
//ret->init(setup, icname);
|
||||
return ret;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
fatalerror("Class %s required for IC %s not found!\n", name.cstr(), icname.cstr());
|
||||
fatalerror("Class %s not found!\n", name.cstr());
|
||||
return NULL; // appease code analysis
|
||||
}
|
||||
|
@ -143,6 +143,7 @@ NETLIB_UPDATE(solver)
|
||||
|
||||
if (delta >= m_inc)
|
||||
{
|
||||
NL_VERBOSE_OUT(("Step!\n"));
|
||||
/* update all terminals for new time step */
|
||||
m_last_step = now;
|
||||
for (netlist_terminal_t **p = m_terms.first(); p != NULL; p = m_terms.next(p))
|
||||
|
@ -6,6 +6,52 @@
|
||||
#include "nl_base.h"
|
||||
#include "devices/nld_system.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_object_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD netlist_object_t::netlist_object_t(const type_t atype, const family_t afamily)
|
||||
: m_objtype(atype)
|
||||
, m_family(afamily)
|
||||
, m_netlist(NULL)
|
||||
, m_name(NULL)
|
||||
{}
|
||||
|
||||
ATTR_COLD netlist_object_t::~netlist_object_t()
|
||||
{
|
||||
delete m_name;
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_object_t::init_object(netlist_base_t &nl, const astring &aname)
|
||||
{
|
||||
m_netlist = &nl;
|
||||
m_name = new astring(aname);
|
||||
}
|
||||
|
||||
ATTR_COLD const astring &netlist_object_t::name() const
|
||||
{
|
||||
if (m_name == NULL)
|
||||
fatalerror("object not initialized");
|
||||
return *m_name;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_owned_object_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD netlist_owned_object_t::netlist_owned_object_t(const type_t atype,
|
||||
const family_t afamily)
|
||||
: netlist_object_t(atype, afamily)
|
||||
, m_netdev(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_owned_object_t::init_object(netlist_core_device_t &dev,
|
||||
const astring &aname)
|
||||
{
|
||||
netlist_object_t::init_object(dev.netlist(), aname);
|
||||
m_netdev = &dev;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_base_t
|
||||
@ -244,10 +290,10 @@ ATTR_COLD void netlist_device_t::register_input(const astring &name, netlist_inp
|
||||
// FIXME: Revise internal links ...
|
||||
ATTR_COLD void netlist_device_t::register_link_internal(netlist_core_device_t &dev, netlist_input_t &in, netlist_output_t &out, netlist_input_t::state_e aState)
|
||||
{
|
||||
in.init_terminal(dev, "internal input", aState);
|
||||
in.init_object(dev, "internal input", aState);
|
||||
// ensure we are not yet initialized ...
|
||||
if (!out.net().isRailNet())
|
||||
out.init_terminal(dev, "internal output");
|
||||
out.init_object(dev, "internal output");
|
||||
//if (in.state() != net_input_t::INP_STATE_PASSIVE)
|
||||
out.net().register_con(in);
|
||||
}
|
||||
@ -287,6 +333,12 @@ ATTR_COLD netlist_net_t::netlist_net_t(const type_t atype, const family_t afamil
|
||||
m_last.Q = 0;
|
||||
};
|
||||
|
||||
ATTR_COLD void netlist_net_t::register_railterminal(netlist_terminal_t &mr)
|
||||
{
|
||||
assert(m_railterminal == NULL);
|
||||
m_railterminal = &mr;
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_net_t::merge_net(netlist_net_t *othernet)
|
||||
{
|
||||
NL_VERBOSE_OUT(("merging nets ...\n"));
|
||||
@ -377,11 +429,37 @@ ATTR_HOT inline void netlist_net_t::update_devs()
|
||||
// netlist_terminal_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD void netlist_terminal_t::init_terminal(netlist_core_device_t &dev, const astring &aname, const state_e astate)
|
||||
ATTR_COLD netlist_terminal_t::netlist_terminal_t(const type_t atype, const family_t afamily)
|
||||
: netlist_owned_object_t(atype, afamily)
|
||||
, m_Idr(0.0)
|
||||
, m_g(NETLIST_GMIN)
|
||||
, m_update_list_next(NULL)
|
||||
, m_net(NULL)
|
||||
, m_state(STATE_NONEX)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_terminal_t::netlist_terminal_t()
|
||||
: netlist_owned_object_t(TERMINAL, ANALOG)
|
||||
, m_Idr(0.0)
|
||||
, m_g(NETLIST_GMIN)
|
||||
, m_update_list_next(NULL)
|
||||
, m_net(NULL)
|
||||
, m_state(STATE_NONEX)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_terminal_t::init_object(netlist_core_device_t &dev, const astring &aname, const state_e astate)
|
||||
{
|
||||
m_netdev = &dev;
|
||||
set_state(astate);
|
||||
init_object(dev.netlist(), aname);
|
||||
netlist_owned_object_t::init_object(dev, aname);
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_terminal_t::set_net(netlist_net_t &anet)
|
||||
{
|
||||
m_net = &anet;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -402,9 +480,9 @@ netlist_output_t::netlist_output_t(const type_t atype, const family_t afamily)
|
||||
this->set_net(m_my_net);
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_output_t::init_terminal(netlist_core_device_t &dev, const astring &aname)
|
||||
ATTR_COLD void netlist_output_t::init_object(netlist_core_device_t &dev, const astring &aname)
|
||||
{
|
||||
netlist_terminal_t::init_terminal(dev, aname, STATE_OUT);
|
||||
netlist_terminal_t::init_object(dev, aname, STATE_OUT);
|
||||
net().init_object(dev.netlist(), aname);
|
||||
net().register_railterminal(*this);
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ class netlist_base_t;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// net_object_t
|
||||
// netlist_object_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_object_t
|
||||
@ -244,25 +244,13 @@ public:
|
||||
ALL = 4 // <== devices usually fall into this category
|
||||
};
|
||||
|
||||
ATTR_COLD netlist_object_t(const type_t atype, const family_t afamily)
|
||||
: m_name(NULL)
|
||||
, m_objtype(atype)
|
||||
, m_family(afamily)
|
||||
, m_netlist(NULL)
|
||||
{}
|
||||
ATTR_COLD netlist_object_t(const type_t atype, const family_t afamily);
|
||||
|
||||
virtual ~netlist_object_t()
|
||||
{
|
||||
delete m_name;
|
||||
}
|
||||
virtual ~netlist_object_t();
|
||||
|
||||
ATTR_COLD void init_object(netlist_base_t &nl, const astring &aname)
|
||||
{
|
||||
m_netlist = &nl;
|
||||
m_name = new astring(aname);
|
||||
}
|
||||
ATTR_COLD void init_object(netlist_base_t &nl, const astring &aname);
|
||||
|
||||
ATTR_COLD const astring &name() const { if (m_name == NULL) fatalerror("object not initialized"); return *m_name; }
|
||||
ATTR_COLD const astring &name() const;
|
||||
|
||||
ATTR_HOT inline const type_t type() const { return m_objtype; }
|
||||
ATTR_HOT inline const family_t family() const { return m_family; }
|
||||
@ -274,17 +262,33 @@ public:
|
||||
ATTR_HOT inline const netlist_base_t & RESTRICT netlist() const { return *m_netlist; }
|
||||
|
||||
private:
|
||||
astring *m_name;
|
||||
const type_t m_objtype;
|
||||
const family_t m_family;
|
||||
netlist_base_t * RESTRICT m_netlist;
|
||||
astring *m_name;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_owned_object_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_owned_object_t : public netlist_object_t
|
||||
{
|
||||
public:
|
||||
ATTR_COLD netlist_owned_object_t(const type_t atype, const family_t afamily);
|
||||
|
||||
ATTR_COLD void init_object(netlist_core_device_t &dev, const astring &aname);
|
||||
|
||||
ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; }
|
||||
private:
|
||||
netlist_core_device_t * RESTRICT m_netdev;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// net_terminal_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_terminal_t : public netlist_object_t
|
||||
class netlist_terminal_t : public netlist_owned_object_t
|
||||
{
|
||||
public:
|
||||
|
||||
@ -299,30 +303,13 @@ public:
|
||||
STATE_NONEX = 256
|
||||
};
|
||||
|
||||
ATTR_COLD netlist_terminal_t(const type_t atype, const family_t afamily)
|
||||
: netlist_object_t(atype, afamily)
|
||||
, m_Idr(0.0)
|
||||
, m_g(NETLIST_GMIN)
|
||||
, m_update_list_next(NULL)
|
||||
, m_netdev(NULL)
|
||||
, m_net(NULL)
|
||||
, m_state(STATE_NONEX)
|
||||
{}
|
||||
ATTR_COLD netlist_terminal_t(const type_t atype, const family_t afamily);
|
||||
ATTR_COLD netlist_terminal_t();
|
||||
|
||||
ATTR_COLD netlist_terminal_t()
|
||||
: netlist_object_t(TERMINAL, ANALOG)
|
||||
, m_Idr(0.0)
|
||||
, m_update_list_next(NULL)
|
||||
, m_netdev(NULL)
|
||||
, m_net(NULL)
|
||||
, m_state(STATE_NONEX)
|
||||
{}
|
||||
|
||||
ATTR_COLD void init_terminal(netlist_core_device_t &dev, const astring &aname, const state_e astate);
|
||||
|
||||
ATTR_COLD void set_net(netlist_net_t &anet) { m_net = &anet; }
|
||||
ATTR_COLD bool has_net() { return (m_net != NULL); }
|
||||
ATTR_COLD void init_object(netlist_core_device_t &dev, const astring &aname, const state_e astate);
|
||||
|
||||
ATTR_COLD void set_net(netlist_net_t &anet);
|
||||
ATTR_COLD inline bool has_net() { return (m_net != NULL); }
|
||||
ATTR_HOT inline const netlist_net_t & RESTRICT net() const { return *m_net;}
|
||||
ATTR_HOT inline netlist_net_t & RESTRICT net() { return *m_net;}
|
||||
|
||||
@ -334,15 +321,12 @@ public:
|
||||
m_state = astate;
|
||||
}
|
||||
|
||||
ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; }
|
||||
|
||||
double m_Idr; // drive current
|
||||
double m_g; // conductance
|
||||
|
||||
netlist_terminal_t *m_update_list_next;
|
||||
|
||||
private:
|
||||
netlist_core_device_t * RESTRICT m_netdev;
|
||||
netlist_net_t * RESTRICT m_net;
|
||||
state_e m_state;
|
||||
};
|
||||
@ -456,11 +440,7 @@ public:
|
||||
|
||||
ATTR_COLD void register_con(netlist_terminal_t &terminal);
|
||||
ATTR_COLD void merge_net(netlist_net_t *othernet);
|
||||
ATTR_COLD void register_railterminal(netlist_terminal_t &mr)
|
||||
{
|
||||
assert(m_railterminal == NULL);
|
||||
m_railterminal = &mr;
|
||||
}
|
||||
ATTR_COLD void register_railterminal(netlist_terminal_t &mr);
|
||||
|
||||
/* inline not always works out */
|
||||
ATTR_HOT inline void update_devs();
|
||||
@ -470,7 +450,7 @@ public:
|
||||
|
||||
ATTR_HOT inline bool isRailNet() { return !(m_railterminal == NULL); }
|
||||
ATTR_HOT inline const netlist_terminal_t & RESTRICT railterminal() const { return *m_railterminal; }
|
||||
ATTR_HOT inline netlist_terminal_t & RESTRICT railterminal() { return *m_railterminal; }
|
||||
ATTR_HOT inline const netlist_terminal_t & RESTRICT railterminal() { return *m_railterminal; }
|
||||
|
||||
/* Everything below is used by the logic subsystem */
|
||||
|
||||
@ -533,9 +513,9 @@ class netlist_output_t : public netlist_terminal_t
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_output_t(const type_t atype, const family_t afamily);
|
||||
ATTR_COLD netlist_output_t(const type_t atype, const family_t afamily);
|
||||
|
||||
ATTR_COLD void init_terminal(netlist_core_device_t &dev, const astring &aname);
|
||||
ATTR_COLD void init_object(netlist_core_device_t &dev, const astring &aname);
|
||||
|
||||
double m_low_V;
|
||||
double m_high_V;
|
||||
@ -617,9 +597,9 @@ class netlist_core_device_t : public netlist_object_t
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_core_device_t();
|
||||
ATTR_COLD netlist_core_device_t();
|
||||
|
||||
virtual ~netlist_core_device_t();
|
||||
ATTR_COLD virtual ~netlist_core_device_t();
|
||||
|
||||
ATTR_COLD virtual void init(netlist_setup_t &setup, const astring &name);
|
||||
|
||||
@ -699,7 +679,7 @@ public:
|
||||
|
||||
ATTR_COLD netlist_device_t();
|
||||
|
||||
virtual ~netlist_device_t();
|
||||
ATTR_COLD virtual ~netlist_device_t();
|
||||
|
||||
ATTR_COLD virtual void init(netlist_setup_t &setup, const astring &name);
|
||||
|
||||
@ -750,8 +730,8 @@ public:
|
||||
|
||||
ATTR_HOT inline void setTo(const double param) { m_param = param; m_netdev->update_param(); }
|
||||
ATTR_HOT inline void setTo(const int param) { m_param = param; m_netdev->update_param(); }
|
||||
inline void initial(const double val) { m_param = val; }
|
||||
inline void initial(const int val) { m_param = val; }
|
||||
ATTR_COLD inline void initial(const double val) { m_param = val; }
|
||||
ATTR_COLD inline void initial(const int val) { m_param = val; }
|
||||
|
||||
ATTR_HOT inline const double Value() const { return m_param; }
|
||||
ATTR_HOT inline const int ValueInt() const { return (int) m_param; }
|
||||
@ -774,12 +754,14 @@ class netlist_base_t
|
||||
{
|
||||
public:
|
||||
|
||||
typedef netlist_timed_queue1<netlist_net_t, netlist_time, 512> queue_t;
|
||||
typedef netlist_timed_queue<netlist_net_t, netlist_time, 512> queue_t;
|
||||
|
||||
netlist_base_t();
|
||||
virtual ~netlist_base_t();
|
||||
|
||||
void set_clock_freq(UINT64 clockfreq);
|
||||
ATTR_COLD void set_clock_freq(UINT64 clockfreq);
|
||||
|
||||
ATTR_HOT inline queue_t &queue() { return m_queue; }
|
||||
|
||||
ATTR_HOT inline void push_to_queue(netlist_net_t &out, const netlist_time &attime)
|
||||
{
|
||||
@ -797,9 +779,6 @@ public:
|
||||
|
||||
ATTR_COLD void reset();
|
||||
|
||||
// FIXME: should'nt be public
|
||||
queue_t m_queue;
|
||||
|
||||
protected:
|
||||
// performance
|
||||
int m_perf_out_processed;
|
||||
@ -807,6 +786,7 @@ protected:
|
||||
int m_perf_inp_active;
|
||||
|
||||
private:
|
||||
queue_t m_queue;
|
||||
NETLIB_NAME(mainclock) * m_mainclock;
|
||||
NETLIB_NAME(solver) * m_solver;
|
||||
netlist_time m_time_ps;
|
||||
@ -841,9 +821,9 @@ public:
|
||||
protected:
|
||||
void start()
|
||||
{
|
||||
m_I.init_terminal(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
|
||||
m_I.init_object(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
|
||||
|
||||
m_Q.init_terminal(*this, "Q");
|
||||
m_Q.init_object(*this, "Q");
|
||||
m_Q.initial(1);
|
||||
}
|
||||
|
||||
@ -883,8 +863,8 @@ public:
|
||||
protected:
|
||||
void start()
|
||||
{
|
||||
m_I.init_terminal(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
|
||||
m_Q.init_terminal(*this, "Q");
|
||||
m_I.init_object(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
|
||||
m_Q.init_object(*this, "Q");
|
||||
m_Q.initial(0);
|
||||
}
|
||||
|
||||
@ -1044,8 +1024,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup, const astring &icname);
|
||||
netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup, const astring &icname);
|
||||
netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup);
|
||||
netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup);
|
||||
|
||||
|
||||
#endif /* NLBASE_H_ */
|
||||
|
@ -80,7 +80,7 @@ private:
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <class _Element, class _Time, int _Size>
|
||||
class netlist_timed_queue1
|
||||
class netlist_timed_queue
|
||||
{
|
||||
public:
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
_Element *m_object;
|
||||
};
|
||||
|
||||
netlist_timed_queue1()
|
||||
netlist_timed_queue()
|
||||
{
|
||||
//m_list = global_alloc_array(entry_t, SIZE);
|
||||
clear();
|
||||
|
@ -53,7 +53,8 @@ void netlist_parser::netdev_param()
|
||||
skipws();
|
||||
val = eval_param();
|
||||
NL_VERBOSE_OUT(("Parser: Param: %s %f\n", param.cstr(), val));
|
||||
m_setup.find_param(param).initial(val);
|
||||
m_setup.register_param(param, val);
|
||||
//m_setup.find_param(param).initial(val);
|
||||
check_char(')');
|
||||
}
|
||||
|
||||
@ -66,15 +67,16 @@ void netlist_parser::netdev_const(const astring &dev_name)
|
||||
|
||||
skipws();
|
||||
name = getname(',');
|
||||
dev = net_create_device_by_name(dev_name, m_setup, name);
|
||||
m_setup.register_dev(dev);
|
||||
dev = net_create_device_by_name(dev_name, m_setup);
|
||||
m_setup.register_dev(dev, name);
|
||||
skipws();
|
||||
val = eval_param();
|
||||
check_char(')');
|
||||
paramfq = name;
|
||||
paramfq.cat(".CONST");
|
||||
NL_VERBOSE_OUT(("Parser: Const: %s %f\n", name.cstr(), val));
|
||||
m_setup.find_param(paramfq).initial(val);
|
||||
//m_setup.find_param(paramfq).initial(val);
|
||||
m_setup.register_param(paramfq, val);
|
||||
}
|
||||
|
||||
void netlist_parser::netdev_device(const astring &dev_type)
|
||||
@ -85,8 +87,8 @@ void netlist_parser::netdev_device(const astring &dev_type)
|
||||
|
||||
skipws();
|
||||
devname = getname2(',', ')');
|
||||
dev = net_create_device_by_name(dev_type, m_setup, devname);
|
||||
m_setup.register_dev(dev);
|
||||
dev = net_create_device_by_name(dev_type, m_setup);
|
||||
m_setup.register_dev(dev, devname);
|
||||
skipws();
|
||||
NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr()));
|
||||
cnt = 0;
|
||||
@ -96,16 +98,20 @@ void netlist_parser::netdev_device(const astring &dev_type)
|
||||
skipws();
|
||||
astring output_name = getname2(',', ')');
|
||||
NL_VERBOSE_OUT(("Parser: ID: %s %s\n", output_name.cstr(), dev->m_terminals.item(cnt)->cstr()));
|
||||
m_setup.register_link(devname + "." + *dev->m_terminals.item(cnt), output_name);
|
||||
astring temp;
|
||||
temp.printf("%s.[%d]", devname.cstr(), cnt);
|
||||
m_setup.register_link(temp, output_name);
|
||||
skipws();
|
||||
cnt++;
|
||||
}
|
||||
if (cnt != dev->m_terminals.count() && !dev->variable_input_count())
|
||||
/*
|
||||
if (cnt != dev->m_terminals.count() && !dev->variable_input_count())
|
||||
fatalerror("netlist: input count mismatch for %s - expected %d found %d\n", devname.cstr(), dev->m_terminals.count(), cnt);
|
||||
if (dev->variable_input_count())
|
||||
{
|
||||
NL_VERBOSE_OUT(("variable inputs %s: %d\n", dev->name().cstr(), cnt));
|
||||
}
|
||||
*/
|
||||
check_char(')');
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,10 @@ netlist_setup_t::~netlist_setup_t()
|
||||
m_terminals.reset();
|
||||
}
|
||||
|
||||
netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev)
|
||||
netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const astring &name)
|
||||
{
|
||||
if (!(m_devices.add(dev->name(), dev, false)==TMERR_NONE))
|
||||
fatalerror("Error adding %s to device list\n", dev->name().cstr());
|
||||
if (!(m_devices.add(name, dev, false)==TMERR_NONE))
|
||||
fatalerror("Error adding %s to device list\n", name.cstr());
|
||||
return dev;
|
||||
}
|
||||
|
||||
@ -144,9 +144,9 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
|
||||
{
|
||||
netlist_terminal_t &term = dynamic_cast<netlist_terminal_t &>(obj);
|
||||
if (obj.isType(netlist_terminal_t::OUTPUT))
|
||||
dynamic_cast<netlist_output_t &>(term).init_terminal(upd_dev, dev.name() + "." + name);
|
||||
dynamic_cast<netlist_output_t &>(term).init_object(upd_dev, dev.name() + "." + name);
|
||||
else
|
||||
term.init_terminal(upd_dev, dev.name() + "." + name, state);
|
||||
term.init_object(upd_dev, dev.name() + "." + name, state);
|
||||
|
||||
if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE))
|
||||
fatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr());
|
||||
@ -161,6 +161,15 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
|
||||
astring temp = param.netdev().name();
|
||||
temp.cat(".");
|
||||
temp.cat(name);
|
||||
const astring *val = m_params_temp.find(temp);
|
||||
if (val != NULL)
|
||||
{
|
||||
//printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
|
||||
double vald = 0;
|
||||
if (sscanf(val->cstr(), "%lf", &vald) != 1)
|
||||
fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val->cstr());
|
||||
param.initial(vald);
|
||||
}
|
||||
if (!(m_params.add(temp, ¶m, false)==TMERR_NONE))
|
||||
fatalerror("Error adding parameter %s to parameter list\n", name.cstr());
|
||||
}
|
||||
@ -178,12 +187,39 @@ void netlist_setup_t::register_link(const astring &sin, const astring &sout)
|
||||
fatalerror("Error adding link %s<==%s to link list\n", sin.cstr(), sout.cstr());
|
||||
}
|
||||
|
||||
const astring &netlist_setup_t::resolve_alias(const astring &name) const
|
||||
void netlist_setup_t::register_param(const astring ¶m, const double value)
|
||||
{
|
||||
const astring *ret = m_alias.find(name);
|
||||
if (ret != NULL)
|
||||
return *ret;
|
||||
return name;
|
||||
// FIXME: there should be a better way
|
||||
astring temp;
|
||||
temp.printf("%.9e", value);
|
||||
register_param(param, temp);
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_param(const astring ¶m, const astring &value)
|
||||
{
|
||||
if (!(m_params_temp.add(param, new astring(value), false)==TMERR_NONE))
|
||||
fatalerror("Error adding parameter %s to parameter list\n", param.cstr());
|
||||
}
|
||||
|
||||
const astring netlist_setup_t::resolve_alias(const astring &name) const
|
||||
{
|
||||
const astring *temp = m_alias.find(name);
|
||||
astring ret = name;
|
||||
if (temp != NULL)
|
||||
ret = *temp;
|
||||
int p = ret.find(".[");
|
||||
if (p > 0)
|
||||
{
|
||||
astring dname = ret;
|
||||
netlist_device_t *dev = m_devices.find(dname.substr(0,p));
|
||||
if (dev == NULL)
|
||||
fatalerror("Device for %s not found\n", name.cstr());
|
||||
ret.substr(p+2,ret.len()-p-3);
|
||||
int c = atoi(ret);
|
||||
ret = dev->name() + "." + *(dev->m_terminals.item(c));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
netlist_terminal_t &netlist_setup_t::find_terminal(const astring &terminal_in)
|
||||
@ -250,7 +286,7 @@ void netlist_setup_t::connect_input_output(netlist_input_t &in, netlist_output_t
|
||||
x.printf("proxy_ad_%d", m_proxy_cnt++);
|
||||
|
||||
proxy->init(*this, x.cstr());
|
||||
register_dev(proxy);
|
||||
register_dev(proxy, x);
|
||||
|
||||
proxy->m_Q.net().register_con(in);
|
||||
out.net().register_con(proxy->m_I);
|
||||
@ -263,7 +299,7 @@ void netlist_setup_t::connect_input_output(netlist_input_t &in, netlist_output_t
|
||||
astring x = "";
|
||||
x.printf("proxy_da_%d", m_proxy_cnt++);
|
||||
proxy->init(*this, x.cstr());
|
||||
register_dev(proxy);
|
||||
register_dev(proxy, x);
|
||||
|
||||
proxy->m_Q.net().register_con(in);
|
||||
out.net().register_con(proxy->m_I);
|
||||
@ -287,7 +323,7 @@ void netlist_setup_t::connect_terminal_input(netlist_terminal_t &term, netlist_i
|
||||
astring x = "";
|
||||
x.printf("proxy_da_%d", m_proxy_cnt++);
|
||||
proxy->init(*this, x.cstr());
|
||||
register_dev(proxy);
|
||||
register_dev(proxy, x);
|
||||
|
||||
connect_terminals(term, proxy->m_I);
|
||||
|
||||
@ -322,7 +358,7 @@ void netlist_setup_t::connect_terminal_output(netlist_terminal_t &in, netlist_ou
|
||||
astring x = "";
|
||||
x.printf("proxy_da_%d", m_proxy_cnt++);
|
||||
proxy->init(*this, x.cstr());
|
||||
register_dev(proxy);
|
||||
register_dev(proxy, x);
|
||||
|
||||
out.net().register_con(proxy->m_I);
|
||||
|
||||
@ -449,6 +485,15 @@ void netlist_setup_t::resolve_inputs(void)
|
||||
|
||||
}
|
||||
|
||||
void netlist_setup_t::start_devices(void)
|
||||
{
|
||||
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
|
||||
{
|
||||
netlist_device_t *dev = entry->object();
|
||||
dev->init(*this, entry->tag());
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_setup_t::step_devices_once(void)
|
||||
{
|
||||
/* make sure params are set now .. */
|
||||
@ -480,9 +525,9 @@ void netlist_setup_t::print_stats()
|
||||
//entry->object()->s
|
||||
printf("Device %20s : %12d %15ld\n", entry->object()->name().cstr(), entry->object()->stat_count, (long int) entry->object()->total_time / (entry->object()->stat_count + 1));
|
||||
}
|
||||
printf("Queue Start %15d\n", m_netlist.m_queue.m_prof_start);
|
||||
printf("Queue End %15d\n", m_netlist.m_queue.m_prof_end);
|
||||
printf("Queue Sort %15d\n", m_netlist.m_queue.m_prof_sort);
|
||||
printf("Queue Move %15d\n", m_netlist.m_queue.m_prof_sortmove);
|
||||
printf("Queue Start %15d\n", m_netlist.queue().m_prof_start);
|
||||
printf("Queue End %15d\n", m_netlist.queue().m_prof_end);
|
||||
printf("Queue Sort %15d\n", m_netlist.queue().m_prof_sort);
|
||||
printf("Queue Move %15d\n", m_netlist.queue().m_prof_sortmove);
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@
|
||||
|
||||
#define NET_ALIAS(_alias, _name) \
|
||||
netlist.register_alias(# _alias, # _name);
|
||||
#define NET_NEW(_type , _name) net_create_device_by_classname(NETLIB_NAME_STR(_type), netlist, # _name)
|
||||
#define NET_NEW(_type) net_create_device_by_classname(NETLIB_NAME_STR(_type), netlist)
|
||||
|
||||
#define NET_REGISTER_DEV(_type, _name) \
|
||||
netlist.register_dev(NET_NEW(_type, _name));
|
||||
netlist.register_dev(NET_NEW(_type), # _name);
|
||||
#define NET_REMOVE_DEV(_name) \
|
||||
netlist.remove_dev(# _name);
|
||||
#define NET_REGISTER_SIGNAL(_type, _name) \
|
||||
@ -32,11 +32,12 @@
|
||||
netlist.register_link(# _name "." # _input, # _output);
|
||||
#define NET_C(_input, _output) \
|
||||
netlist.register_link(NET_STR(_input) , NET_STR(_output));
|
||||
#define NETDEV_PARAM(_name, _val) \
|
||||
netlist.find_param(# _name).initial(_val);
|
||||
#define NETDEV_PARAMI(_name, _param, _val) \
|
||||
netlist.find_param(# _name "." # _param).initial(_val);
|
||||
|
||||
#define NETDEV_PARAM(_name, _val) \
|
||||
netlist.register_param(# _name, _val);
|
||||
|
||||
#define NETDEV_PARAMI(_name, _param, _val) \
|
||||
netlist.register_param(# _name "." # _param, _val);
|
||||
|
||||
#define NETLIST_NAME(_name) netlist ## _ ## _name
|
||||
|
||||
@ -87,12 +88,13 @@ public:
|
||||
|
||||
netlist_base_t &netlist() { return m_netlist; }
|
||||
|
||||
netlist_device_t *register_dev(netlist_device_t *dev);
|
||||
netlist_device_t *register_dev(netlist_device_t *dev, const astring &name);
|
||||
void remove_dev(const astring &name);
|
||||
|
||||
void register_alias(const astring &alias, const astring &out);
|
||||
|
||||
void register_link(const astring &sin, const astring &sout);
|
||||
void register_param(const astring ¶m, const astring &value);
|
||||
void register_param(const astring ¶m, const double value);
|
||||
|
||||
void register_object(netlist_device_t &dev, netlist_core_device_t &upd_dev, const astring &name, netlist_object_t &obj, netlist_input_t::state_e state);
|
||||
|
||||
@ -105,6 +107,7 @@ public:
|
||||
|
||||
void parse(char *buf);
|
||||
|
||||
void start_devices(void);
|
||||
void resolve_inputs(void);
|
||||
void step_devices_once(void);
|
||||
|
||||
@ -123,6 +126,7 @@ private:
|
||||
tagmap_astring_t m_alias;
|
||||
tagmap_param_t m_params;
|
||||
tagmap_link_t m_links;
|
||||
tagmap_astring_t m_params_temp;
|
||||
|
||||
int m_proxy_cnt;
|
||||
|
||||
@ -134,7 +138,7 @@ private:
|
||||
// helpers
|
||||
astring objtype_as_astr(netlist_object_t &in);
|
||||
|
||||
const astring &resolve_alias(const astring &name) const;
|
||||
const astring resolve_alias(const astring &name) const;
|
||||
};
|
||||
|
||||
#endif /* NLSETUP_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user