trunk/src/emu/machine/netlist.c
| r242980 | r242981 | |
| 48 | 48 | #include "netlist.h" |
| 49 | 49 | #include "netlist/nl_base.h" |
| 50 | 50 | #include "netlist/nl_setup.h" |
| 51 | #include "netlist/nl_factory.h" |
| 51 | 52 | #include "netlist/devices/net_lib.h" |
| 52 | 53 | #include "debugger.h" |
| 53 | 54 | |
| r242980 | r242981 | |
| 134 | 135 | pstring dname = "OUT_" + m_in; |
| 135 | 136 | m_delegate.bind_relative_to(owner()->machine().root_device()); |
| 136 | 137 | NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>( |
| 137 | | setup.factory().new_device_by_classname("nld_analog_callback", setup)); |
| 138 | setup.register_dev("nld_analog_callback", dname)); |
| 138 | 139 | |
| 139 | | setup.register_dev(dev, dname); |
| 140 | 140 | dev->register_callback(m_delegate); |
| 141 | 141 | setup.register_link(dname + ".IN", m_in); |
| 142 | 142 | } |
| r242980 | r242981 | |
| 208 | 208 | { |
| 209 | 209 | NETLIB_NAME(sound_in) *snd_in = setup.netlist().get_first_device<NETLIB_NAME(sound_in)>(); |
| 210 | 210 | if (snd_in == NULL) |
| 211 | | { |
| 212 | | snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.factory().new_device_by_classname("nld_sound_in", setup)); |
| 213 | | setup.register_dev(snd_in, "STREAM_INPUT"); |
| 214 | | } |
| 211 | snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.register_dev("nld_sound_in", "STREAM_INPUT")); |
| 215 | 212 | |
| 216 | 213 | pstring sparam = pstring::sprintf("STREAM_INPUT.CHAN%d", m_channel); |
| 217 | 214 | setup.register_param(sparam, m_param_name); |
| r242980 | r242981 | |
| 247 | 244 | |
| 248 | 245 | void netlist_mame_stream_output_t::custom_netlist_additions(netlist_setup_t &setup) |
| 249 | 246 | { |
| 250 | | NETLIB_NAME(sound_out) *snd_out; |
| 247 | //NETLIB_NAME(sound_out) *snd_out; |
| 251 | 248 | pstring sname = pstring::sprintf("STREAM_OUT_%d", m_channel); |
| 252 | 249 | |
| 253 | | snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.factory().new_device_by_classname("nld_sound_out", setup)); |
| 254 | | setup.register_dev(snd_out, sname); |
| 250 | //snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.register_dev("nld_sound_out", sname)); |
| 251 | setup.register_dev("nld_sound_out", sname); |
| 255 | 252 | |
| 256 | 253 | setup.register_param(sname + ".CHAN" , m_channel); |
| 257 | 254 | setup.register_param(sname + ".MULT", m_mult); |
trunk/src/emu/netlist/nl_base.c
| r242980 | r242981 | |
| 1002 | 1002 | net.set_time(netlist().time() + m_inc); |
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | | // ---------------------------------------------------------------------------------------- |
| 1006 | | // net_device_t_base_factory |
| 1007 | | // ---------------------------------------------------------------------------------------- |
| 1008 | | |
| 1009 | | ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list() |
| 1010 | | { |
| 1011 | | if (m_def_param.startsWith("+")) |
| 1012 | | return nl_util::split(m_def_param.substr(1), ","); |
| 1013 | | else |
| 1014 | | return nl_util::pstring_list(); |
| 1015 | | } |
| 1016 | | |
| 1017 | | ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params() |
| 1018 | | { |
| 1019 | | if (m_def_param.startsWith("+") || m_def_param.equals("-")) |
| 1020 | | return nl_util::pstring_list(); |
| 1021 | | else |
| 1022 | | return nl_util::split(m_def_param, ","); |
| 1023 | | } |
trunk/src/emu/netlist/nl_config.h
| r242980 | r242981 | |
| 159 | 159 | #else |
| 160 | 160 | #define nl_assert(x) do { } while (0) |
| 161 | 161 | //#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) |
| 162 | | #define nl_assert_always(x, msg) do { } while (0) |
| 162 | #define nl_assert_always(x, msg) do { if (!(x)) throw nl_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0) |
| 163 | 163 | #endif |
| 164 | 164 | |
| 165 | 165 | //============================================================ |
trunk/src/emu/netlist/nl_dice_compat.h
| r242980 | r242981 | |
| 8 | 8 | #ifndef NL_DICE_COMPAT_H_ |
| 9 | 9 | #define NL_DICE_COMPAT_H_ |
| 10 | 10 | |
| 11 | #include "netlist/devices/net_lib.h" |
| 12 | |
| 11 | 13 | /* -------------------------------------------------------------------- |
| 12 | 14 | * Compatibility macros for DICE netlists ... |
| 13 | 15 | * -------------------------------------------------------------------- */ |
| 14 | 16 | |
| 15 | | //#define CHIP(_n, _t) netlist.register_dev(NET_NEW(_t ## _dip), _n); |
| 17 | /* |
| 18 | * define NETLIST_DEVELOPMENT in IDEs before including this header file |
| 19 | * to get compile time errors on unknown devices. This should only be |
| 20 | * a temporary support and not be used in commits. |
| 21 | */ |
| 22 | |
| 23 | #ifdef NETLIST_DEVELOPMENT |
| 16 | 24 | #define CHIP(_n, _t) setup.register_dev( nl_alloc(nld_ ## _t ## _dip), _n); |
| 25 | #else |
| 26 | #define CHIP(_n, _t) setup.register_dev(NETLIB_NAME_STR(_t ## _dip), _n); |
| 27 | #endif |
| 17 | 28 | |
| 18 | 29 | #define CONNECTION( ... ) CONNECTIONY( CONNECTIONX( __VA_ARGS__ ) ) |
| 19 | 30 | #define CONNECTIONY(_a) _a |
trunk/src/emu/netlist/nl_factory.c
| r242980 | r242981 | |
| 50 | 50 | #include "nl_factory.h" |
| 51 | 51 | #include "nl_setup.h" |
| 52 | 52 | |
| 53 | // ---------------------------------------------------------------------------------------- |
| 54 | // net_device_t_base_factory |
| 55 | // ---------------------------------------------------------------------------------------- |
| 56 | |
| 57 | ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list() |
| 58 | { |
| 59 | if (m_def_param.startsWith("+")) |
| 60 | return nl_util::split(m_def_param.substr(1), ","); |
| 61 | else |
| 62 | return nl_util::pstring_list(); |
| 63 | } |
| 64 | |
| 65 | ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params() |
| 66 | { |
| 67 | if (m_def_param.startsWith("+") || m_def_param.equals("-")) |
| 68 | return nl_util::pstring_list(); |
| 69 | else |
| 70 | return nl_util::split(m_def_param, ","); |
| 71 | } |
| 72 | |
| 73 | |
| 53 | 74 | netlist_factory_t::netlist_factory_t() |
| 54 | 75 | { |
| 55 | 76 | } |
| r242980 | r242981 | |
| 64 | 85 | m_list.clear(); |
| 65 | 86 | } |
| 66 | 87 | |
| 67 | | netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const |
| 88 | netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname) const |
| 68 | 89 | { |
| 69 | 90 | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 70 | 91 | { |
| r242980 | r242981 | |
| 76 | 97 | } |
| 77 | 98 | p++; |
| 78 | 99 | } |
| 79 | | setup.netlist().error("Class %s not found!\n", classname.cstr()); |
| 80 | 100 | return NULL; // appease code analysis |
| 81 | 101 | } |
| 82 | 102 | |
trunk/src/emu/netlist/nl_setup.c
| r242980 | r242981 | |
| 9 | 9 | #include "nl_setup.h" |
| 10 | 10 | #include "nl_parser.h" |
| 11 | 11 | #include "nl_util.h" |
| 12 | #include "nl_factory.h" |
| 12 | 13 | #include "devices/net_lib.h" |
| 13 | 14 | #include "devices/nld_system.h" |
| 14 | 15 | #include "analog/nld_solver.h" |
| r242980 | r242981 | |
| 37 | 38 | , m_proxy_cnt(0) |
| 38 | 39 | { |
| 39 | 40 | netlist.set_setup(this); |
| 41 | m_factory = nl_alloc(netlist_factory_t); |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | 44 | void netlist_setup_t::init() |
| r242980 | r242981 | |
| 55 | 57 | m_params_temp.clear(); |
| 56 | 58 | |
| 57 | 59 | netlist().set_setup(NULL); |
| 60 | nl_free(m_factory); |
| 58 | 61 | |
| 59 | 62 | pstring::resetmem(); |
| 60 | 63 | } |
| r242980 | r242981 | |
| 92 | 95 | return dev; |
| 93 | 96 | } |
| 94 | 97 | |
| 98 | netlist_device_t *netlist_setup_t::register_dev(const pstring &classname, const pstring &name) |
| 99 | { |
| 100 | netlist_device_t *dev = factory().new_device_by_classname(classname); |
| 101 | if (dev == NULL) |
| 102 | netlist().error("Class %s not found!\n", classname.cstr()); |
| 103 | return register_dev(dev, name); |
| 104 | } |
| 105 | |
| 95 | 106 | template <class T> |
| 96 | 107 | static void remove_start_with(T &hm, pstring &sw) |
| 97 | 108 | { |
| r242980 | r242981 | |
| 695 | 706 | { |
| 696 | 707 | NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); |
| 697 | 708 | NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); |
| 698 | | netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this); |
| 709 | netlist_device_t *nc = factory().new_device_by_classname("nld_log"); |
| 699 | 710 | pstring name = "log_" + ll[i]; |
| 700 | 711 | register_dev(nc, name); |
| 701 | 712 | register_link(name + ".I", ll[i]); |
trunk/src/emu/netlist/nl_setup.h
| r242980 | r242981 | |
| 3 | 3 | /* |
| 4 | 4 | * nlsetup.h |
| 5 | 5 | * |
| 6 | | * Created on: 3 Nov 2013 |
| 7 | | * Author: andre |
| 8 | 6 | */ |
| 9 | 7 | |
| 10 | 8 | #ifndef NLSETUP_H_ |
| 11 | 9 | #define NLSETUP_H_ |
| 12 | 10 | |
| 13 | 11 | #include "nl_base.h" |
| 14 | | #include "nl_factory.h" |
| 12 | //#include "nl_factory.h" |
| 15 | 13 | |
| 16 | 14 | //============================================================ |
| 17 | 15 | // MACROS / inline netlist definitions |
| r242980 | r242981 | |
| 25 | 23 | #define ALIAS(_alias, _name) \ |
| 26 | 24 | setup.register_alias(# _alias, # _name); |
| 27 | 25 | |
| 28 | | #define NET_NEW(_type) setup.factory().new_device_by_classname(NETLIB_NAME_STR(_type), setup) |
| 26 | //#define NET_NEW(_type) setup.factory().new_device_by_classname(NETLIB_NAME_STR(_type), setup) |
| 29 | 27 | |
| 30 | 28 | #define NET_REGISTER_DEV(_type, _name) \ |
| 31 | | setup.register_dev(NET_NEW(_type), # _name); |
| 29 | setup.register_dev(NETLIB_NAME_STR(_type), # _name); |
| 32 | 30 | |
| 33 | 31 | #define NET_REMOVE_DEV(_name) \ |
| 34 | 32 | setup.remove_dev(# _name); |
| r242980 | r242981 | |
| 67 | 65 | setup.namespace_pop(); |
| 68 | 66 | |
| 69 | 67 | // ---------------------------------------------------------------------------------------- |
| 70 | | // FIXME: Clean this up |
| 71 | | // ---------------------------------------------------------------------------------------- |
| 72 | | |
| 73 | | //class NETLIB_NAME(analog_callback); |
| 74 | | |
| 75 | | // ---------------------------------------------------------------------------------------- |
| 76 | 68 | // netlist_setup_t |
| 77 | 69 | // ---------------------------------------------------------------------------------------- |
| 78 | 70 | |
| 71 | // Forward definition so we keep nl_factory.h out of the public |
| 72 | class netlist_factory_t; |
| 73 | |
| 79 | 74 | class netlist_setup_t |
| 80 | 75 | { |
| 81 | 76 | NETLIST_PREVENT_COPYING(netlist_setup_t) |
| r242980 | r242981 | |
| 118 | 113 | |
| 119 | 114 | netlist_base_t &netlist() { return m_netlist; } |
| 120 | 115 | const netlist_base_t &netlist() const { return m_netlist; } |
| 121 | | netlist_factory_t &factory() { return m_factory; } |
| 122 | | const netlist_factory_t &factory() const { return m_factory; } |
| 123 | 116 | |
| 124 | 117 | pstring build_fqn(const pstring &obj_name) const; |
| 125 | 118 | |
| 126 | 119 | netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name); |
| 120 | netlist_device_t *register_dev(const pstring &classname, const pstring &name); |
| 127 | 121 | void remove_dev(const pstring &name); |
| 128 | 122 | |
| 129 | 123 | void register_model(const pstring &model); |
| r242980 | r242981 | |
| 152 | 146 | void namespace_push(const pstring &aname); |
| 153 | 147 | void namespace_pop(); |
| 154 | 148 | |
| 155 | | /* not ideal, but needed for save_state */ |
| 156 | | tagmap_terminal_t m_terminals; |
| 149 | netlist_factory_t &factory() { return *m_factory; } |
| 150 | const netlist_factory_t &factory() const { return *m_factory; } |
| 157 | 151 | |
| 158 | | void print_stats() const; |
| 152 | /* not ideal, but needed for save_state */ |
| 153 | tagmap_terminal_t m_terminals; |
| 159 | 154 | |
| 155 | void print_stats() const; |
| 156 | |
| 160 | 157 | protected: |
| 161 | 158 | |
| 162 | 159 | private: |
| r242980 | r242981 | |
| 168 | 165 | tagmap_link_t m_links; |
| 169 | 166 | tagmap_nstring_t m_params_temp; |
| 170 | 167 | |
| 171 | | netlist_factory_t m_factory; |
| 168 | netlist_factory_t *m_factory; |
| 172 | 169 | |
| 173 | 170 | plinearlist_t<pstring> m_models; |
| 174 | 171 | |