diff --git a/src/lib/netlist/core/core_device.h b/src/lib/netlist/core/core_device.h index e1df57deb50..db5f922ad13 100644 --- a/src/lib/netlist/core/core_device.h +++ b/src/lib/netlist/core/core_device.h @@ -78,6 +78,10 @@ namespace netlist log_type & log(); + void handler_noop() + { + } + public: virtual void timestep(timestep_type ts_type, nl_fptype st) noexcept { plib::unused_var(ts_type, st); } virtual void update_terminals() noexcept { } diff --git a/src/lib/netlist/core/device_macros.h b/src/lib/netlist/core/device_macros.h index 127447e194a..17d70d7d710 100644 --- a/src/lib/netlist/core/device_macros.h +++ b/src/lib/netlist/core/device_macros.h @@ -152,6 +152,7 @@ class NETLIB_NAME(name) : public delegator_t void NETLIB_NAME(cname) :: timestep(timestep_type ts_type, nl_fptype step) noexcept #define NETLIB_DELEGATE(name) nldelegate(&this_type :: name, this) +#define NETLIB_DELEGATE_NOOP() nldelegate(&core_device_t::handler_noop, static_cast(this)) #define NETLIB_UPDATE_TERMINALSI() virtual void update_terminals() noexcept override #define NETLIB_HANDLERI(name) void name() noexcept diff --git a/src/lib/netlist/core/devices.h b/src/lib/netlist/core/devices.h index de4b11b994a..f14832aa0b7 100644 --- a/src/lib/netlist/core/devices.h +++ b/src/lib/netlist/core/devices.h @@ -138,7 +138,7 @@ namespace netlist { public: NETLIB_CONSTRUCTOR(nc_pin) - , m_I(*this, "I", NETLIB_DELEGATE(noop)) + , m_I(*this, "I", NETLIB_DELEGATE_NOOP()) { } @@ -146,10 +146,6 @@ namespace netlist //NETLIB_RESETI() {} private: - NETLIB_HANDLERI(noop) - { - } - analog_input_t m_I; }; diff --git a/src/lib/netlist/devices/nld_74165.cpp b/src/lib/netlist/devices/nld_74165.cpp index 527e4605bef..1da604aef36 100644 --- a/src/lib/netlist/devices/nld_74165.cpp +++ b/src/lib/netlist/devices/nld_74165.cpp @@ -36,7 +36,7 @@ namespace netlist { NETLIB_CONSTRUCTOR(74165) , m_DATA(*this, { "H", "G", "F", "E", "D", "C", "B", "A" }, NETLIB_DELEGATE(inputs)) - , m_SER(*this, "SER", NETLIB_DELEGATE(noop)) + , m_SER(*this, "SER", NETLIB_DELEGATE_NOOP()) , m_SH_LDQ(*this, "SH_LDQ", NETLIB_DELEGATE(inputs)) , m_CLK(*this, "CLK", NETLIB_DELEGATE(clk)) , m_CLKINH(*this, "CLKINH", NETLIB_DELEGATE(inputs)) @@ -53,10 +53,6 @@ namespace netlist m_shifter = 0; } - NETLIB_HANDLERI(noop) - { - } - NETLIB_HANDLERI(clk) { unsigned high_bit = m_SER() ? 0x80 : 0; diff --git a/src/lib/netlist/devices/nld_7497.cpp b/src/lib/netlist/devices/nld_7497.cpp index 4fdf282a9fd..6f5f30e8811 100644 --- a/src/lib/netlist/devices/nld_7497.cpp +++ b/src/lib/netlist/devices/nld_7497.cpp @@ -48,6 +48,8 @@ namespace netlist static constexpr const std::array out_delay_CLK_Y = { NLTIME_FROM_NS(20), NLTIME_FROM_NS(26) }; // tPHL, tPLH static constexpr const std::array out_delay_CLK_Z = { NLTIME_FROM_NS(17), NLTIME_FROM_NS(12) }; + // FIXME: room for improvement -> clock handling + NETLIB_OBJECT(7497) { NETLIB_CONSTRUCTOR(7497) @@ -76,8 +78,6 @@ namespace netlist m_lastclock = 0; } - NETLIB_HANDLERI(noop) { } - NETLIB_HANDLERI(unity) { newstate (m_state); diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 9cb12d06668..f4aaaa930cc 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -332,9 +332,10 @@ namespace netlist std::vector t; log().verbose("Using default startup strategy"); for (auto &n : m_nets) + { + n->update_inputs(); // only used if USE_COPY_INSTEAD_OF_REFERENCE == 1 for (auto & term : n->core_terms()) { - n->update_inputs(); // only used if USE_COPY_INSTEAD_OF_REFERENCE == 1 if (!plib::container::contains(t, &term->delegate())) { t.push_back(&term->delegate()); @@ -345,6 +346,7 @@ namespace netlist if (!plib::container::contains(devices_called, dev)) devices_called.push_back(dev); } + } log().verbose("Devices not yet updated:"); for (auto &dev : m_devices) if (!plib::container::contains(devices_called, dev.second.get())) @@ -747,8 +749,6 @@ namespace netlist nldelegate delegate) : logic_t(dev, aname, STATE_INP_ACTIVE, delegate) { - if (!delegate.is_set()) - throw nl_exception("delegate not set for {1}", this->name()); state().setup().register_term(*this); } diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 70860747f93..06ad0619cc7 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -1688,12 +1688,15 @@ void setup_t::prepare_to_run() } for (auto &n : m_nlstate.nets()) + { for (auto & term : n->core_terms()) - if (!term->delegate().is_set()) + if (!term->delegate()) { log().fatal(MF_DELEGATE_NOT_SET_1(term->name())); throw nl_exception(MF_DELEGATE_NOT_SET_1(term->name())); } + n->rebuild_list(); + } } // ---------------------------------------------------------------------------------------- diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h index 13d627dd2a1..e86c94ff4c9 100644 --- a/src/lib/netlist/plib/ppmf.h +++ b/src/lib/netlist/plib/ppmf.h @@ -368,8 +368,6 @@ namespace plib { bind>(object, &mftp); } - bool is_set() const noexcept { return m_resolved != nullptr; } - generic_class *object() const noexcept { return m_obj; } bool has_object() const noexcept { return m_obj != nullptr; } @@ -384,6 +382,7 @@ namespace plib { return this->call(std::forward(args)...); } + operator bool() const noexcept { return m_resolved != nullptr; } private: template void bind(O * object, MF *fraw)