mirror of
https://github.com/holub/mame
synced 2025-10-08 01:28:00 +03:00
Better seperation of setup_t and netlist_t. (nw)
This commit is contained in:
parent
48e5f590bf
commit
14a5f0143e
@ -103,7 +103,7 @@ void netlist_mame_analog_output_t::custom_netlist_additions(netlist::setup_t &se
|
|||||||
|
|
||||||
plib::owned_ptr<netlist::device_t> dev = plib::owned_ptr<netlist::device_t>::Create<NETLIB_NAME(analog_callback)>(setup.netlist(), setup.build_fqn(dname));
|
plib::owned_ptr<netlist::device_t> dev = plib::owned_ptr<netlist::device_t>::Create<NETLIB_NAME(analog_callback)>(setup.netlist(), setup.build_fqn(dname));
|
||||||
static_cast<NETLIB_NAME(analog_callback) *>(dev.get())->register_callback(m_delegate);
|
static_cast<NETLIB_NAME(analog_callback) *>(dev.get())->register_callback(m_delegate);
|
||||||
setup.register_dev(std::move(dev));
|
setup.netlist().register_dev(std::move(dev));
|
||||||
setup.register_link(dname + ".IN", m_in);
|
setup.register_link(dname + ".IN", m_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +217,14 @@ nl_double netlist_t::gmin() const
|
|||||||
return solver()->gmin();
|
return solver()->gmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void netlist_t::register_dev(plib::owned_ptr<device_t> dev)
|
||||||
|
{
|
||||||
|
for (auto & d : m_devices)
|
||||||
|
if (d->name() == dev->name())
|
||||||
|
log().fatal("Error adding {1} to device list. Duplicate name \n", d->name());
|
||||||
|
m_devices.push_back(std::move(dev));
|
||||||
|
}
|
||||||
|
|
||||||
void netlist_t::start()
|
void netlist_t::start()
|
||||||
{
|
{
|
||||||
/* load the library ... */
|
/* load the library ... */
|
||||||
@ -225,59 +233,7 @@ void netlist_t::start()
|
|||||||
|
|
||||||
m_lib = plib::palloc<plib::dynlib>(libpath);
|
m_lib = plib::palloc<plib::dynlib>(libpath);
|
||||||
|
|
||||||
/* make sure the solver and parameters are started first! */
|
|
||||||
|
|
||||||
for (auto & e : setup().m_device_factory)
|
|
||||||
{
|
|
||||||
if ( setup().factory().is_class<devices::NETLIB_NAME(mainclock)>(e.second)
|
|
||||||
|| setup().factory().is_class<devices::NETLIB_NAME(solver)>(e.second)
|
|
||||||
|| setup().factory().is_class<devices::NETLIB_NAME(gnd)>(e.second)
|
|
||||||
|| setup().factory().is_class<devices::NETLIB_NAME(netlistparams)>(e.second))
|
|
||||||
{
|
|
||||||
auto dev = plib::owned_ptr<device_t>(e.second->Create(*this, e.first));
|
|
||||||
setup().register_dev(std::move(dev));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log().debug("Searching for mainclock and solver ...\n");
|
|
||||||
|
|
||||||
m_mainclock = get_single_device<devices::NETLIB_NAME(mainclock)>("mainclock");
|
|
||||||
m_solver = get_single_device<devices::NETLIB_NAME(solver)>("solver");
|
|
||||||
m_gnd = get_single_device<devices::NETLIB_NAME(gnd)>("gnd");
|
|
||||||
m_params = get_single_device<devices::NETLIB_NAME(netlistparams)>("parameter");
|
|
||||||
|
|
||||||
/* create devices */
|
|
||||||
|
|
||||||
for (auto & e : setup().m_device_factory)
|
|
||||||
{
|
|
||||||
if ( !setup().factory().is_class<devices::NETLIB_NAME(mainclock)>(e.second)
|
|
||||||
&& !setup().factory().is_class<devices::NETLIB_NAME(solver)>(e.second)
|
|
||||||
&& !setup().factory().is_class<devices::NETLIB_NAME(gnd)>(e.second)
|
|
||||||
&& !setup().factory().is_class<devices::NETLIB_NAME(netlistparams)>(e.second))
|
|
||||||
{
|
|
||||||
auto dev = plib::owned_ptr<device_t>(e.second->Create(*this, e.first));
|
|
||||||
setup().register_dev(std::move(dev));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool use_deactivate = (m_params->m_use_deactivate.Value() ? true : false);
|
|
||||||
|
|
||||||
|
|
||||||
for (auto &d : m_devices)
|
|
||||||
{
|
|
||||||
if (use_deactivate)
|
|
||||||
{
|
|
||||||
auto p = setup().m_param_values.find(d->name() + ".HINT_NO_DEACTIVATE");
|
|
||||||
if (p != setup().m_param_values.end())
|
|
||||||
{
|
|
||||||
//FIXME: Error checking
|
|
||||||
auto v = p->second.as_long();
|
|
||||||
d->set_hint_deactivate(!v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
d->set_hint_deactivate(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void netlist_t::stop()
|
void netlist_t::stop()
|
||||||
|
@ -1066,6 +1066,7 @@ namespace netlist
|
|||||||
|
|
||||||
class netlist_t : public plib::plog_dispatch_intf
|
class netlist_t : public plib::plog_dispatch_intf
|
||||||
{
|
{
|
||||||
|
friend class setup_t;
|
||||||
P_PREVENT_COPYING(netlist_t)
|
P_PREVENT_COPYING(netlist_t)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -1095,6 +1096,9 @@ namespace netlist
|
|||||||
void set_setup(setup_t *asetup) { m_setup = asetup; }
|
void set_setup(setup_t *asetup) { m_setup = asetup; }
|
||||||
setup_t &setup() { return *m_setup; }
|
setup_t &setup() { return *m_setup; }
|
||||||
|
|
||||||
|
|
||||||
|
void register_dev(plib::owned_ptr<device_t> dev);
|
||||||
|
|
||||||
net_t *find_net(const pstring &name);
|
net_t *find_net(const pstring &name);
|
||||||
|
|
||||||
template<class device_class>
|
template<class device_class>
|
||||||
@ -1156,7 +1160,7 @@ namespace netlist
|
|||||||
/* sole use is to manage lifetime of family objects */
|
/* sole use is to manage lifetime of family objects */
|
||||||
std::vector<std::pair<pstring, std::unique_ptr<logic_family_desc_t>>> m_family_cache;
|
std::vector<std::pair<pstring, std::unique_ptr<logic_family_desc_t>>> m_family_cache;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// performance
|
// performance
|
||||||
nperfcount_t m_perf_out_processed;
|
nperfcount_t m_perf_out_processed;
|
||||||
|
@ -100,15 +100,6 @@ void setup_t::namespace_pop()
|
|||||||
m_namespace_stack.pop();
|
m_namespace_stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setup_t::register_dev(plib::owned_ptr<device_t> dev)
|
|
||||||
{
|
|
||||||
for (auto & d : netlist().m_devices)
|
|
||||||
if (d->name() == dev->name())
|
|
||||||
log().fatal("Error adding {1} to device list. Duplicate name \n", d->name());
|
|
||||||
netlist().m_devices.push_back(std::move(dev));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup_t::register_lib_entry(const pstring &name)
|
void setup_t::register_lib_entry(const pstring &name)
|
||||||
{
|
{
|
||||||
if (plib::container::contains(m_lib, name))
|
if (plib::container::contains(m_lib, name))
|
||||||
@ -454,7 +445,7 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(core_terminal_t &out)
|
|||||||
|
|
||||||
proxy = new_proxy.get();
|
proxy = new_proxy.get();
|
||||||
|
|
||||||
register_dev(std::move(new_proxy));
|
netlist().register_dev(std::move(new_proxy));
|
||||||
}
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
@ -472,7 +463,7 @@ void setup_t::connect_input_output(core_terminal_t &in, core_terminal_t &out)
|
|||||||
proxy->m_Q.net().register_con(in);
|
proxy->m_Q.net().register_con(in);
|
||||||
out.net().register_con(proxy->m_I);
|
out.net().register_con(proxy->m_I);
|
||||||
|
|
||||||
register_dev(std::move(proxy));
|
netlist().register_dev(std::move(proxy));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (out.is_logic() && in.is_analog())
|
else if (out.is_logic() && in.is_analog())
|
||||||
@ -515,7 +506,7 @@ void setup_t::connect_terminal_input(terminal_t &term, core_terminal_t &inp)
|
|||||||
else
|
else
|
||||||
proxy->m_Q.net().register_con(inp);
|
proxy->m_Q.net().register_con(inp);
|
||||||
|
|
||||||
register_dev(std::move(proxy));
|
netlist().register_dev(std::move(proxy));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -782,10 +773,63 @@ void setup_t::start_devices()
|
|||||||
auto nc = factory().factory_by_name("LOG")->Create(netlist(), name);
|
auto nc = factory().factory_by_name("LOG")->Create(netlist(), name);
|
||||||
register_link(name + ".I", ll);
|
register_link(name + ".I", ll);
|
||||||
log().debug(" dynamic link {1}: <{2}>\n",ll, name);
|
log().debug(" dynamic link {1}: <{2}>\n",ll, name);
|
||||||
register_dev(std::move(nc));
|
netlist().register_dev(std::move(nc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* make sure the solver and parameters are started first! */
|
||||||
|
|
||||||
|
for (auto & e : m_device_factory)
|
||||||
|
{
|
||||||
|
if ( factory().is_class<devices::NETLIB_NAME(mainclock)>(e.second)
|
||||||
|
|| factory().is_class<devices::NETLIB_NAME(solver)>(e.second)
|
||||||
|
|| factory().is_class<devices::NETLIB_NAME(gnd)>(e.second)
|
||||||
|
|| factory().is_class<devices::NETLIB_NAME(netlistparams)>(e.second))
|
||||||
|
{
|
||||||
|
auto dev = plib::owned_ptr<device_t>(e.second->Create(netlist(), e.first));
|
||||||
|
netlist().register_dev(std::move(dev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log().debug("Searching for mainclock and solver ...\n");
|
||||||
|
|
||||||
|
netlist().m_mainclock = netlist().get_single_device<devices::NETLIB_NAME(mainclock)>("mainclock");
|
||||||
|
netlist().m_solver = netlist().get_single_device<devices::NETLIB_NAME(solver)>("solver");
|
||||||
|
netlist().m_gnd = netlist().get_single_device<devices::NETLIB_NAME(gnd)>("gnd");
|
||||||
|
netlist().m_params = netlist().get_single_device<devices::NETLIB_NAME(netlistparams)>("parameter");
|
||||||
|
|
||||||
|
/* create devices */
|
||||||
|
|
||||||
|
for (auto & e : m_device_factory)
|
||||||
|
{
|
||||||
|
if ( !factory().is_class<devices::NETLIB_NAME(mainclock)>(e.second)
|
||||||
|
&& !factory().is_class<devices::NETLIB_NAME(solver)>(e.second)
|
||||||
|
&& !factory().is_class<devices::NETLIB_NAME(gnd)>(e.second)
|
||||||
|
&& !factory().is_class<devices::NETLIB_NAME(netlistparams)>(e.second))
|
||||||
|
{
|
||||||
|
auto dev = plib::owned_ptr<device_t>(e.second->Create(netlist(), e.first));
|
||||||
|
netlist().register_dev(std::move(dev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool use_deactivate = (netlist().m_params->m_use_deactivate.Value() ? true : false);
|
||||||
|
|
||||||
|
for (auto &d : netlist().m_devices)
|
||||||
|
{
|
||||||
|
if (use_deactivate)
|
||||||
|
{
|
||||||
|
auto p = m_param_values.find(d->name() + ".HINT_NO_DEACTIVATE");
|
||||||
|
if (p != m_param_values.end())
|
||||||
|
{
|
||||||
|
//FIXME: Error checking
|
||||||
|
auto v = p->second.as_long();
|
||||||
|
d->set_hint_deactivate(!v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
d->set_hint_deactivate(false);
|
||||||
|
}
|
||||||
|
|
||||||
netlist().start();
|
netlist().start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,6 @@ namespace netlist
|
|||||||
|
|
||||||
void register_term(core_terminal_t &obj);
|
void register_term(core_terminal_t &obj);
|
||||||
|
|
||||||
void register_dev(plib::owned_ptr<device_t> dev);
|
|
||||||
void register_dev(const pstring &classname, const pstring &name);
|
void register_dev(const pstring &classname, const pstring &name);
|
||||||
|
|
||||||
void register_lib_entry(const pstring &name);
|
void register_lib_entry(const pstring &name);
|
||||||
|
Loading…
Reference in New Issue
Block a user