diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 4374ef2212d..dfd07bdd8f2 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -568,7 +568,7 @@ void netlist_t::print_stats() const } } -core_device_t *netlist_t::pget_single_device(const pstring classname, bool (*cc)(core_device_t *)) +core_device_t *netlist_t::get_single_device(const pstring classname, bool (*cc)(core_device_t *)) { core_device_t *ret = nullptr; for (auto &d : m_devices) @@ -772,7 +772,7 @@ void detail::net_t::update_devs() NL_NOEXCEPT { nl_assert(this->isRailNet()); - static const unsigned masks[4] = + const unsigned masks[4] = { 0, core_terminal_t::STATE_INP_LH | core_terminal_t::STATE_INP_ACTIVE, @@ -780,10 +780,10 @@ void detail::net_t::update_devs() NL_NOEXCEPT 0 }; - const unsigned mask = masks[ m_cur_Q * 2 + m_new_Q ]; + const unsigned mask = masks[ (m_cur_Q << 1) | m_new_Q ]; - m_in_queue = 2; /* mark as taken ... */ m_cur_Q = m_new_Q; + m_in_queue = 2; /* mark as taken ... */ for (auto & p : m_list_active) { @@ -1199,4 +1199,26 @@ std::unique_ptr param_data_t::stream() } //namespace devices + + bool detail::core_terminal_t::is_logic() const NL_NOEXCEPT + { + return dynamic_cast(this) != nullptr; + } + + bool detail::core_terminal_t::is_analog() const NL_NOEXCEPT + { + return dynamic_cast(this) != nullptr; + } + + bool detail::net_t::is_logic() const NL_NOEXCEPT + { + return dynamic_cast(this) != nullptr; + } + + bool detail::net_t::is_analog() const NL_NOEXCEPT + { + return dynamic_cast(this) != nullptr; + } + + } // namespace netlist diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index e56a10b9e20..d6e177be9c9 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -316,15 +316,15 @@ namespace netlist //! Move Constructor. state_var(state_var &&rhs) NL_NOEXCEPT = default; //! Assignment operator to assign value of a state var. - state_var &operator=(const state_var &rhs) { m_value = rhs; return *this; } + state_var &operator=(const state_var &rhs) NL_NOEXCEPT { m_value = rhs; return *this; } //! Assignment operator to assign value of type T. - state_var &operator=(const T &rhs) { m_value = rhs; return *this; } + state_var &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; } //! Return value of state variable. - operator T & () { return m_value; } + operator T & () NL_NOEXCEPT { return m_value; } //! Return const value of state variable. - constexpr operator const T & () const { return m_value; } + constexpr operator const T & () const NL_NOEXCEPT { return m_value; } T * ptr() { return &m_value; } - constexpr T * ptr() const { return &m_value; } + constexpr T * ptr() const NL_NOEXCEPT{ return &m_value; } private: T m_value; }; @@ -347,10 +347,10 @@ namespace netlist state_var(const state_var &rhs) NL_NOEXCEPT = default; //! Move Constructor. state_var(state_var &&rhs) NL_NOEXCEPT = default; - state_var &operator=(const state_var &rhs) { m_value = rhs.m_value; return *this; } - state_var &operator=(const T &rhs) { m_value = rhs; return *this; } - T & operator[](const std::size_t i) { return m_value[i]; } - constexpr T & operator[](const std::size_t i) const { return m_value[i]; } + state_var &operator=(const state_var &rhs) NL_NOEXCEPT { m_value = rhs.m_value; return *this; } + state_var &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; } + T & operator[](const std::size_t i) NL_NOEXCEPT { return m_value[i]; } + constexpr T & operator[](const std::size_t i) const NL_NOEXCEPT { return m_value[i]; } private: T m_value[N]; }; @@ -443,7 +443,7 @@ namespace netlist /*! returns reference to owning device. * \returns reference to owning device. */ - core_device_t &device() const { return m_device; } + core_device_t &device() const NL_NOEXCEPT { return m_device; } /*! The netlist owning the owner of this object. * \returns reference to netlist object. @@ -495,17 +495,17 @@ namespace netlist void set_net(net_t *anet); void clear_net(); - bool has_net() const { return (m_net != nullptr); } + bool has_net() const NL_NOEXCEPT { return (m_net != nullptr); } - const net_t & net() const { return *m_net;} - net_t & net() { return *m_net;} + const net_t & net() const NL_NOEXCEPT { return *m_net;} + net_t & net() NL_NOEXCEPT { return *m_net;} bool is_logic() const NL_NOEXCEPT; bool is_analog() const NL_NOEXCEPT; - bool is_state(const state_e astate) const { return (m_state == astate); } - state_e state() const { return m_state; } - void set_state(const state_e astate) { m_state = astate; } + bool is_state(const state_e astate) const NL_NOEXCEPT { return (m_state == astate); } + state_e state() const NL_NOEXCEPT { return m_state; } + void set_state(const state_e astate) NL_NOEXCEPT { m_state = astate; } void reset(); @@ -666,7 +666,7 @@ namespace netlist /*! returns voltage at terminal. * \returns voltage at terminal. */ - nl_double operator()() const { return Q_Analog(); } + nl_double operator()() const NL_NOEXCEPT { return Q_Analog(); } /*! returns voltage at terminal. * \returns voltage at terminal. @@ -690,17 +690,17 @@ namespace netlist void reset(); - void toggle_new_Q() { m_new_Q ^= 1; } - void force_queue_execution() { m_new_Q = (m_cur_Q ^ 1); } + void toggle_new_Q() NL_NOEXCEPT { m_new_Q ^= 1; } + void force_queue_execution() NL_NOEXCEPT { m_new_Q = (m_cur_Q ^ 1); } void push_to_queue(const netlist_time delay) NL_NOEXCEPT; void reschedule_in_queue(const netlist_time delay) NL_NOEXCEPT; - bool is_queued() const { return m_in_queue == 1; } + bool is_queued() const NL_NOEXCEPT { return m_in_queue == 1; } void update_devs() NL_NOEXCEPT; - const netlist_time time() const { return m_time; } - void set_time(const netlist_time ntime) { m_time = ntime; } + const netlist_time time() const NL_NOEXCEPT { return m_time; } + void set_time(const netlist_time ntime) NL_NOEXCEPT { m_time = ntime; } bool isRailNet() const { return !(m_railterminal == nullptr); } core_terminal_t & railterminal() const { return *m_railterminal; } @@ -748,9 +748,9 @@ namespace netlist logic_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr); virtual ~logic_net_t(); - netlist_sig_t Q() const { return m_cur_Q; } - netlist_sig_t new_Q() const { return m_new_Q; } - void initial(const netlist_sig_t val) { m_cur_Q = m_new_Q = val; } + netlist_sig_t Q() const NL_NOEXCEPT { return m_cur_Q; } + netlist_sig_t new_Q() const NL_NOEXCEPT { return m_new_Q; } + void initial(const netlist_sig_t val) NL_NOEXCEPT { m_cur_Q = m_new_Q = val; } void set_Q(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT { @@ -1027,8 +1027,6 @@ namespace netlist m_stat_total_time.stop(); } - void set_delegate_pointer(); - void do_inc_active() NL_NOEXCEPT { if (m_hint_deactivate) @@ -1047,6 +1045,8 @@ namespace netlist void do_reset() { reset(); } void set_hint_deactivate(bool v) { m_hint_deactivate = v; } + void set_delegate_pointer(); + /* stats */ nperftime_t m_stat_total_time; nperfcount_t m_stat_call_count; @@ -1232,7 +1232,7 @@ namespace netlist template C *get_single_device(const pstring classname) { - return dynamic_cast(pget_single_device(classname, check_class)); + return dynamic_cast(get_single_device(classname, check_class)); } /* logging and name */ @@ -1254,8 +1254,6 @@ namespace netlist this->state().save_state_ptr(static_cast(&owner), from_utf8(owner.name()) + pstring(".") + stname, plib::state_manager_t::datatype_f::f(), count, state); } - void rebuild_lists(); /* must be called after post_load ! */ - plib::dynlib &lib() { return *m_lib; } // FIXME: find something better @@ -1264,7 +1262,11 @@ namespace netlist /* sole use is to manage lifetime of family objects */ std::vector>> m_family_cache; + // FIXME: sort rebuild_lists out + void rebuild_lists(); /* must be called after post_load ! */ + protected: + void print_stats() const; private: @@ -1273,7 +1275,7 @@ namespace netlist static pstring from_utf8(const char *c) { return pstring(c, pstring::UTF8); } static pstring from_utf8(const pstring &c) { return c; } - core_device_t *pget_single_device(const pstring classname, bool (*cc)(core_device_t *)); + core_device_t *get_single_device(const pstring classname, bool (*cc)(core_device_t *)); /* mostly rw */ netlist_time m_time; @@ -1333,26 +1335,6 @@ namespace netlist device.netlist().log().warning("Rom {1} not found", Value()); } - inline bool detail::core_terminal_t::is_logic() const NL_NOEXCEPT - { - return dynamic_cast(this) != nullptr; - } - - inline bool detail::core_terminal_t::is_analog() const NL_NOEXCEPT - { - return dynamic_cast(this) != nullptr; - } - - inline bool detail::net_t::is_logic() const NL_NOEXCEPT - { - return dynamic_cast(this) != nullptr; - } - - inline bool detail::net_t::is_analog() const NL_NOEXCEPT - { - return dynamic_cast(this) != nullptr; - } - inline void logic_input_t::inactivate() { if (!is_state(STATE_INP_PASSIVE)) @@ -1453,6 +1435,16 @@ namespace netlist } } + inline netlist_t &detail::device_object_t::netlist() + { + return m_device.netlist(); + } + + inline const netlist_t &detail::device_object_t::netlist() const + { + return m_device.netlist(); + } + template template state_var::state_var(O &owner, const pstring name, const T &value) @@ -1470,15 +1462,6 @@ namespace netlist m_value[i] = value; } - inline netlist_t &detail::device_object_t::netlist() - { - return m_device.netlist(); - } - - inline const netlist_t &detail::device_object_t::netlist() const - { - return m_device.netlist(); - } } diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 4c6935bd7d4..f0789b909a1 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -52,12 +52,13 @@ namespace netlist { public: - struct entry_t + struct entry_t final { - entry_t() { } - entry_t(const Time &t, const Element &o) : m_exec_time(t), m_object(o) { } - entry_t(const entry_t &e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { } - entry_t(entry_t &&e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { } + constexpr entry_t() { } + constexpr entry_t(const Time &t, const Element &o) : m_exec_time(t), m_object(o) { } + constexpr entry_t(const entry_t &e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { } + constexpr entry_t(entry_t &&e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { } + ~entry_t() = default; entry_t& operator=(entry_t && other) { @@ -76,8 +77,8 @@ namespace netlist clear(); } - std::size_t capacity() const { return m_list.size(); } - bool empty() const { return (m_end == &m_list[1]); } + constexpr std::size_t capacity() const { return m_list.size(); } + constexpr bool empty() const { return (m_end == &m_list[1]); } void push(entry_t &&e) noexcept { @@ -95,9 +96,13 @@ namespace netlist m_prof_call.inc(); } +#if 0 entry_t pop() noexcept { return std::move(*(--m_end)); } const entry_t &top() const noexcept { return std::move(*(m_end-1)); } - +#else + entry_t pop() noexcept { return *(--m_end); } + const entry_t &top() const noexcept { return *(m_end-1); } +#endif void remove(const Element &elem) noexcept { /* Lock */ @@ -137,9 +142,9 @@ namespace netlist // save state support & mame disasm - const entry_t *listptr() const { return &m_list[1]; } - std::size_t size() const noexcept { return static_cast(m_end - &m_list[1]); } - const entry_t & operator[](const std::size_t index) const { return m_list[ 1 + index]; } + constexpr const entry_t *listptr() const { return &m_list[1]; } + constexpr std::size_t size() const noexcept { return static_cast(m_end - &m_list[1]); } + constexpr const entry_t & operator[](const std::size_t index) const { return m_list[ 1 + index]; } private: #if HAS_OPENMP && USE_OPENMP diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index c6ba2821790..e792ae06ca9 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -81,32 +81,40 @@ public: friend class linkedlist_t; - element_t() : m_next(nullptr) {} - virtual ~element_t() = default; + constexpr element_t() : m_next(nullptr) {} + constexpr element_t(const element_t &rhs) = delete; + constexpr element_t(element_t &&rhs) = delete; - LC *next() const noexcept { return m_next; } + constexpr LC *next() const noexcept { return m_next; } + + protected: + ~element_t() = default; private: LC * m_next; }; struct iter_t final : public std::iterator { + private: LC* p; public: explicit constexpr iter_t(LC* x) noexcept : p(x) {} - explicit iter_t(const iter_t &rhs) noexcept = default; - iter_t(iter_t &&rhs) noexcept = default; + explicit constexpr iter_t(const iter_t &rhs) noexcept = default; + constexpr iter_t(iter_t &&rhs) noexcept = default; iter_t& operator++() noexcept {p = p->next();return *this;} iter_t operator++(int) noexcept {iter_t tmp(*this); operator++(); return tmp;} - bool operator==(const iter_t& rhs) noexcept {return p==rhs.p;} - bool operator!=(const iter_t& rhs) noexcept {return p!=rhs.p;} - LC& operator*() noexcept {return *p;} - LC* operator->() noexcept {return p;} + constexpr bool operator==(const iter_t& rhs) const noexcept {return p == rhs.p;} + constexpr bool operator!=(const iter_t& rhs) const noexcept {return p != rhs.p;} + /* constexpr */ LC& operator*() noexcept {return *p;} + /* constexpr */ LC* operator->() noexcept {return p;} + + constexpr LC& operator*() const noexcept {return *p;} + constexpr LC* operator->() const noexcept {return p;} }; - linkedlist_t() : m_head(nullptr) {} + constexpr linkedlist_t() : m_head(nullptr) {} - iter_t begin() const noexcept { return iter_t(m_head); } + constexpr iter_t begin() const noexcept { return iter_t(m_head); } constexpr iter_t end() const noexcept { return iter_t(nullptr); } void push_front(LC *elem) @@ -138,7 +146,7 @@ public: LC *front() const { return m_head; } void clear() { m_head = nullptr; } - bool empty() const { return (m_head == nullptr); } + constexpr bool empty() const { return (m_head == nullptr); } private: LC *m_head;