summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-02-17 18:30:14 +0100
committer couriersud <couriersud@gmx.org>2019-02-17 18:30:34 +0100
commit1fe9f5e2e5cd05122a5600e43ccf7fed241df521 (patch)
tree70a7c9ca20de2fb25eb34877afa62f8904e2eab2
parent7d45dcec4efaf1ce3cb16afe7fa5cf885a67fcc4 (diff)
netlist: refactoring startup process and array usage. (nw)
-rw-r--r--src/devices/machine/netlist.cpp10
-rw-r--r--src/devices/machine/netlist.h7
-rw-r--r--src/lib/netlist/netlist_types.h2
-rw-r--r--src/lib/netlist/nl_base.h4
-rw-r--r--src/lib/netlist/nl_factory.h2
-rw-r--r--src/lib/netlist/nl_parser.h6
-rw-r--r--src/lib/netlist/nl_setup.cpp36
-rw-r--r--src/lib/netlist/nl_setup.h90
-rw-r--r--src/lib/netlist/plib/gmres.h19
-rw-r--r--src/lib/netlist/plib/parray.h6
10 files changed, 102 insertions, 80 deletions
diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp
index fcfa246910f..b05ae7b9625 100644
--- a/src/devices/machine/netlist.cpp
+++ b/src/devices/machine/netlist.cpp
@@ -213,7 +213,7 @@ private:
class netlist_source_memregion_t : public netlist::source_t
{
public:
- netlist_source_memregion_t(netlist::setup_t &setup, pstring name)
+ netlist_source_memregion_t(netlist::nlparse_t &setup, pstring name)
: netlist::source_t(setup), m_name(name)
{
}
@@ -238,7 +238,7 @@ public:
std::unique_ptr<plib::pistream> netlist_source_memregion_t::stream(const pstring &name)
{
- memory_region *mem = static_cast<netlist_mame_device::netlist_mame_t &>(setup().exec()).machine().root_device().memregion(m_name.c_str());
+ memory_region *mem = static_cast<netlist_mame_device::netlist_mame_t &>(setup().setup().exec()).machine().root_device().memregion(m_name.c_str());
return plib::make_unique<plib::pimemstream>(mem->base(), mem->bytes());
}
@@ -249,7 +249,7 @@ netlist_data_memregions_t::netlist_data_memregions_t(netlist::setup_t &setup)
std::unique_ptr<plib::pistream> netlist_data_memregions_t::stream(const pstring &name)
{
- memory_region *mem = static_cast<netlist_mame_device::netlist_mame_t &>(setup().exec()).parent().memregion(name.c_str());
+ memory_region *mem = static_cast<netlist_mame_device::netlist_mame_t &>(setup().setup().exec()).parent().memregion(name.c_str());
if (mem != nullptr)
{
return plib::make_unique<plib::pimemstream>(mem->base(), mem->bytes());
@@ -454,7 +454,7 @@ netlist::setup_t &netlist_mame_device::setup()
return m_netlist->nlstate().setup();
}
-void netlist_mame_device::register_memregion_source(netlist::setup_t &setup, const char *name)
+void netlist_mame_device::register_memregion_source(netlist::nlparse_t &setup, const char *name)
{
setup.register_source(plib::make_unique<netlist_source_memregion_t>(setup, pstring(name)));
}
@@ -826,7 +826,7 @@ netlist_mame_device::~netlist_mame_device()
LOGDEVCALLS("~netlist_mame_device\n");
}
-void netlist_mame_device::set_constructor(void (*setup_func)(netlist::setup_t &))
+void netlist_mame_device::set_constructor(void (*setup_func)(netlist::nlparse_t &))
{
if (LOG_DEV_CALLS) logerror("set_constructor\n");
m_setup_func = setup_func;
diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h
index 630bbabe42c..615f1fb1880 100644
--- a/src/devices/machine/netlist.h
+++ b/src/devices/machine/netlist.h
@@ -19,6 +19,7 @@ class nld_sound_in;
namespace netlist {
class setup_t;
+ class nlparse_t;
template <typename T>
class param_num_t;
class param_ptr_t;
@@ -105,7 +106,7 @@ public:
netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~netlist_mame_device();
- void set_constructor(void (*setup_func)(netlist::setup_t &));
+ void set_constructor(void (*setup_func)(netlist::nlparse_t &));
ATTR_HOT inline netlist::setup_t &setup();
ATTR_HOT inline netlist_mame_t &netlist() { return *m_netlist; }
@@ -113,7 +114,7 @@ public:
ATTR_HOT void update_icount(netlist::netlist_time time);
ATTR_HOT void check_mame_abort_slice();
- static void register_memregion_source(netlist::setup_t &setup, const char *name);
+ static void register_memregion_source(netlist::nlparse_t &setup, const char *name);
int m_icount;
@@ -144,7 +145,7 @@ private:
netlist::poolptr<netlist_mame_t> m_netlist;
- void (*m_setup_func)(netlist::setup_t &);
+ void (*m_setup_func)(netlist::nlparse_t &);
};
// ----------------------------------------------------------------------------------------
diff --git a/src/lib/netlist/netlist_types.h b/src/lib/netlist/netlist_types.h
index 5aec827491b..b2a507fe0fe 100644
--- a/src/lib/netlist/netlist_types.h
+++ b/src/lib/netlist/netlist_types.h
@@ -15,8 +15,8 @@
#include "nl_config.h"
#include "plib/pchrono.h"
#include "plib/pfmtlog.h"
-#include "plib/pstring.h"
#include "plib/pmempool.h"
+#include "plib/pstring.h"
namespace netlist
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index c9087a1f541..bee5ffe9b38 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -19,10 +19,10 @@
#include "plib/palloc.h" // owned_ptr
#include "plib/pdynlib.h"
#include "plib/pfmtlog.h"
+#include "plib/pmempool.h"
#include "plib/ppmf.h"
#include "plib/pstate.h"
#include "plib/pstream.h"
-#include "plib/pmempool.h"
#include "netlist_types.h"
#include "nl_errstr.h"
@@ -1454,7 +1454,9 @@ namespace netlist
private:
/* mostly rw */
+ PALIGNAS_CACHELINE()
netlist_time m_time;
+ PALIGNAS_CACHELINE()
devices::NETLIB_NAME(mainclock) * m_mainclock;
PALIGNAS_CACHELINE()
diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h
index 739f815ae1b..3ed98b19152 100644
--- a/src/lib/netlist/nl_factory.h
+++ b/src/lib/netlist/nl_factory.h
@@ -11,9 +11,9 @@
#include <vector>
+#include "netlist_types.h"
#include "plib/palloc.h"
#include "plib/ptypes.h"
-#include "netlist_types.h"
#define NETLIB_DEVICE_IMPL_ALIAS(p_alias, chip, p_name, p_def_param) \
NETLIB_DEVICE_IMPL_BASE(devices, p_alias, chip, p_name, p_def_param) \
diff --git a/src/lib/netlist/nl_parser.h b/src/lib/netlist/nl_parser.h
index 16075ca4914..92459c4b87b 100644
--- a/src/lib/netlist/nl_parser.h
+++ b/src/lib/netlist/nl_parser.h
@@ -17,7 +17,7 @@ namespace netlist
{
public:
template <typename T>
- parser_t(T &&strm, setup_t &setup)
+ parser_t(T &&strm, nlparse_t &setup)
: plib::ptokenizer(std::forward<T>(strm))
, m_setup(setup)
{
@@ -43,7 +43,7 @@ namespace netlist
void net_truthtable_start(const pstring &nlname);
/* for debugging messages */
- netlist_state_t &netlist() { return m_setup.netlist(); }
+ //netlist_state_t &netlist() { return m_setup.netlist(); }
void verror(const pstring &msg, int line_num, const pstring &line) override;
private:
@@ -72,7 +72,7 @@ namespace netlist
token_id_t m_tok_TT_LINE;
token_id_t m_tok_TT_FAMILY;
- setup_t &m_setup;
+ nlparse_t &m_setup;
};
} // namespace netlist
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index c791472086d..b8fba6f03aa 100644
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -25,9 +25,10 @@ namespace netlist
// nl_parse_t
// ----------------------------------------------------------------------------------------
- nlparse_t::nlparse_t(netlist_t &netlist)
- : m_factory(netlist.log())
- , m_log(netlist.log())
+ nlparse_t::nlparse_t(setup_t &setup, log_type &log)
+ : m_factory(log)
+ , m_setup(setup)
+ , m_log(log)
, m_frontier_cnt(0)
{ }
@@ -218,13 +219,27 @@ namespace netlist
return false;
}
+ bool nlparse_t::parse_stream(std::unique_ptr<plib::pistream> &&istrm, const pstring &name)
+ {
+ return parser_t(std::move(plib::ppreprocessor(&m_defines).process(std::move(istrm))), *this).parse(name);
+ }
+
+ void nlparse_t::add_define(const pstring &defstr)
+ {
+ auto p = defstr.find("=");
+ if (p != pstring::npos)
+ add_define(plib::left(defstr, p), defstr.substr(p+1));
+ else
+ add_define(defstr, "1");
+ }
+
// ----------------------------------------------------------------------------------------
// setup_t
// ----------------------------------------------------------------------------------------
setup_t::setup_t(netlist_t &netlist)
- : nlparse_t(netlist)
+ : nlparse_t(*this, netlist.log())
, m_netlist(netlist)
, m_netlist_params(nullptr)
, m_proxy_cnt(0)
@@ -971,11 +986,6 @@ const logic_family_desc_t *setup_t::family_from_model(const pstring &model)
// Sources
// ----------------------------------------------------------------------------------------
-bool setup_t::parse_stream(std::unique_ptr<plib::pistream> &&istrm, const pstring &name)
-{
- return parser_t(std::move(plib::ppreprocessor(&m_defines).process(std::move(istrm))), *this).parse(name);
-}
-
std::unique_ptr<plib::pistream> setup_t::get_data_stream(const pstring &name)
{
for (auto &source : m_sources)
@@ -991,14 +1001,6 @@ std::unique_ptr<plib::pistream> setup_t::get_data_stream(const pstring &name)
return std::unique_ptr<plib::pistream>(nullptr);
}
-void setup_t::add_define(const pstring &defstr)
-{
- auto p = defstr.find("=");
- if (p != pstring::npos)
- add_define(plib::left(defstr, p), defstr.substr(p+1));
- else
- add_define(defstr, "1");
-}
// ----------------------------------------------------------------------------------------
// Device handling
diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h
index 99539162970..bbffba1257a 100644
--- a/src/lib/netlist/nl_setup.h
+++ b/src/lib/netlist/nl_setup.h
@@ -28,41 +28,41 @@
#define NET_STR(x) # x
-#define NET_MODEL(model) \
+#define NET_MODEL(model) \
setup.register_model(model);
-#define ALIAS(alias, name) \
+#define ALIAS(alias, name) \
setup.register_alias(# alias, # name);
-#define DIPPINS(pin1, ...) \
+#define DIPPINS(pin1, ...) \
setup.register_dippins_arr( # pin1 ", " # __VA_ARGS__);
/* to be used to reference new library truthtable devices */
-#define NET_REGISTER_DEV(type, name) \
+#define NET_REGISTER_DEV(type, name) \
setup.register_dev(# type, # name);
-#define NET_CONNECT(name, input, output) \
+#define NET_CONNECT(name, input, output) \
setup.register_link(# name "." # input, # output);
-#define NET_C(term1, ...) \
+#define NET_C(term1, ...) \
setup.register_link_arr( # term1 ", " # __VA_ARGS__);
-#define PARAM(name, val) \
+#define PARAM(name, val) \
setup.register_param(# name, val);
#define HINT(name, val) \
setup.register_param(# name ".HINT_" # val, 1);
-#define NETDEV_PARAMI(name, param, val) \
+#define NETDEV_PARAMI(name, param, val) \
setup.register_param(# name "." # param, val);
#define NETLIST_NAME(name) netlist ## _ ## name
#define NETLIST_EXTERNAL(name) \
- void NETLIST_NAME(name)(netlist::setup_t &setup);
+ void NETLIST_NAME(name)(netlist::nlparse_t &setup);
#define NETLIST_START(name) \
-void NETLIST_NAME(name)(netlist::setup_t &setup) \
+void NETLIST_NAME(name)(netlist::nlparse_t &setup) \
{
#define NETLIST_END() }
@@ -81,7 +81,7 @@ void NETLIST_NAME(name)(netlist::setup_t &setup) \
NETLIST_NAME(model)(setup); \
setup.namespace_pop();
-#define OPTIMIZE_FRONTIER(attach, r_in, r_out) \
+#define OPTIMIZE_FRONTIER(attach, r_in, r_out) \
setup.register_frontier(# attach, r_in, r_out);
// -----------------------------------------------------------------------------
@@ -182,8 +182,9 @@ namespace netlist
using list_t = std::vector<std::unique_ptr<source_t>>;
- source_t(setup_t &setup, const type_t type = SOURCE)
- : m_setup(setup), m_type(type)
+ source_t(nlparse_t &setup, const type_t type = SOURCE)
+ : m_setup(setup)
+ , m_type(type)
{}
COPYASSIGNMOVE(source_t, delete)
@@ -191,14 +192,14 @@ namespace netlist
virtual ~source_t() noexcept = default;
virtual bool parse(const pstring &name);
- setup_t &setup() { return m_setup; }
+ nlparse_t &setup() { return m_setup; }
type_t type() const { return m_type; }
protected:
virtual std::unique_ptr<plib::pistream> stream(const pstring &name) = 0;
private:
- setup_t &m_setup;
+ nlparse_t &m_setup;
const type_t m_type;
};
@@ -211,7 +212,7 @@ namespace netlist
public:
using link_t = std::pair<pstring, pstring>;
- nlparse_t(netlist_t &netlist);
+ nlparse_t(setup_t &netlist, log_type &log);
void register_model(const pstring &model_in);
void register_alias(const pstring &alias, const pstring &out);
@@ -223,6 +224,13 @@ namespace netlist
void register_param(const pstring &param, const double value);
void register_lib_entry(const pstring &name, const pstring &sourcefile);
void register_frontier(const pstring &attach, const double r_IN, const double r_OUT);
+
+ /* register a source */
+ void register_source(std::unique_ptr<source_t> &&src)
+ {
+ m_sources.push_back(std::move(src));
+ }
+
void tt_factory_create(tt_desc &desc, const pstring &sourcefile);
/* handle namespace */
@@ -244,6 +252,31 @@ namespace netlist
/* used from netlist.cpp (mame) */
bool device_exists(const pstring &name) const;
+ /* FIXME: used by source_t - need a different approach at some time */
+ bool parse_stream(std::unique_ptr<plib::pistream> &&istrm, const pstring &name);
+
+ void add_define(pstring def, pstring val)
+ {
+ m_defines.insert({ def, plib::ppreprocessor::define_t(def, val)});
+ }
+
+ void add_define(const pstring &defstr);
+
+ factory::list_t &factory() { return m_factory; }
+ const factory::list_t &factory() const { return m_factory; }
+
+ log_type &log() { return m_log; }
+ const log_type &log() const { return m_log; }
+
+ /* FIXME: sources may need access to the netlist parent type
+ * since they may be created in a context in which they don't
+ * have access to their environment.
+ * Example is the MAME memregion source.
+ * We thus need a better approach to creating netlists in a context
+ * other than static procedures.
+ */
+ setup_t &setup() { return m_setup; }
+ const setup_t &setup() const { return m_setup; }
protected:
std::unordered_map<pstring, pstring> m_models;
std::stack<pstring> m_namespace_stack;
@@ -260,9 +293,9 @@ namespace netlist
private:
- log_type &log() { return m_log; }
- const log_type &log() const { return m_log; }
+ plib::ppreprocessor::defines_map_type m_defines;
+ setup_t &m_setup;
log_type &m_log;
unsigned m_frontier_cnt;
};
@@ -299,21 +332,6 @@ namespace netlist
std::unique_ptr<plib::pistream> get_data_stream(const pstring &name);
- bool parse_stream(std::unique_ptr<plib::pistream> &&istrm, const pstring &name);
-
- /* register a source */
-
- void register_source(std::unique_ptr<source_t> &&src)
- {
- m_sources.push_back(std::move(src));
- }
-
- void add_define(pstring def, pstring val)
- {
- m_defines.insert({ def, plib::ppreprocessor::define_t(def, val)});
- }
-
- void add_define(const pstring &defstr);
factory::list_t &factory() { return m_factory; }
const factory::list_t &factory() const { return m_factory; }
@@ -371,8 +389,6 @@ namespace netlist
devices::nld_netlistparams *m_netlist_params;
std::unordered_map<pstring, param_ref_t> m_params;
- plib::ppreprocessor::defines_map_type m_defines;
-
unsigned m_proxy_cnt;
};
@@ -430,7 +446,7 @@ namespace netlist
class source_proc_t : public source_t
{
public:
- source_proc_t(setup_t &setup, pstring name, void (*setup_func)(setup_t &))
+ source_proc_t(nlparse_t &setup, pstring name, void (*setup_func)(nlparse_t &))
: source_t(setup),
m_setup_func(setup_func),
m_setup_func_name(name)
@@ -443,7 +459,7 @@ namespace netlist
std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private:
- void (*m_setup_func)(setup_t &);
+ void (*m_setup_func)(nlparse_t &);
pstring m_setup_func_name;
};
diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h
index ecdc093ff17..edd15a49380 100644
--- a/src/lib/netlist/plib/gmres.h
+++ b/src/lib/netlist/plib/gmres.h
@@ -145,10 +145,10 @@ namespace plib
static constexpr const std::size_t storage_N = plib::sizeabs<FT, SIZE>::ABS();
gmres_t(std::size_t size)
- : m_use_more_precise_stop_condition(false)
- , residual(size)
+ : residual(size)
, Ax(size)
, m_size(size)
+ , m_use_more_precise_stop_condition(false)
{
}
@@ -326,24 +326,25 @@ namespace plib
private:
- bool m_use_more_precise_stop_condition;
-
//typedef typename plib::mat_cr_t<FT, SIZE>::index_type mattype;
plib::parray<float_type, SIZE> residual;
plib::parray<float_type, SIZE> Ax;
- std::array<float_type, RESTART + 1> m_c; /* mr + 1 */
- std::array<float_type, RESTART + 1> m_g; /* mr + 1 */
- std::array<std::array<float_type, RESTART>, RESTART + 1> m_ht; /* (mr + 1), mr */
- std::array<float_type, RESTART + 1> m_s; /* mr + 1 */
- std::array<float_type, RESTART + 1> m_y; /* mr + 1 */
+ plib::parray<float_type, RESTART + 1> m_c; /* mr + 1 */
+ plib::parray<float_type, RESTART + 1> m_g; /* mr + 1 */
+ plib::parray<plib::parray<float_type, RESTART>, RESTART + 1> m_ht; /* (mr + 1), mr */
+ plib::parray<float_type, RESTART + 1> m_s; /* mr + 1 */
+ plib::parray<float_type, RESTART + 1> m_y; /* mr + 1 */
//plib::parray<float_type, SIZE> m_v[RESTART + 1]; /* mr + 1, n */
std::array<std::array<float_type, storage_N>, RESTART + 1> m_v; /* mr + 1, n */
std::size_t m_size;
+ bool m_use_more_precise_stop_condition;
+
+
};
diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h
index 5fded97d1e9..662c2e9550e 100644
--- a/src/lib/netlist/plib/parray.h
+++ b/src/lib/netlist/plib/parray.h
@@ -66,11 +66,11 @@ namespace plib {
{
}
-#if 0
+#if 1
/* allow construction in fixed size arrays */
template <int X = SIZE >
- parray(typename std::enable_if<X==0, int>::type = 0)
- : m_size(0)
+ parray(typename std::enable_if<(X > 0), int>::type = 0)
+ : m_size(X)
{
}
#endif