trunk/src/emu/netlist/devices/nld_truthtable.h
| r242945 | r242946 | |
| 50 | 50 | { |
| 51 | 51 | nl_util::pstring_list io = nl_util::split(ttline,"|"); |
| 52 | 52 | // checks |
| 53 | | assert(io.count() == 2); |
| 53 | nl_assert(io.count() == 2); |
| 54 | 54 | nl_util::pstring_list inout = nl_util::split(io[0], ","); |
| 55 | | assert(inout.count() == m_num_bits); |
| 55 | nl_assert(inout.count() == m_num_bits); |
| 56 | 56 | nl_util::pstring_list out = nl_util::split(io[1], ","); |
| 57 | | assert(out.count() == m_NO); |
| 57 | nl_assert(out.count() == m_NO); |
| 58 | 58 | |
| 59 | 59 | for (int i=0; i < m_NI; i++) |
| 60 | 60 | { |
| r242945 | r242946 | |
| 133 | 133 | { |
| 134 | 134 | nl_util::pstring_list io = nl_util::split(ttline,"|"); |
| 135 | 135 | // checks |
| 136 | | assert(io.count() == 3); |
| 136 | nl_assert(io.count() == 3); |
| 137 | 137 | nl_util::pstring_list inout = nl_util::split(io[0], ","); |
| 138 | | assert(inout.count() == m_num_bits); |
| 138 | nl_assert(inout.count() == m_num_bits); |
| 139 | 139 | nl_util::pstring_list out = nl_util::split(io[1], ","); |
| 140 | | assert(out.count() == m_NO); |
| 140 | nl_assert(out.count() == m_NO); |
| 141 | 141 | nl_util::pstring_list times = nl_util::split(io[2], ","); |
| 142 | | assert(times.count() == m_NO); |
| 142 | nl_assert(times.count() == m_NO); |
| 143 | 143 | |
| 144 | 144 | UINT16 val = 0; |
| 145 | 145 | UINT8 tindex[m_NO]; |
trunk/src/emu/netlist/nl_base.c
| r242945 | r242946 | |
| 9 | 9 | #include "pstring.h" |
| 10 | 10 | #include "nl_util.h" |
| 11 | 11 | |
| 12 | #include <stdlib.h> // FIXME: only included for atof |
| 13 | |
| 12 | 14 | const netlist_time netlist_time::zero = netlist_time::from_raw(0); |
| 13 | 15 | |
| 14 | 16 | netlist_logic_family_desc_t netlist_family_TTL = |
| r242945 | r242946 | |
| 164 | 166 | ATTR_COLD void netlist_base_t::save_register() |
| 165 | 167 | { |
| 166 | 168 | save(static_cast<pstate_callback_t &>(m_queue), "m_queue"); |
| 167 | | save(NAME(m_time)); |
| 169 | save(NLNAME(m_time)); |
| 168 | 170 | netlist_object_t::save_register(); |
| 169 | 171 | } |
| 170 | 172 | |
| r242945 | r242946 | |
| 529 | 531 | |
| 530 | 532 | ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr) |
| 531 | 533 | { |
| 532 | | assert(m_railterminal == NULL); |
| 534 | nl_assert(m_railterminal == NULL); |
| 533 | 535 | m_railterminal = &mr; |
| 534 | 536 | } |
| 535 | 537 | |
| r242945 | r242946 | |
| 545 | 547 | |
| 546 | 548 | ATTR_COLD void netlist_net_t::save_register() |
| 547 | 549 | { |
| 548 | | save(NAME(m_time)); |
| 549 | | save(NAME(m_active)); |
| 550 | | save(NAME(m_in_queue)); |
| 551 | | save(NAME(m_cur_Analog)); |
| 552 | | save(NAME(m_cur_Q)); |
| 553 | | save(NAME(m_new_Q)); |
| 550 | save(NLNAME(m_time)); |
| 551 | save(NLNAME(m_active)); |
| 552 | save(NLNAME(m_in_queue)); |
| 553 | save(NLNAME(m_cur_Analog)); |
| 554 | save(NLNAME(m_cur_Q)); |
| 555 | save(NLNAME(m_new_Q)); |
| 554 | 556 | netlist_object_t::save_register(); |
| 555 | 557 | } |
| 556 | 558 | |
| r242945 | r242946 | |
| 569 | 571 | ATTR_HOT ATTR_ALIGN inline void netlist_net_t::update_devs() |
| 570 | 572 | { |
| 571 | 573 | //assert(m_num_cons != 0); |
| 572 | | assert(this->isRailNet()); |
| 574 | nl_assert(this->isRailNet()); |
| 573 | 575 | |
| 574 | 576 | const UINT32 masks[4] = { 1, 5, 3, 1 }; |
| 575 | 577 | const UINT32 mask = masks[ (m_cur_Q << 1) | m_new_Q ]; |
| r242945 | r242946 | |
| 707 | 709 | |
| 708 | 710 | ATTR_COLD void netlist_analog_net_t::save_register() |
| 709 | 711 | { |
| 710 | | save(NAME(m_DD_n_m_1)); |
| 711 | | save(NAME(m_h_n_m_1)); |
| 712 | save(NLNAME(m_DD_n_m_1)); |
| 713 | save(NLNAME(m_h_n_m_1)); |
| 712 | 714 | netlist_net_t::save_register(); |
| 713 | 715 | } |
| 714 | 716 | |
| r242945 | r242946 | |
| 803 | 805 | |
| 804 | 806 | ATTR_COLD void netlist_terminal_t::save_register() |
| 805 | 807 | { |
| 806 | | save(NAME(m_Idr1)); |
| 807 | | save(NAME(m_go1)); |
| 808 | | save(NAME(m_gt1)); |
| 808 | save(NLNAME(m_Idr1)); |
| 809 | save(NLNAME(m_go1)); |
| 810 | save(NLNAME(m_gt1)); |
| 809 | 811 | netlist_core_terminal_t::save_register(); |
| 810 | 812 | } |
| 811 | 813 | |
trunk/src/emu/netlist/nl_base.h
| r242945 | r242946 | |
| 444 | 444 | ATTR_HOT inline const state_e state() const { return m_state; } |
| 445 | 445 | ATTR_HOT inline void set_state(const state_e astate) |
| 446 | 446 | { |
| 447 | | assert(astate != STATE_NONEX); |
| 447 | nl_assert(astate != STATE_NONEX); |
| 448 | 448 | m_state = astate; |
| 449 | 449 | } |
| 450 | 450 | |
| r242945 | r242946 | |
| 453 | 453 | protected: |
| 454 | 454 | ATTR_COLD virtual void save_register() |
| 455 | 455 | { |
| 456 | | save(NAME(m_state)); |
| 456 | save(NLNAME(m_state)); |
| 457 | 457 | netlist_owned_object_t::save_register(); |
| 458 | 458 | } |
| 459 | 459 | |
| r242945 | r242946 | |
| 710 | 710 | */ |
| 711 | 711 | ATTR_COLD inline netlist_sig_t &Q_state_ptr() |
| 712 | 712 | { |
| 713 | | assert(family() == LOGIC); |
| 713 | nl_assert(family() == LOGIC); |
| 714 | 714 | return m_cur_Q; |
| 715 | 715 | } |
| 716 | 716 | |
| r242945 | r242946 | |
| 738 | 738 | |
| 739 | 739 | ATTR_HOT inline const double Q_Analog() const |
| 740 | 740 | { |
| 741 | | //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 742 | | assert(family() == ANALOG); |
| 741 | //nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 742 | nl_assert(family() == ANALOG); |
| 743 | 743 | return m_cur_Analog; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | ATTR_COLD inline double &Q_Analog_state_ptr() |
| 747 | 747 | { |
| 748 | | //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 749 | | assert(family() == ANALOG); |
| 748 | //nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); |
| 749 | nl_assert(family() == ANALOG); |
| 750 | 750 | return m_cur_Analog; |
| 751 | 751 | } |
| 752 | 752 | |
| r242945 | r242946 | |
| 883 | 883 | protected: |
| 884 | 884 | ATTR_COLD virtual void save_register() |
| 885 | 885 | { |
| 886 | | save(NAME(m_param)); |
| 886 | save(NLNAME(m_param)); |
| 887 | 887 | netlist_param_t::save_register(); |
| 888 | 888 | } |
| 889 | 889 | |
| r242945 | r242946 | |
| 905 | 905 | protected: |
| 906 | 906 | ATTR_COLD virtual void save_register() |
| 907 | 907 | { |
| 908 | | save(NAME(m_param)); |
| 908 | save(NLNAME(m_param)); |
| 909 | 909 | netlist_param_t::save_register(); |
| 910 | 910 | } |
| 911 | 911 | |
| r242945 | r242946 | |
| 988 | 988 | |
| 989 | 989 | ATTR_HOT inline const netlist_sig_t INPLOGIC(const netlist_logic_input_t &inp) const |
| 990 | 990 | { |
| 991 | | assert(inp.state() != netlist_input_t::STATE_INP_PASSIVE); |
| 991 | nl_assert(inp.state() != netlist_input_t::STATE_INP_PASSIVE); |
| 992 | 992 | return inp.Q(); |
| 993 | 993 | } |
| 994 | 994 | |
| r242945 | r242946 | |
| 1262 | 1262 | |
| 1263 | 1263 | ATTR_HOT inline netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() |
| 1264 | 1264 | { |
| 1265 | | assert(family() == LOGIC); |
| 1265 | nl_assert(family() == LOGIC); |
| 1266 | 1266 | return static_cast<netlist_logic_net_t &>(*this); |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | ATTR_HOT inline const netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() const |
| 1270 | 1270 | { |
| 1271 | | assert(family() == LOGIC); |
| 1271 | nl_assert(family() == LOGIC); |
| 1272 | 1272 | return static_cast<const netlist_logic_net_t &>(*this); |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | ATTR_HOT inline netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() |
| 1276 | 1276 | { |
| 1277 | | assert(family() == ANALOG); |
| 1277 | nl_assert(family() == ANALOG); |
| 1278 | 1278 | return static_cast<netlist_analog_net_t &>(*this); |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | ATTR_HOT inline const netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() const |
| 1282 | 1282 | { |
| 1283 | | assert(family() == ANALOG); |
| 1283 | nl_assert(family() == ANALOG); |
| 1284 | 1284 | return static_cast<const netlist_analog_net_t &>(*this); |
| 1285 | 1285 | } |
| 1286 | 1286 | |
trunk/src/emu/netlist/nl_config.h
| r242945 | r242946 | |
| 10 | 10 | |
| 11 | 11 | /* FIXME: at some time, make it compile on it's own */ |
| 12 | 12 | |
| 13 | | #include "emu.h" |
| 13 | #include "osdcore.h" |
| 14 | #include "corealloc.h" |
| 15 | #include <math.h> |
| 16 | #include <exception> |
| 17 | #include <typeinfo> |
| 14 | 18 | |
| 15 | 19 | //============================================================ |
| 16 | 20 | // SETUP |
| r242945 | r242946 | |
| 102 | 106 | #define end_timing(v) do { } while (0) |
| 103 | 107 | #endif |
| 104 | 108 | |
| 109 | // this macro passes an item followed by a string version of itself as two consecutive parameters |
| 110 | #define NLNAME(x) x, #x |
| 105 | 111 | |
| 112 | // emu_fatalerror is a generic fatal exception that provides an error string |
| 113 | class nl_fatalerror : public std::exception |
| 114 | { |
| 115 | public: |
| 116 | nl_fatalerror(const char *format, ...) ATTR_PRINTF(2,3) |
| 117 | { |
| 118 | char text[1024]; |
| 119 | va_list ap; |
| 120 | va_start(ap, format); |
| 121 | vsprintf(text, format, ap); |
| 122 | va_end(ap); |
| 123 | osd_printf_error("%s\n", text); |
| 124 | } |
| 125 | nl_fatalerror(const char *format, va_list ap) |
| 126 | { |
| 127 | char text[1024]; |
| 128 | vsprintf(text, format, ap); |
| 129 | osd_printf_error("%s\n", text); |
| 130 | } |
| 131 | }; |
| 132 | |
| 133 | #ifdef MAME_DEBUG |
| 134 | #define nl_assert(x) do { if (!(x)) throw nl_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) |
| 135 | #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) |
| 136 | #else |
| 137 | #define nl_assert(x) do { } while (0) |
| 138 | //#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) |
| 139 | #define nl_assert_always(x, msg) do { } while (0) |
| 140 | #endif |
| 141 | |
| 106 | 142 | //============================================================ |
| 107 | 143 | // Compiling standalone |
| 108 | 144 | //============================================================ |
| r242945 | r242946 | |
| 110 | 146 | // Compiling without mame ? |
| 111 | 147 | |
| 112 | 148 | #ifndef ATTR_HOT |
| 113 | | //#warning ATTR_HOT not defined |
| 149 | #warning ATTR_HOT not defined |
| 114 | 150 | |
| 115 | 151 | // standard C includes |
| 116 | 152 | #include <math.h> |
| r242945 | r242946 | |
| 132 | 168 | #define UNEXPECTED |
| 133 | 169 | #define ATTR_UNUSED __attribute__((__unused__)) |
| 134 | 170 | |
| 135 | | // this macro passes an item followed by a string version of itself as two consecutive parameters |
| 136 | | #define NAME(x) x, #x |
| 137 | | |
| 138 | 171 | /* 8-bit values */ |
| 139 | 172 | typedef unsigned char UINT8; |
| 140 | 173 | typedef signed char INT8; |
| r242945 | r242946 | |
| 160 | 193 | #endif |
| 161 | 194 | #endif |
| 162 | 195 | |
| 163 | | #ifdef MAME_DEBUG |
| 164 | | #define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) |
| 165 | | #define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0) |
| 166 | | #else |
| 167 | | #define assert(x) do { } while (0) |
| 168 | | //#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) |
| 169 | | #define assert_always(x, msg) do { } while (0) |
| 170 | | #endif |
| 171 | | |
| 172 | 196 | /* U64 and S64 are used to wrap long integer constants. */ |
| 173 | 197 | #if defined(__GNUC__) || defined(_MSC_VER) |
| 174 | 198 | #define U64(val) val##ULL |
trunk/src/emu/netlist/nl_setup.c
| r242945 | r242946 | |
| 14 | 14 | #include "analog/nld_solver.h" |
| 15 | 15 | #include "analog/nld_twoterm.h" |
| 16 | 16 | |
| 17 | //FIXME: we need a nl_getenv |
| 18 | #include <stdlib.h> |
| 19 | |
| 17 | 20 | static NETLIST_START(base) |
| 18 | 21 | TTL_INPUT(ttlhigh, 1) |
| 19 | 22 | TTL_INPUT(ttllow, 0) |
| r242945 | r242946 | |
| 378 | 381 | |
| 379 | 382 | nld_base_d_to_a_proxy *netlist_setup_t::get_d_a_proxy(netlist_output_t &out) |
| 380 | 383 | { |
| 381 | | assert(out.isFamily(netlist_terminal_t::LOGIC)); |
| 384 | nl_assert(out.isFamily(netlist_terminal_t::LOGIC)); |
| 382 | 385 | |
| 383 | 386 | //printf("proxy for %s\n", out.name().cstr());; |
| 384 | 387 | netlist_logic_output_t &out_cast = dynamic_cast<netlist_logic_output_t &>(out); |
| r242945 | r242946 | |
| 499 | 502 | |
| 500 | 503 | void netlist_setup_t::connect_terminals(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2) |
| 501 | 504 | { |
| 502 | | //assert(in.isType(netlist_terminal_t::TERMINAL)); |
| 503 | | //assert(out.isType(netlist_terminal_t::TERMINAL)); |
| 505 | //nl_assert(in.isType(netlist_terminal_t::TERMINAL)); |
| 506 | //nl_assert(out.isType(netlist_terminal_t::TERMINAL)); |
| 504 | 507 | |
| 505 | 508 | if (t1.has_net() && t2.has_net()) |
| 506 | 509 | { |
| r242945 | r242946 | |
| 683 | 686 | |
| 684 | 687 | void netlist_setup_t::start_devices() |
| 685 | 688 | { |
| 689 | //FIXME: we need a nl_getenv |
| 686 | 690 | if (getenv("NL_LOGS")) |
| 687 | 691 | { |
| 688 | 692 | NL_VERBOSE_OUT(("Creating dynamic logs ...\n")); |
trunk/src/emu/netlist/plists.h
| r242945 | r242946 | |
| 108 | 108 | |
| 109 | 109 | ATTR_HOT inline void remove_at(const int pos) |
| 110 | 110 | { |
| 111 | | assert((pos>=0) && (pos<m_count)); |
| 111 | nl_assert((pos>=0) && (pos<m_count)); |
| 112 | 112 | m_count--; |
| 113 | 113 | for (int i = pos; i < m_count; i++) |
| 114 | 114 | { |
| r242945 | r242946 | |
| 118 | 118 | |
| 119 | 119 | ATTR_HOT inline void swap(const int pos1, const int pos2) |
| 120 | 120 | { |
| 121 | | assert((pos1>=0) && (pos1<m_count)); |
| 122 | | assert((pos2>=0) && (pos2<m_count)); |
| 121 | nl_assert((pos1>=0) && (pos1<m_count)); |
| 122 | nl_assert((pos2>=0) && (pos2<m_count)); |
| 123 | 123 | _ListClass tmp = m_list[pos1]; |
| 124 | 124 | m_list[pos1] = m_list[pos2]; |
| 125 | 125 | m_list[pos2] =tmp; |
| r242945 | r242946 | |
| 331 | 331 | } |
| 332 | 332 | p = p->m_next; |
| 333 | 333 | } |
| 334 | | assert_always(false, "element not found"); |
| 334 | nl_assert_always(false, "element not found"); |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| r242945 | r242946 | |
| 357 | 357 | _ListClass **p = &m_head; |
| 358 | 358 | while (*p != &elem) |
| 359 | 359 | { |
| 360 | | assert(*p != NULL); |
| 360 | nl_assert(*p != NULL); |
| 361 | 361 | p = &((*p)->m_next); |
| 362 | 362 | } |
| 363 | 363 | (*p) = elem.m_next; |