trunk/src/emu/netlist/analog/nld_ms_direct.h
| r242958 | r242959 | |
| 69 | 69 | { |
| 70 | 70 | //delete[] m_A[k]; |
| 71 | 71 | } |
| 72 | | //delete[] m_last_RHS; |
| 72 | for (int k = 0; k < N(); k++) |
| 73 | { |
| 74 | nl_free(m_terms[k]); |
| 75 | nl_free(m_row_ops[k]); |
| 76 | } |
| 77 | nl_free(m_row_ops[N()]); |
| 78 | //delete[] m_last_RHS; |
| 73 | 79 | //delete[] m_RHS; |
| 74 | | delete[] m_terms; |
| 75 | | delete[] m_rails_temp; |
| 80 | nl_free_array(m_terms); |
| 81 | nl_free_array(m_rails_temp); |
| 76 | 82 | //delete[] m_row_ops; |
| 77 | 83 | |
| 78 | 84 | } |
| r242958 | r242959 | |
| 452 | 458 | , m_dim(size) |
| 453 | 459 | , m_lp_fact(0) |
| 454 | 460 | { |
| 455 | | m_terms = new terms_t *[N()]; |
| 456 | | m_rails_temp = new terms_t[N()]; |
| 461 | m_terms = nl_alloc_array(terms_t *, N()); |
| 462 | m_rails_temp = nl_alloc_array(terms_t, N()); |
| 457 | 463 | |
| 458 | 464 | for (int k = 0; k < N(); k++) |
| 459 | 465 | { |
| 460 | | m_terms[k] = new terms_t; |
| 466 | m_terms[k] = nl_alloc(terms_t); |
| 461 | 467 | m_row_ops[k] = vector_ops_t::create_ops(k); |
| 462 | 468 | } |
| 463 | 469 | m_row_ops[N()] = vector_ops_t::create_ops(N()); |
| r242958 | r242959 | |
| 469 | 475 | , m_dim(size) |
| 470 | 476 | , m_lp_fact(0) |
| 471 | 477 | { |
| 472 | | m_terms = new terms_t *[N()]; |
| 473 | | m_rails_temp = new terms_t[N()]; |
| 478 | m_terms = nl_alloc_array(terms_t *, N()); |
| 479 | m_rails_temp = nl_alloc_array(terms_t, N()); |
| 474 | 480 | |
| 475 | 481 | for (int k = 0; k < N(); k++) |
| 476 | 482 | { |
| 477 | | m_terms[k] = new terms_t; |
| 483 | m_terms[k] = nl_alloc(terms_t); |
| 478 | 484 | m_row_ops[k] = vector_ops_t::create_ops(k); |
| 479 | 485 | } |
| 480 | 486 | m_row_ops[N()] = vector_ops_t::create_ops(N()); |
trunk/src/emu/netlist/analog/nld_solver.c
| r242958 | r242959 | |
| 44 | 44 | switch (size) |
| 45 | 45 | { |
| 46 | 46 | case 1: |
| 47 | | return new vector_ops_impl_t<1>(); |
| 47 | return nl_alloc(vector_ops_impl_t<1>); |
| 48 | 48 | case 2: |
| 49 | | return new vector_ops_impl_t<2>(); |
| 49 | return nl_alloc(vector_ops_impl_t<2>); |
| 50 | 50 | case 3: |
| 51 | | return new vector_ops_impl_t<3>(); |
| 51 | return nl_alloc(vector_ops_impl_t<3>); |
| 52 | 52 | case 4: |
| 53 | | return new vector_ops_impl_t<4>(); |
| 53 | return nl_alloc(vector_ops_impl_t<4>); |
| 54 | 54 | case 5: |
| 55 | | return new vector_ops_impl_t<5>(); |
| 55 | return nl_alloc(vector_ops_impl_t<5>); |
| 56 | 56 | case 6: |
| 57 | | return new vector_ops_impl_t<6>(); |
| 57 | return nl_alloc(vector_ops_impl_t<6>); |
| 58 | 58 | case 7: |
| 59 | | return new vector_ops_impl_t<7>(); |
| 59 | return nl_alloc(vector_ops_impl_t<7>); |
| 60 | 60 | case 8: |
| 61 | | return new vector_ops_impl_t<8>(); |
| 61 | return nl_alloc(vector_ops_impl_t<8>); |
| 62 | 62 | case 9: |
| 63 | | return new vector_ops_impl_t<9>(); |
| 63 | return nl_alloc(vector_ops_impl_t<9>); |
| 64 | 64 | case 10: |
| 65 | | return new vector_ops_impl_t<10>(); |
| 65 | return nl_alloc(vector_ops_impl_t<10>); |
| 66 | 66 | case 11: |
| 67 | | return new vector_ops_impl_t<11>(); |
| 67 | return nl_alloc(vector_ops_impl_t<11>); |
| 68 | 68 | case 12: |
| 69 | | return new vector_ops_impl_t<12>(); |
| 69 | return nl_alloc(vector_ops_impl_t<12>); |
| 70 | 70 | default: |
| 71 | | return new vector_ops_impl_t<0>(size); |
| 71 | return nl_alloc(vector_ops_impl_t<0>, size); |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| r242958 | r242959 | |
| 91 | 91 | m_term[i]->m_Idr1 = &m_Idr[i]; |
| 92 | 92 | m_other_curanalog[i] = &m_term[i]->m_otherterm->net().as_analog().m_cur_Analog; |
| 93 | 93 | } |
| 94 | | |
| 95 | | m_ops = vector_ops_t::create_ops(m_gt.count()); |
| 96 | 94 | } |
| 97 | 95 | |
| 98 | 96 | // ---------------------------------------------------------------------------------------- |
| r242958 | r242959 | |
| 112 | 110 | ATTR_COLD netlist_matrix_solver_t::~netlist_matrix_solver_t() |
| 113 | 111 | { |
| 114 | 112 | for (int i = 0; i < m_inps.count(); i++) |
| 115 | | delete m_inps[i]; |
| 113 | global_free(m_inps[i]); |
| 116 | 114 | } |
| 117 | 115 | |
| 118 | 116 | ATTR_COLD void netlist_matrix_solver_t::setup(netlist_analog_net_t::list_t &nets) |
| r242958 | r242959 | |
| 176 | 174 | |
| 177 | 175 | if (net_proxy_output == NULL) |
| 178 | 176 | { |
| 179 | | net_proxy_output = new netlist_analog_output_t(); |
| 177 | net_proxy_output = nl_alloc(netlist_analog_output_t); |
| 180 | 178 | net_proxy_output->init_object(*this, this->name() + "." + pstring::sprintf("m%d", m_inps.count())); |
| 181 | 179 | m_inps.add(net_proxy_output); |
| 182 | 180 | net_proxy_output->m_proxied_net = &p->net().as_analog(); |
| r242958 | r242959 | |
| 380 | 378 | while (e != NULL) |
| 381 | 379 | { |
| 382 | 380 | netlist_matrix_solver_t * const *en = m_mat_solvers.next(e); |
| 383 | | delete *e; |
| 381 | global_free(*e); |
| 384 | 382 | e = en; |
| 385 | 383 | } |
| 386 | 384 | |
| r242958 | r242959 | |
| 435 | 433 | netlist_matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const int gs_threshold, const bool use_specific) |
| 436 | 434 | { |
| 437 | 435 | if (use_specific && m_N == 1) |
| 438 | | return new netlist_matrix_solver_direct1_t(m_params); |
| 436 | return nl_alloc(netlist_matrix_solver_direct1_t, m_params); |
| 439 | 437 | else if (use_specific && m_N == 2) |
| 440 | | return new netlist_matrix_solver_direct2_t(m_params); |
| 438 | return nl_alloc(netlist_matrix_solver_direct2_t, m_params); |
| 441 | 439 | else |
| 442 | 440 | { |
| 441 | typedef netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N> solver_N; |
| 443 | 442 | if (size >= gs_threshold) |
| 444 | | return new netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N>(m_params, size); |
| 443 | return nl_alloc(solver_N, m_params, size); |
| 445 | 444 | else |
| 446 | | return new netlist_matrix_solver_direct_t<m_N, _storage_N>(m_params, size); |
| 445 | return nl_alloc(solver_N, m_params, size); |
| 447 | 446 | } |
| 448 | 447 | } |
| 449 | 448 | |
trunk/src/emu/netlist/devices/net_lib.c
| r242958 | r242959 | |
| 49 | 49 | |
| 50 | 50 | #include "net_lib.h" |
| 51 | 51 | #include "nld_system.h" |
| 52 | #include "../nl_factory.h" |
| 52 | 53 | |
| 53 | 54 | NETLIST_START(diode_models) |
| 54 | 55 | NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") |
| r242958 | r242959 | |
| 64 | 65 | |
| 65 | 66 | |
| 66 | 67 | #define xstr(s) # s |
| 67 | | #define ENTRY1(_nic, _name, _defparam) register_device<_nic>( # _name, xstr(_nic), _defparam ); |
| 68 | #define ENTRY1(_nic, _name, _defparam) factory.register_device<_nic>( # _name, xstr(_nic), _defparam ); |
| 68 | 69 | #define ENTRY(_nic, _name, _defparam) ENTRY1(NETLIB_NAME(_nic), _name, _defparam) |
| 69 | 70 | |
| 70 | | netlist_factory_t::netlist_factory_t() |
| 71 | void nl_initialize_factory(netlist_factory_t &factory) |
| 71 | 72 | { |
| 72 | | } |
| 73 | | |
| 74 | | netlist_factory_t::~netlist_factory_t() |
| 75 | | { |
| 76 | | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 77 | | { |
| 78 | | net_device_t_base_factory *p = *e; |
| 79 | | delete p; |
| 80 | | } |
| 81 | | m_list.clear(); |
| 82 | | } |
| 83 | | |
| 84 | | void netlist_factory_t::initialize() |
| 85 | | { |
| 86 | 73 | ENTRY(R, RES, "R") |
| 87 | 74 | ENTRY(POT, POT, "R") |
| 88 | 75 | ENTRY(C, CAP, "C") |
| r242958 | r242959 | |
| 162 | 149 | ENTRY(NE555_dip, NE555_DIP, "-") |
| 163 | 150 | } |
| 164 | 151 | |
| 165 | | netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const |
| 166 | | { |
| 167 | | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 168 | | { |
| 169 | | net_device_t_base_factory *p = *e; |
| 170 | | if (strcmp(p->classname(), classname) == 0) |
| 171 | | { |
| 172 | | netlist_device_t *ret = p->Create(); |
| 173 | | return ret; |
| 174 | | } |
| 175 | | p++; |
| 176 | | } |
| 177 | | setup.netlist().error("Class %s not found!\n", classname.cstr()); |
| 178 | | return NULL; // appease code analysis |
| 179 | | } |
| 180 | | |
| 181 | | netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const |
| 182 | | { |
| 183 | | net_device_t_base_factory *f = factory_by_name(name, setup); |
| 184 | | return f->Create(); |
| 185 | | } |
| 186 | | |
| 187 | | net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const |
| 188 | | { |
| 189 | | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 190 | | { |
| 191 | | net_device_t_base_factory *p = *e; |
| 192 | | if (strcmp(p->name(), name) == 0) |
| 193 | | { |
| 194 | | return p; |
| 195 | | } |
| 196 | | p++; |
| 197 | | } |
| 198 | | setup.netlist().error("Class %s not found!\n", name.cstr()); |
| 199 | | return NULL; // appease code analysis |
| 200 | | } |
trunk/src/emu/netlist/nl_base.h
| r242958 | r242959 | |
| 1370 | 1370 | } |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | | |
| 1374 | | // ----------------------------------------------------------------------------- |
| 1375 | | // net_dev class factory |
| 1376 | | // ----------------------------------------------------------------------------- |
| 1377 | | |
| 1378 | | class net_device_t_base_factory |
| 1379 | | { |
| 1380 | | NETLIST_PREVENT_COPYING(net_device_t_base_factory) |
| 1381 | | public: |
| 1382 | | ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname, |
| 1383 | | const pstring &def_param) |
| 1384 | | : m_name(name), m_classname(classname), m_def_param(def_param) |
| 1385 | | {} |
| 1386 | | |
| 1387 | | ATTR_COLD virtual ~net_device_t_base_factory() {} |
| 1388 | | |
| 1389 | | ATTR_COLD virtual netlist_device_t *Create() const = 0; |
| 1390 | | |
| 1391 | | ATTR_COLD const pstring &name() const { return m_name; } |
| 1392 | | ATTR_COLD const pstring &classname() const { return m_classname; } |
| 1393 | | ATTR_COLD const pstring ¶m_desc() const { return m_def_param; } |
| 1394 | | ATTR_COLD const nl_util::pstring_list term_param_list(); |
| 1395 | | ATTR_COLD const nl_util::pstring_list def_params(); |
| 1396 | | |
| 1397 | | protected: |
| 1398 | | pstring m_name; /* device name */ |
| 1399 | | pstring m_classname; /* device class name */ |
| 1400 | | pstring m_def_param; /* default parameter */ |
| 1401 | | }; |
| 1402 | | |
| 1403 | | template <class C> |
| 1404 | | class net_device_t_factory : public net_device_t_base_factory |
| 1405 | | { |
| 1406 | | NETLIST_PREVENT_COPYING(net_device_t_factory) |
| 1407 | | public: |
| 1408 | | ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname, |
| 1409 | | const pstring &def_param) |
| 1410 | | : net_device_t_base_factory(name, classname, def_param) { } |
| 1411 | | |
| 1412 | | ATTR_COLD netlist_device_t *Create() const |
| 1413 | | { |
| 1414 | | netlist_device_t *r = new C(); |
| 1415 | | //r->init(setup, name); |
| 1416 | | return r; |
| 1417 | | } |
| 1418 | | }; |
| 1419 | | |
| 1420 | | class netlist_factory_t |
| 1421 | | { |
| 1422 | | public: |
| 1423 | | typedef plinearlist_t<net_device_t_base_factory *> list_t; |
| 1424 | | |
| 1425 | | ATTR_COLD netlist_factory_t(); |
| 1426 | | ATTR_COLD ~netlist_factory_t(); |
| 1427 | | |
| 1428 | | ATTR_COLD void initialize(); |
| 1429 | | |
| 1430 | | template<class _C> |
| 1431 | | ATTR_COLD void register_device(const pstring &name, const pstring &classname, |
| 1432 | | const pstring &def_param) |
| 1433 | | { |
| 1434 | | m_list.add(new net_device_t_factory< _C >(name, classname, def_param) ); |
| 1435 | | } |
| 1436 | | |
| 1437 | | ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const; |
| 1438 | | ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const; |
| 1439 | | ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const; |
| 1440 | | |
| 1441 | | const list_t &list() { return m_list; } |
| 1442 | | |
| 1443 | | private: |
| 1444 | | list_t m_list; |
| 1445 | | |
| 1446 | | }; |
| 1447 | | |
| 1448 | | |
| 1449 | 1373 | #endif /* NLBASE_H_ */ |
trunk/src/emu/netlist/nl_config.h
| r242958 | r242959 | |
| 109 | 109 | // this macro passes an item followed by a string version of itself as two consecutive parameters |
| 110 | 110 | #define NLNAME(x) x, #x |
| 111 | 111 | |
| 112 | //============================================================ |
| 113 | // Exceptions |
| 114 | //============================================================ |
| 115 | |
| 112 | 116 | // emu_fatalerror is a generic fatal exception that provides an error string |
| 113 | 117 | class nl_fatalerror : public std::exception |
| 114 | 118 | { |
| r242958 | r242959 | |
| 130 | 134 | } |
| 131 | 135 | }; |
| 132 | 136 | |
| 137 | //============================================================ |
| 138 | // Memory allocation |
| 139 | //============================================================ |
| 140 | |
| 141 | #define nl_alloc(T, ...) global_alloc(T(__VA_ARGS__)) |
| 142 | #define nl_alloc_array(T, N) global_alloc_array(T, N) |
| 143 | |
| 144 | #define nl_free(_ptr) global_free(_ptr) |
| 145 | #define nl_free_array(_ptr) global_free_array(_ptr) |
| 146 | |
| 147 | |
| 148 | //============================================================ |
| 149 | // Asserts |
| 150 | //============================================================ |
| 151 | |
| 133 | 152 | #ifdef MAME_DEBUG |
| 134 | 153 | #define nl_assert(x) do { if (!(x)) throw nl_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) |
| 135 | 154 | #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) |
trunk/src/emu/netlist/nl_factory.c
| r0 | r242959 | |
| 1 | // license:GPL-2.0+ |
| 2 | // copyright-holders:Couriersud |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | nl_factory.c |
| 6 | |
| 7 | Discrete netlist implementation. |
| 8 | |
| 9 | **************************************************************************** |
| 10 | |
| 11 | Couriersud reserves the right to license the code under a less restrictive |
| 12 | license going forward. |
| 13 | |
| 14 | Copyright Nicola Salmoria and the MAME team |
| 15 | All rights reserved. |
| 16 | |
| 17 | Redistribution and use of this code or any derivative works are permitted |
| 18 | provided that the following conditions are met: |
| 19 | |
| 20 | * Redistributions may not be sold, nor may they be used in a commercial |
| 21 | product or activity. |
| 22 | |
| 23 | * Redistributions that are modified from the original source must include the |
| 24 | complete source code, including the source code for all components used by a |
| 25 | binary built from the modified sources. However, as a special exception, the |
| 26 | source code distributed need not include anything that is normally distributed |
| 27 | (in either source or binary form) with the major components (compiler, kernel, |
| 28 | and so on) of the operating system on which the executable runs, unless that |
| 29 | component itself accompanies the executable. |
| 30 | |
| 31 | * Redistributions must reproduce the above copyright notice, this list of |
| 32 | conditions and the following disclaimer in the documentation and/or other |
| 33 | materials provided with the distribution. |
| 34 | |
| 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 36 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 37 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 38 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 39 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 40 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 41 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 42 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 43 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 44 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 45 | POSSIBILITY OF SUCH DAMAGE. |
| 46 | |
| 47 | |
| 48 | ****************************************************************************/ |
| 49 | |
| 50 | #include "nl_factory.h" |
| 51 | #include "nl_setup.h" |
| 52 | |
| 53 | netlist_factory_t::netlist_factory_t() |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | netlist_factory_t::~netlist_factory_t() |
| 58 | { |
| 59 | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 60 | { |
| 61 | net_device_t_base_factory *p = *e; |
| 62 | global_free(p); |
| 63 | } |
| 64 | m_list.clear(); |
| 65 | } |
| 66 | |
| 67 | netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const |
| 68 | { |
| 69 | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 70 | { |
| 71 | net_device_t_base_factory *p = *e; |
| 72 | if (strcmp(p->classname(), classname) == 0) |
| 73 | { |
| 74 | netlist_device_t *ret = p->Create(); |
| 75 | return ret; |
| 76 | } |
| 77 | p++; |
| 78 | } |
| 79 | setup.netlist().error("Class %s not found!\n", classname.cstr()); |
| 80 | return NULL; // appease code analysis |
| 81 | } |
| 82 | |
| 83 | netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const |
| 84 | { |
| 85 | net_device_t_base_factory *f = factory_by_name(name, setup); |
| 86 | return f->Create(); |
| 87 | } |
| 88 | |
| 89 | net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const |
| 90 | { |
| 91 | for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e)) |
| 92 | { |
| 93 | net_device_t_base_factory *p = *e; |
| 94 | if (strcmp(p->name(), name) == 0) |
| 95 | { |
| 96 | return p; |
| 97 | } |
| 98 | p++; |
| 99 | } |
| 100 | setup.netlist().error("Class %s not found!\n", name.cstr()); |
| 101 | return NULL; // appease code analysis |
| 102 | } |
trunk/src/emu/netlist/nl_factory.h
| r0 | r242959 | |
| 1 | // license:GPL-2.0+ |
| 2 | // copyright-holders:Couriersud |
| 3 | /* |
| 4 | * nl_factory.h |
| 5 | * |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef NLFACTORY_H_ |
| 10 | #define NLFACTORY_H_ |
| 11 | |
| 12 | #include "nl_config.h" |
| 13 | #include "plists.h" |
| 14 | #include "nl_base.h" |
| 15 | #if 0 |
| 16 | #include "nl_time.h" |
| 17 | #include "nl_util.h" |
| 18 | #include "pstate.h" |
| 19 | #endif |
| 20 | #include "pstring.h" |
| 21 | |
| 22 | // ----------------------------------------------------------------------------- |
| 23 | // net_dev class factory |
| 24 | // ----------------------------------------------------------------------------- |
| 25 | |
| 26 | class net_device_t_base_factory |
| 27 | { |
| 28 | NETLIST_PREVENT_COPYING(net_device_t_base_factory) |
| 29 | public: |
| 30 | ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname, |
| 31 | const pstring &def_param) |
| 32 | : m_name(name), m_classname(classname), m_def_param(def_param) |
| 33 | {} |
| 34 | |
| 35 | ATTR_COLD virtual ~net_device_t_base_factory() {} |
| 36 | |
| 37 | ATTR_COLD virtual netlist_device_t *Create() const = 0; |
| 38 | |
| 39 | ATTR_COLD const pstring &name() const { return m_name; } |
| 40 | ATTR_COLD const pstring &classname() const { return m_classname; } |
| 41 | ATTR_COLD const pstring ¶m_desc() const { return m_def_param; } |
| 42 | ATTR_COLD const nl_util::pstring_list term_param_list(); |
| 43 | ATTR_COLD const nl_util::pstring_list def_params(); |
| 44 | |
| 45 | protected: |
| 46 | pstring m_name; /* device name */ |
| 47 | pstring m_classname; /* device class name */ |
| 48 | pstring m_def_param; /* default parameter */ |
| 49 | }; |
| 50 | |
| 51 | template <class C> |
| 52 | class net_device_t_factory : public net_device_t_base_factory |
| 53 | { |
| 54 | NETLIST_PREVENT_COPYING(net_device_t_factory) |
| 55 | public: |
| 56 | ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname, |
| 57 | const pstring &def_param) |
| 58 | : net_device_t_base_factory(name, classname, def_param) { } |
| 59 | |
| 60 | ATTR_COLD netlist_device_t *Create() const |
| 61 | { |
| 62 | netlist_device_t *r = nl_alloc(C); |
| 63 | //r->init(setup, name); |
| 64 | return r; |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | class netlist_factory_t |
| 69 | { |
| 70 | public: |
| 71 | typedef plinearlist_t<net_device_t_base_factory *> list_t; |
| 72 | |
| 73 | ATTR_COLD netlist_factory_t(); |
| 74 | ATTR_COLD ~netlist_factory_t(); |
| 75 | |
| 76 | template<class _C> |
| 77 | ATTR_COLD void register_device(const pstring &name, const pstring &classname, |
| 78 | const pstring &def_param) |
| 79 | { |
| 80 | m_list.add(nl_alloc(net_device_t_factory< _C >, name, classname, def_param)); |
| 81 | } |
| 82 | |
| 83 | ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const; |
| 84 | ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const; |
| 85 | ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const; |
| 86 | |
| 87 | const list_t &list() { return m_list; } |
| 88 | |
| 89 | private: |
| 90 | list_t m_list; |
| 91 | |
| 92 | }; |
| 93 | |
| 94 | |
| 95 | #endif /* NLFACTORY_H_ */ |
trunk/src/emu/netlist/nl_setup.c
| r242958 | r242959 | |
| 41 | 41 | |
| 42 | 42 | void netlist_setup_t::init() |
| 43 | 43 | { |
| 44 | | m_factory.initialize(); |
| 44 | nl_initialize_factory(factory()); |
| 45 | 45 | NETLIST_NAME(base)(*this); |
| 46 | 46 | } |
| 47 | 47 | |
| r242958 | r242959 | |
| 390 | 390 | if (proxy == NULL) |
| 391 | 391 | { |
| 392 | 392 | // create a new one ... |
| 393 | | proxy = new nld_d_to_a_proxy(out); |
| 393 | proxy = nl_alloc(nld_d_to_a_proxy ,out); |
| 394 | 394 | pstring x = pstring::sprintf("proxy_da_%s_%d", out.name().cstr(), m_proxy_cnt); |
| 395 | 395 | m_proxy_cnt++; |
| 396 | 396 | |
| r242958 | r242959 | |
| 419 | 419 | { |
| 420 | 420 | if (out.isFamily(netlist_terminal_t::ANALOG) && in.isFamily(netlist_terminal_t::LOGIC)) |
| 421 | 421 | { |
| 422 | | nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(in); |
| 422 | nld_a_to_d_proxy *proxy = nl_alloc(nld_a_to_d_proxy, in); |
| 423 | 423 | pstring x = pstring::sprintf("proxy_ad_%s_%d", in.name().cstr(), m_proxy_cnt); |
| 424 | 424 | m_proxy_cnt++; |
| 425 | 425 | |
| r242958 | r242959 | |
| 455 | 455 | else if (inp.isFamily(netlist_terminal_t::LOGIC)) |
| 456 | 456 | { |
| 457 | 457 | NL_VERBOSE_OUT(("connect_terminal_input: connecting proxy\n")); |
| 458 | | nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(inp); |
| 458 | nld_a_to_d_proxy *proxy = nl_alloc(nld_a_to_d_proxy, inp); |
| 459 | 459 | pstring x = pstring::sprintf("proxy_ad_%s_%d", inp.name().cstr(), m_proxy_cnt); |
| 460 | 460 | m_proxy_cnt++; |
| 461 | 461 | |
| r242958 | r242959 | |
| 523 | 523 | else |
| 524 | 524 | { |
| 525 | 525 | NL_VERBOSE_OUT(("adding net ...\n")); |
| 526 | | netlist_analog_net_t *anet = new netlist_analog_net_t(); |
| 526 | netlist_analog_net_t *anet = nl_alloc(netlist_analog_net_t); |
| 527 | 527 | t1.set_net(*anet); |
| 528 | 528 | //m_netlist.solver()->m_nets.add(anet); |
| 529 | 529 | // FIXME: Nets should have a unique name |
trunk/src/emu/netlist/plists.h
| r242958 | r242959 | |
| 28 | 28 | if (m_num_elements == 0) |
| 29 | 29 | m_list = NULL; |
| 30 | 30 | else |
| 31 | | m_list = new _ListClass[m_num_elements]; |
| 31 | m_list = nl_alloc_array(_ListClass, m_num_elements); |
| 32 | 32 | m_count = 0; |
| 33 | 33 | } |
| 34 | 34 | |
| r242958 | r242959 | |
| 38 | 38 | if (m_num_elements == 0) |
| 39 | 39 | m_list = NULL; |
| 40 | 40 | else |
| 41 | | m_list = new _ListClass[m_num_elements]; |
| 41 | m_list = nl_alloc_array(_ListClass, m_num_elements); |
| 42 | 42 | m_count = 0; |
| 43 | 43 | for (int i=0; i<rhs.count(); i++) |
| 44 | 44 | { |
| r242958 | r242959 | |
| 60 | 60 | ATTR_COLD ~plinearlist_t() |
| 61 | 61 | { |
| 62 | 62 | if (m_list != NULL) |
| 63 | | delete[] m_list; |
| 63 | nl_free_array(m_list); |
| 64 | 64 | m_list = NULL; |
| 65 | 65 | } |
| 66 | 66 | |
| r242958 | r242959 | |
| 157 | 157 | { |
| 158 | 158 | for (_ListClass *i = m_list; i < m_list + m_count; i++) |
| 159 | 159 | { |
| 160 | | delete *i; |
| 160 | nl_free(*i); |
| 161 | 161 | } |
| 162 | 162 | clear(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | private: |
| 166 | | ATTR_HOT inline void resize(const int new_size) |
| 166 | ATTR_COLD void resize(const int new_size) |
| 167 | 167 | { |
| 168 | 168 | int cnt = count(); |
| 169 | 169 | if (new_size > 0) |
| 170 | 170 | { |
| 171 | | _ListClass *m_new = new _ListClass[new_size]; |
| 171 | _ListClass *m_new = nl_alloc_array(_ListClass, new_size); |
| 172 | 172 | _ListClass *pd = m_new; |
| 173 | 173 | |
| 174 | 174 | if (cnt > new_size) |
| r242958 | r242959 | |
| 176 | 176 | for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++) |
| 177 | 177 | *pd = *ps; |
| 178 | 178 | if (m_list != NULL) |
| 179 | | delete[] m_list; |
| 179 | nl_free_array(m_list); |
| 180 | 180 | m_list = m_new; |
| 181 | 181 | m_count = cnt; |
| 182 | 182 | } |
| 183 | 183 | else |
| 184 | 184 | { |
| 185 | 185 | if (m_list != NULL) |
| 186 | | delete[] m_list; |
| 186 | nl_free_array(m_list); |
| 187 | 187 | m_list = NULL; |
| 188 | 188 | m_count = 0; |
| 189 | 189 | } |
trunk/src/emu/netlist/pstate.c
| r242958 | r242959 | |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | 29 | NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr)); |
| 30 | | pstate_entry_t *p = new pstate_entry_t(stname, dt, owner, size, count, ptr, is_ptr); |
| 30 | pstate_entry_t *p = nl_alloc(pstate_entry_t, stname, dt, owner, size, count, ptr, is_ptr); |
| 31 | 31 | m_save.add(p); |
| 32 | 32 | } |
| 33 | 33 | |
| r242958 | r242959 | |
| 60 | 60 | if (m_save[i]->m_dt == DT_CUSTOM) |
| 61 | 61 | m_save[i]->m_callback->on_post_load(); |
| 62 | 62 | } |
| 63 | |
| 64 | template<> ATTR_COLD void pstate_manager_t::save_item(pstate_callback_t &state, const void *owner, const pstring &stname) |
| 65 | { |
| 66 | //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state); |
| 67 | pstate_entry_t *p = nl_alloc(pstate_entry_t, stname, owner, &state); |
| 68 | m_save.add(p); |
| 69 | state.register_state(*this, stname); |
| 70 | } |