Use noexcept in netlist code where appropriate.

Use macro NL_NOEXCEPT if debug builds would throw an exception (e.g. by
using nl_assert). This is not entirely safe. Going forward, nl_assert
should call log first and than throw. (nw)
This commit is contained in:
couriersud 2016-08-07 01:44:45 +02:00
parent a38471602c
commit 5b1d15383d
11 changed files with 122 additions and 127 deletions

View File

@ -261,7 +261,7 @@ namespace netlist
} }
public: public:
void inc_active() override void inc_active() noexcept override
{ {
if (m_NI > 1) if (m_NI > 1)
if (++m_active == 1) if (++m_active == 1)
@ -270,7 +270,7 @@ namespace netlist
} }
} }
void dec_active() override void dec_active() noexcept override
{ {
/* FIXME: /* FIXME:
* Based on current measurements there is no point to disable * Based on current measurements there is no point to disable

View File

@ -536,8 +536,9 @@ void core_device_t::set_delegate_pointer()
void core_device_t::stop_dev() void core_device_t::stop_dev()
{ {
#if (NL_KEEP_STATISTICS) //NOTE: stop_dev is not removed. It remains so it can be reactivated in case
#endif // we run into a situation were RAII and noexcept dtors force us to
// to have a device stop() routine which may throw.
//stop(); //stop();
} }
@ -640,7 +641,7 @@ detail::net_t::~net_t()
netlist().state().remove_save_items(this); netlist().state().remove_save_items(this);
} }
void detail::net_t::inc_active(core_terminal_t &term) void detail::net_t::inc_active(core_terminal_t &term) NL_NOEXCEPT
{ {
m_active++; m_active++;
m_list_active.push_front(&term); m_list_active.push_front(&term);
@ -664,7 +665,7 @@ void detail::net_t::inc_active(core_terminal_t &term)
} }
} }
void detail::net_t::dec_active(core_terminal_t &term) void detail::net_t::dec_active(core_terminal_t &term) NL_NOEXCEPT
{ {
--m_active; --m_active;
nl_assert(m_active >= 0); nl_assert(m_active >= 0);
@ -688,9 +689,8 @@ void detail::net_t::rebuild_list()
m_active = cnt; m_active = cnt;
} }
void detail::net_t::update_devs() void detail::net_t::update_devs() NL_NOEXCEPT
{ {
//assert(m_num_cons != 0);
nl_assert(this->isRailNet()); nl_assert(this->isRailNet());
static const unsigned masks[4] = static const unsigned masks[4] =
@ -748,41 +748,14 @@ void detail::net_t::register_con(detail::core_terminal_t &terminal)
m_active++; m_active++;
} }
void detail::net_t::move_connections(detail::net_t *dest_net) void detail::net_t::move_connections(detail::net_t &dest_net)
{ {
for (auto &ct : m_core_terms) for (auto &ct : m_core_terms)
dest_net->register_con(*ct); dest_net.register_con(*ct);
m_core_terms.clear(); m_core_terms.clear();
m_active = 0; m_active = 0;
} }
void detail::net_t::merge_net(detail::net_t *othernet)
{
netlist().log().debug("merging nets ...\n");
if (othernet == nullptr)
return; // Nothing to do
if (othernet == this)
{
netlist().log().warning("Connecting {1} to itself. This may be right, though\n", this->name());
return; // Nothing to do
}
if (this->isRailNet() && othernet->isRailNet())
netlist().log().fatal("Trying to merge two rail nets: {1} and {2}\n", this->name(), othernet->name());
if (othernet->isRailNet())
{
netlist().log().debug("othernet is railnet\n");
othernet->merge_net(this);
}
else
{
othernet->move_connections(this);
}
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// logic_net_t // logic_net_t
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------

View File

@ -117,14 +117,14 @@ class NETLIB_NAME(name) : public device_t
#define NETLIB_FAMILY(family) , m_famsetter(*this, family) #define NETLIB_FAMILY(family) , m_famsetter(*this, family)
#define NETLIB_UPDATE_TERMINALSI() public: virtual void update_terminals() override #define NETLIB_UPDATE_TERMINALSI() public: virtual void update_terminals() override
#define NETLIB_UPDATEI() protected: virtual void update() NOEXCEPT override #define NETLIB_UPDATEI() protected: virtual void update() noexcept override
#define NETLIB_UPDATE_PARAMI() public: virtual void update_param() override #define NETLIB_UPDATE_PARAMI() public: virtual void update_param() override
#define NETLIB_RESETI() protected: virtual void reset() override #define NETLIB_RESETI() protected: virtual void reset() override
#define NETLIB_SUB(chip) nld_ ## chip #define NETLIB_SUB(chip) nld_ ## chip
#define NETLIB_SUBXX(chip) std::unique_ptr< nld_ ## chip > #define NETLIB_SUBXX(chip) std::unique_ptr< nld_ ## chip >
#define NETLIB_UPDATE(chip) void NETLIB_NAME(chip) :: update(void) NOEXCEPT #define NETLIB_UPDATE(chip) void NETLIB_NAME(chip) :: update(void) NL_NOEXCEPT
#define NETLIB_RESET(chip) void NETLIB_NAME(chip) :: reset(void) #define NETLIB_RESET(chip) void NETLIB_NAME(chip) :: reset(void)
@ -140,13 +140,14 @@ class NETLIB_NAME(name) : public device_t
//============================================================ //============================================================
#if defined(MAME_DEBUG) #if defined(MAME_DEBUG)
#define nl_assert(x) do { if (1) if (!(x)) throw nl_exception(plib::pfmt("assert: {1}:{2}: {3}")(__FILE__)(__LINE__)(#x) ); } while (0) #define nl_assert(x) do { if (1) if (!(x)) throw nl_exception(plib::pfmt("assert: {1}:{2}: {3}")(__FILE__)(__LINE__)(#x) ); } while (0)
#define NL_NOEXCEPT
#else #else
#define nl_assert(x) do { if (0) if (!(x)) throw nl_exception(plib::pfmt("assert: {1}:{2}: {3}")(__FILE__)(__LINE__)(#x) ); } while (0) #define nl_assert(x) do { if (0) if (!(x)) throw nl_exception(plib::pfmt("assert: {1}:{2}: {3}")(__FILE__)(__LINE__)(#x) ); } while (0)
#define NL_NOEXCEPT noexcept
#endif #endif
#define nl_assert_always(x, msg) do { if (!(x)) throw nl_exception(plib::pfmt("Fatal error: {1}\nCaused by assert: {2}:{3}: {4}")(msg)(__FILE__)(__LINE__)(#x)); } while (0) #define nl_assert_always(x, msg) do { if (!(x)) throw nl_exception(plib::pfmt("Fatal error: {1}\nCaused by assert: {2}:{3}: {4}")(msg)(__FILE__)(__LINE__)(#x)); } while (0)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// forward definitions // forward definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -196,7 +197,7 @@ namespace netlist
: plib::pexception(text) { } : plib::pexception(text) { }
/*! Copy constructor. */ /*! Copy constructor. */
nl_exception(const nl_exception &e) : plib::pexception(e) { } nl_exception(const nl_exception &e) : plib::pexception(e) { }
virtual ~nl_exception() noexcept {} virtual ~nl_exception() {}
}; };
class logic_output_t; class logic_output_t;
@ -285,9 +286,9 @@ namespace netlist
const T &value //!< Initial value after construction const T &value //!< Initial value after construction
); );
//! Copy Constructor. //! Copy Constructor.
state_var(const state_var &rhs) NOEXCEPT = default; state_var(const state_var &rhs) noexcept = default;
//! Move Constructor. //! Move Constructor.
state_var(state_var &&rhs) NOEXCEPT = default; state_var(state_var &&rhs) noexcept = default;
//! Assignment operator to assign value of a state var. //! Assignment operator to assign value of a state var.
state_var &operator=(state_var rhs) { std::swap(rhs.m_value, this->m_value); return *this; } state_var &operator=(state_var rhs) { std::swap(rhs.m_value, this->m_value); return *this; }
//! Assignment operator to assign value of type T. //! Assignment operator to assign value of type T.
@ -315,8 +316,8 @@ namespace netlist
{ {
public: public:
state_var(device_t &dev, const pstring name, const T & value); state_var(device_t &dev, const pstring name, const T & value);
state_var(const state_var &rhs) NOEXCEPT = default; state_var(const state_var &rhs) noexcept = default;
state_var(state_var &&rhs) NOEXCEPT = default; state_var(state_var &&rhs) noexcept = default;
state_var &operator=(const state_var rhs) { m_value = rhs.m_value; return *this; } 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; } state_var &operator=(const T rhs) { m_value = rhs; return *this; }
T & operator[](const std::size_t i) { return m_value[i]; } T & operator[](const std::size_t i) { return m_value[i]; }
@ -475,8 +476,8 @@ namespace netlist
const net_t & net() const { return *m_net;} const net_t & net() const { return *m_net;}
net_t & net() { return *m_net;} net_t & net() { return *m_net;}
bool is_logic() const; bool is_logic() const noexcept;
bool is_analog() const; bool is_analog() const noexcept;
bool is_state(const state_e astate) const { return (m_state == astate); } bool is_state(const state_e astate) const { return (m_state == astate); }
state_e state() const { return m_state; } state_e state() const { return m_state; }
@ -506,8 +507,8 @@ namespace netlist
{ {
} }
const analog_net_t & net() const; const analog_net_t & net() const noexcept;
analog_net_t & net(); analog_net_t & net() noexcept;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -589,8 +590,8 @@ namespace netlist
devices::nld_base_proxy *get_proxy() const { return m_proxy; } devices::nld_base_proxy *get_proxy() const { return m_proxy; }
void set_proxy(devices::nld_base_proxy *proxy) { m_proxy = proxy; } void set_proxy(devices::nld_base_proxy *proxy) { m_proxy = proxy; }
logic_net_t & net(); logic_net_t & net() noexcept;
const logic_net_t & net() const; const logic_net_t & net() const noexcept;
protected: protected:
@ -607,9 +608,9 @@ namespace netlist
public: public:
logic_input_t(core_device_t &dev, const pstring &aname); logic_input_t(core_device_t &dev, const pstring &aname);
netlist_sig_t Q() const; netlist_sig_t Q() const noexcept;
netlist_sig_t operator()() const netlist_sig_t operator()() const NL_NOEXCEPT
{ {
nl_assert(state() != STATE_INP_PASSIVE); nl_assert(state() != STATE_INP_PASSIVE);
return Q(); return Q();
@ -647,7 +648,7 @@ namespace netlist
/*! returns voltage at terminal. /*! returns voltage at terminal.
* \returns voltage at terminal. * \returns voltage at terminal.
*/ */
nl_double Q_Analog() const; nl_double Q_Analog() const noexcept;
}; };
@ -668,19 +669,18 @@ namespace netlist
void reset(); void reset();
void register_con(core_terminal_t &terminal); void register_con(core_terminal_t &terminal);
void merge_net(net_t *othernet);
bool is_logic() const; bool is_logic() const noexcept;
bool is_analog() const; bool is_analog() const noexcept;
void toggle_new_Q() { m_new_Q ^= 1; } void toggle_new_Q() { m_new_Q ^= 1; }
void force_queue_execution() { m_new_Q = (m_cur_Q ^ 1); } void force_queue_execution() { m_new_Q = (m_cur_Q ^ 1); }
void push_to_queue(const netlist_time delay) NOEXCEPT; void push_to_queue(const netlist_time delay) noexcept;
void reschedule_in_queue(const netlist_time delay) NOEXCEPT; void reschedule_in_queue(const netlist_time delay) noexcept;
bool is_queued() const { return m_in_queue == 1; } bool is_queued() const { return m_in_queue == 1; }
void update_devs(); void update_devs() NL_NOEXCEPT;
const netlist_time time() const { return m_time; } const netlist_time time() const { return m_time; }
void set_time(const netlist_time ntime) { m_time = ntime; } void set_time(const netlist_time ntime) { m_time = ntime; }
@ -688,12 +688,13 @@ namespace netlist
bool isRailNet() const { return !(m_railterminal == nullptr); } bool isRailNet() const { return !(m_railterminal == nullptr); }
core_terminal_t & railterminal() const { return *m_railterminal; } core_terminal_t & railterminal() const { return *m_railterminal; }
std::size_t num_cons() const { return m_core_terms.size(); } std::size_t num_cons() const noexcept { return m_core_terms.size(); }
void inc_active(core_terminal_t &term); void inc_active(core_terminal_t &term) NL_NOEXCEPT;
void dec_active(core_terminal_t &term); void dec_active(core_terminal_t &term) NL_NOEXCEPT;
void rebuild_list(); /* rebuild m_list after a load */ void rebuild_list(); /* rebuild m_list after a load */
void move_connections(net_t &dest_net);
std::vector<core_terminal_t *> m_core_terms; // save post-start m_list ... std::vector<core_terminal_t *> m_core_terms; // save post-start m_list ...
@ -706,8 +707,6 @@ namespace netlist
state_var_u8 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ state_var_u8 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */
private: private:
void move_connections(net_t *new_net);
plib::linkedlist_t<core_terminal_t> m_list_active; plib::linkedlist_t<core_terminal_t> m_list_active;
core_terminal_t * m_railterminal; core_terminal_t * m_railterminal;
@ -729,7 +728,7 @@ namespace netlist
netlist_sig_t new_Q() const { return m_new_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; } void initial(const netlist_sig_t val) { m_cur_Q = m_new_Q = val; }
void set_Q(const netlist_sig_t newQ, const netlist_time delay) NOEXCEPT void set_Q(const netlist_sig_t newQ, const netlist_time delay) noexcept
{ {
if (newQ != m_new_Q) if (newQ != m_new_Q)
{ {
@ -738,7 +737,7 @@ namespace netlist
} }
} }
void set_Q_time(const netlist_sig_t newQ, const netlist_time at) void set_Q_time(const netlist_sig_t newQ, const netlist_time at) noexcept
{ {
if (newQ != m_new_Q) if (newQ != m_new_Q)
{ {
@ -793,7 +792,7 @@ namespace netlist
void initial(const netlist_sig_t val); void initial(const netlist_sig_t val);
void push(const netlist_sig_t newQ, const netlist_time delay) NOEXCEPT void push(const netlist_sig_t newQ, const netlist_time delay) noexcept
{ {
m_my_net.set_Q(newQ, delay); // take the shortcut m_my_net.set_Q(newQ, delay); // take the shortcut
} }
@ -808,11 +807,11 @@ namespace netlist
public: public:
analog_output_t(core_device_t &dev, const pstring &aname); analog_output_t(core_device_t &dev, const pstring &aname);
void push(const nl_double val) { set_Q(val); } void push(const nl_double val) noexcept { set_Q(val); }
void initial(const nl_double val); void initial(const nl_double val);
private: private:
void set_Q(const nl_double newQ); void set_Q(const nl_double newQ) noexcept;
analog_net_t m_my_net; analog_net_t m_my_net;
}; };
@ -849,7 +848,7 @@ namespace netlist
public: public:
param_template_t(device_t &device, const pstring name, const C val); param_template_t(device_t &device, const pstring name, const C val);
const C operator()() const { return Value(); } const C operator()() const { return Value(); }
void setTo(const C &param); void setTo(const C &param);
void initial(const C &val) { m_param = val; } void initial(const C &val) { m_param = val; }
@ -902,14 +901,14 @@ namespace netlist
virtual ~core_device_t(); virtual ~core_device_t();
void update_dev() void update_dev() noexcept
{ {
m_stat_total_time.start(); m_stat_total_time.start();
do_update(); do_update();
m_stat_total_time.stop(); m_stat_total_time.stop();
} }
void do_update() NOEXCEPT void do_update() noexcept
{ {
#if (NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF) #if (NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF)
(this->*m_static_update)(); (this->*m_static_update)();
@ -923,7 +922,7 @@ namespace netlist
void set_delegate_pointer(); void set_delegate_pointer();
void stop_dev(); void stop_dev();
void do_inc_active() void do_inc_active() noexcept
{ {
if (m_hint_deactivate) if (m_hint_deactivate)
{ {
@ -931,7 +930,8 @@ namespace netlist
inc_active(); inc_active();
} }
} }
void do_dec_active()
void do_dec_active() noexcept
{ {
if (m_hint_deactivate) if (m_hint_deactivate)
dec_active(); dec_active();
@ -946,9 +946,9 @@ namespace netlist
protected: protected:
virtual void update() NOEXCEPT { } virtual void update() noexcept { }
virtual void inc_active() { } virtual void inc_active() noexcept { }
virtual void dec_active() { } virtual void dec_active() noexcept { }
virtual void stop() { } virtual void stop() { }
virtual void reset() { } virtual void reset() { }
@ -1085,8 +1085,8 @@ namespace netlist
devices::NETLIB_NAME(gnd) *gnd() const { return m_gnd; } devices::NETLIB_NAME(gnd) *gnd() const { return m_gnd; }
nl_double gmin() const; nl_double gmin() const;
void push_to_queue(detail::net_t &out, const netlist_time attime) NOEXCEPT; void push_to_queue(detail::net_t &out, const netlist_time attime) noexcept;
void remove_from_queue(detail::net_t &out); void remove_from_queue(detail::net_t &out) NL_NOEXCEPT;
void process_queue(const netlist_time &delta); void process_queue(const netlist_time &delta);
void abort_current_queue_slice() { m_queue.retime(m_time, nullptr); } void abort_current_queue_slice() { m_queue.retime(m_time, nullptr); }
@ -1218,22 +1218,22 @@ namespace netlist
} }
} }
inline bool detail::core_terminal_t::is_logic() const inline bool detail::core_terminal_t::is_logic() const noexcept
{ {
return dynamic_cast<const logic_t *>(this) != nullptr; return dynamic_cast<const logic_t *>(this) != nullptr;
} }
inline bool detail::core_terminal_t::is_analog() const inline bool detail::core_terminal_t::is_analog() const noexcept
{ {
return dynamic_cast<const analog_t *>(this) != nullptr; return dynamic_cast<const analog_t *>(this) != nullptr;
} }
inline bool detail::net_t::is_logic() const inline bool detail::net_t::is_logic() const noexcept
{ {
return dynamic_cast<const logic_net_t *>(this) != nullptr; return dynamic_cast<const logic_net_t *>(this) != nullptr;
} }
inline bool detail::net_t::is_analog() const inline bool detail::net_t::is_analog() const noexcept
{ {
return dynamic_cast<const analog_net_t *>(this) != nullptr; return dynamic_cast<const analog_net_t *>(this) != nullptr;
} }
@ -1274,7 +1274,7 @@ namespace netlist
} }
} }
inline void detail::net_t::push_to_queue(const netlist_time delay) NOEXCEPT inline void detail::net_t::push_to_queue(const netlist_time delay) noexcept
{ {
if (!is_queued() && (num_cons() != 0)) if (!is_queued() && (num_cons() != 0))
{ {
@ -1287,7 +1287,7 @@ namespace netlist
} }
} }
inline void detail::net_t::reschedule_in_queue(const netlist_time delay) NOEXCEPT inline void detail::net_t::reschedule_in_queue(const netlist_time delay) noexcept
{ {
if (is_queued()) if (is_queued())
netlist().remove_from_queue(*this); netlist().remove_from_queue(*this);
@ -1300,39 +1300,39 @@ namespace netlist
} }
} }
inline const analog_net_t & analog_t::net() const inline const analog_net_t & analog_t::net() const noexcept
{ {
return static_cast<const analog_net_t &>(core_terminal_t::net()); return static_cast<const analog_net_t &>(core_terminal_t::net());
} }
inline analog_net_t & analog_t::net() inline analog_net_t & analog_t::net() noexcept
{ {
return static_cast<analog_net_t &>(core_terminal_t::net()); return static_cast<analog_net_t &>(core_terminal_t::net());
} }
inline nl_double terminal_t::operator ()() const { return net().Q_Analog(); } inline nl_double terminal_t::operator ()() const { return net().Q_Analog(); }
inline logic_net_t & logic_t::net() inline logic_net_t & logic_t::net() noexcept
{ {
return *static_cast<logic_net_t *>(&core_terminal_t::net()); return *static_cast<logic_net_t *>(&core_terminal_t::net());
} }
inline const logic_net_t & logic_t::net() const inline const logic_net_t & logic_t::net() const noexcept
{ {
return static_cast<const logic_net_t &>(core_terminal_t::net()); return static_cast<const logic_net_t &>(core_terminal_t::net());
} }
inline netlist_sig_t logic_input_t::Q() const inline netlist_sig_t logic_input_t::Q() const noexcept
{ {
return net().Q(); return net().Q();
} }
inline nl_double analog_input_t::Q_Analog() const inline nl_double analog_input_t::Q_Analog() const noexcept
{ {
return net().Q_Analog(); return net().Q_Analog();
} }
inline void analog_output_t::set_Q(const nl_double newQ) inline void analog_output_t::set_Q(const nl_double newQ) noexcept
{ {
if (newQ != net().Q_Analog()) if (newQ != net().Q_Analog())
{ {
@ -1342,12 +1342,12 @@ namespace netlist
} }
} }
inline void netlist_t::push_to_queue(detail::net_t &out, const netlist_time attime) NOEXCEPT inline void netlist_t::push_to_queue(detail::net_t &out, const netlist_time attime) noexcept
{ {
m_queue.push(attime, &out); m_queue.push(attime, &out);
} }
inline void netlist_t::remove_from_queue(detail::net_t &out) inline void netlist_t::remove_from_queue(detail::net_t &out) NL_NOEXCEPT
{ {
m_queue.remove(&out); m_queue.remove(&out);
} }

View File

@ -135,11 +135,6 @@ using nperfcount_t = plib::chrono::counter<false>;
// General // General
//============================================================ //============================================================
// this macro passes an item followed by a string version of itself as two consecutive parameters
//#define NLNAME(x) x, #x
#define NOEXCEPT noexcept
// The following adds about 10% performance ... // The following adds about 10% performance ...
#if !defined(USE_OPENMP) #if !defined(USE_OPENMP)

View File

@ -47,7 +47,7 @@ namespace netlist
std::size_t capacity() const { return m_list.size(); } std::size_t capacity() const { return m_list.size(); }
bool empty() const { return (m_end == &m_list[1]); } bool empty() const { return (m_end == &m_list[1]); }
void push(const Time t, Element o) NOEXCEPT void push(const Time t, Element o) noexcept
{ {
#if HAS_OPENMP && USE_OPENMP #if HAS_OPENMP && USE_OPENMP
/* Lock */ /* Lock */
@ -67,10 +67,10 @@ namespace netlist
#endif #endif
} }
entry_t pop() NOEXCEPT { return *(--m_end); } entry_t pop() noexcept { return *(--m_end); }
const entry_t &top() const NOEXCEPT { return *(m_end-1); } const entry_t &top() const noexcept { return *(m_end-1); }
void remove(const Element &elem) NOEXCEPT void remove(const Element &elem) noexcept
{ {
/* Lock */ /* Lock */
#if HAS_OPENMP && USE_OPENMP #if HAS_OPENMP && USE_OPENMP
@ -97,7 +97,7 @@ namespace netlist
#endif #endif
} }
void retime(const Time t, const Element &elem) NOEXCEPT void retime(const Time t, const Element &elem) noexcept
{ {
remove(elem); remove(elem);
push(t, elem); push(t, elem);
@ -116,9 +116,9 @@ namespace netlist
// save state support & mame disasm // save state support & mame disasm
const entry_t *listptr() const { return &m_list[1]; } const entry_t *listptr() const { return &m_list[1]; }
std::size_t size() const { return static_cast<std::size_t>(m_end - &m_list[1]); } std::size_t size() const noexcept { return static_cast<std::size_t>(m_end - &m_list[1]); }
const entry_t & operator[](const std::size_t index) const { return m_list[ 1 + index]; } const entry_t & operator[](const std::size_t index) const { return m_list[ 1 + index]; }
private: private:

View File

@ -451,6 +451,31 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(detail::core_terminal_t &out)
return proxy; return proxy;
} }
void setup_t::merge_nets(detail::net_t &thisnet, detail::net_t &othernet)
{
netlist().log().debug("merging nets ...\n");
if (&othernet == &thisnet)
{
netlist().log().warning("Connecting {1} to itself. This may be right, though\n", thisnet.name());
return; // Nothing to do
}
if (thisnet.isRailNet() && othernet.isRailNet())
netlist().log().fatal("Trying to merge two rail nets: {1} and {2}\n", thisnet.name(), othernet.name());
if (othernet.isRailNet())
{
netlist().log().debug("othernet is railnet\n");
merge_nets(othernet, thisnet);
}
else
{
othernet.move_connections(thisnet);
}
}
void setup_t::connect_input_output(detail::core_terminal_t &in, detail::core_terminal_t &out) void setup_t::connect_input_output(detail::core_terminal_t &in, detail::core_terminal_t &out)
{ {
if (out.is_analog() && in.is_logic()) if (out.is_analog() && in.is_logic())
@ -477,7 +502,7 @@ void setup_t::connect_input_output(detail::core_terminal_t &in, detail::core_ter
else else
{ {
if (in.has_net()) if (in.has_net())
out.net().merge_net(&in.net()); merge_nets(out.net(), in.net());
else else
out.net().register_con(in); out.net().register_con(in);
} }
@ -503,7 +528,7 @@ void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &
if (inp.has_net()) if (inp.has_net())
//fatalerror("logic inputs can only belong to one net!\n"); //fatalerror("logic inputs can only belong to one net!\n");
proxy->m_Q.net().merge_net(&inp.net()); merge_nets(proxy->m_Q.net(), inp.net());
else else
proxy->m_Q.net().register_con(inp); proxy->m_Q.net().register_con(inp);
@ -522,7 +547,7 @@ void setup_t::connect_terminal_output(terminal_t &in, detail::core_terminal_t &o
log().debug("connect_terminal_output: {1} {2}\n", in.name(), out.name()); log().debug("connect_terminal_output: {1} {2}\n", in.name(), out.name());
/* no proxy needed, just merge existing terminal net */ /* no proxy needed, just merge existing terminal net */
if (in.has_net()) if (in.has_net())
out.net().merge_net(&in.net()); merge_nets(out.net(), in.net());
else else
out.net().register_con(in); out.net().register_con(in);
} }
@ -544,7 +569,7 @@ void setup_t::connect_terminals(detail::core_terminal_t &t1, detail::core_termin
if (t1.has_net() && t2.has_net()) if (t1.has_net() && t2.has_net())
{ {
log().debug("T2 and T1 have net\n"); log().debug("T2 and T1 have net\n");
t1.net().merge_net(&t2.net()); merge_nets(t1.net(), t2.net());
} }
else if (t2.has_net()) else if (t2.has_net())
{ {

View File

@ -270,6 +270,8 @@ namespace netlist
detail::core_terminal_t *find_terminal(const pstring &outname_in, bool required = true); detail::core_terminal_t *find_terminal(const pstring &outname_in, bool required = true);
detail::core_terminal_t *find_terminal(const pstring &outname_in, detail::device_object_t::type_t atype, bool required = true); detail::core_terminal_t *find_terminal(const pstring &outname_in, detail::device_object_t::type_t atype, bool required = true);
void merge_nets(detail::net_t &thisnet, detail::net_t &othernet);
void connect_terminals(detail::core_terminal_t &in, detail::core_terminal_t &out); void connect_terminals(detail::core_terminal_t &in, detail::core_terminal_t &out);
void connect_input_output(detail::core_terminal_t &in, detail::core_terminal_t &out); void connect_input_output(detail::core_terminal_t &in, detail::core_terminal_t &out);
void connect_terminal_output(terminal_t &in, detail::core_terminal_t &out); void connect_terminal_output(terminal_t &in, detail::core_terminal_t &out);

View File

@ -36,13 +36,13 @@ namespace netlist
using mult_type = std::uint_fast64_t; using mult_type = std::uint_fast64_t;
static constexpr internal_type resolution = RES; static constexpr internal_type resolution = RES;
constexpr ptime() NOEXCEPT : m_time(0) {} constexpr ptime() noexcept : m_time(0) {}
constexpr ptime(const ptime &rhs) NOEXCEPT = default; constexpr ptime(const ptime &rhs) noexcept = default;
constexpr ptime(ptime &&rhs) NOEXCEPT = default; constexpr ptime(ptime &&rhs) noexcept = default;
constexpr explicit ptime(const double t) = delete; constexpr explicit ptime(const double t) = delete;
//: m_time((internal_type) ( t * (double) resolution)) { } //: m_time((internal_type) ( t * (double) resolution)) { }
constexpr explicit ptime(const internal_type nom, const internal_type den) NOEXCEPT constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept
: m_time(nom * (resolution / den)) { } : m_time(nom * (resolution / den)) { }
ptime &operator=(const ptime rhs) { m_time = rhs.m_time; return *this; } ptime &operator=(const ptime rhs) { m_time = rhs.m_time; return *this; }

View File

@ -112,7 +112,7 @@ private:
owned_ptr() owned_ptr()
: m_ptr(nullptr), m_is_owned(true) { } : m_ptr(nullptr), m_is_owned(true) { }
public: public:
owned_ptr(SC *p, bool owned) owned_ptr(SC *p, bool owned) noexcept
: m_ptr(p), m_is_owned(owned) : m_ptr(p), m_is_owned(owned)
{ } { }
owned_ptr(const owned_ptr &r) = delete; owned_ptr(const owned_ptr &r) = delete;
@ -130,7 +130,7 @@ public:
return *this; return *this;
} }
owned_ptr(owned_ptr &&r) owned_ptr(owned_ptr &&r) noexcept
{ {
m_is_owned = r.m_is_owned; m_is_owned = r.m_is_owned;
m_ptr = r.m_ptr; m_ptr = r.m_ptr;
@ -139,7 +139,7 @@ public:
} }
template<typename DC> template<typename DC>
owned_ptr(owned_ptr<DC> &&r) owned_ptr(owned_ptr<DC> &&r) noexcept
{ {
m_ptr = static_cast<SC *>(r.get()); m_ptr = static_cast<SC *>(r.get());
m_is_owned = r.is_owned(); m_is_owned = r.is_owned();

View File

@ -43,12 +43,12 @@ public:
size_t size() { return N; } size_t size() { return N; }
C& operator[](const std::size_t &index) C& operator[](const std::size_t &index) noexcept
{ {
return *reinterpret_cast<C *>(&m_buf[index]); return *reinterpret_cast<C *>(&m_buf[index]);
} }
const C& operator[](const std::size_t &index) const const C& operator[](const std::size_t &index) const noexcept
{ {
return *reinterpret_cast<C *>(&m_buf[index]); return *reinterpret_cast<C *>(&m_buf[index]);
} }
@ -85,7 +85,7 @@ public:
element_t() : m_next(nullptr) {} element_t() : m_next(nullptr) {}
LC *next() const { return m_next; } LC *next() const noexcept { return m_next; }
private: private:
LC * m_next; LC * m_next;
}; };
@ -107,8 +107,8 @@ public:
linkedlist_t() : m_head(nullptr) {} linkedlist_t() : m_head(nullptr) {}
iter_t begin() const { return iter_t(m_head); } iter_t begin() const noexcept { return iter_t(m_head); }
constexpr iter_t end() const { return iter_t(nullptr); } constexpr iter_t end() const noexcept { return iter_t(nullptr); }
void push_front(LC *elem) void push_front(LC *elem)
{ {

View File

@ -382,7 +382,7 @@ void matrix_solver_t::reset()
m_last_step = netlist_time::zero(); m_last_step = netlist_time::zero();
} }
void matrix_solver_t::update() NOEXCEPT void matrix_solver_t::update() NL_NOEXCEPT
{ {
const netlist_time new_timestep = solve(); const netlist_time new_timestep = solve();