diff options
Diffstat (limited to 'src/lib/netlist/nl_setup.h')
-rw-r--r-- | src/lib/netlist/nl_setup.h | 90 |
1 files changed, 53 insertions, 37 deletions
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 ¶m, 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; }; |