diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index cf839c876ea..757d084c415 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -824,8 +824,10 @@ void netlist_mame_stream_output_device::device_start() void netlist_mame_stream_output_device::device_reset() { LOGDEVCALLS("reset %s\n", name()); +#if 0 m_cur = 0.0; m_last_buffer_time = netlist::netlist_time_ext::zero(); +#endif } void netlist_mame_stream_output_device::sound_update_fill(std::size_t samples, stream_sample_t *target) @@ -906,6 +908,7 @@ netlist_mame_device::netlist_mame_device(const machine_config &mconfig, device_t , m_attotime_per_clock(attotime::zero) , m_old(netlist::netlist_time_ext::zero()) , m_setup_func(nullptr) + , m_device_reset_called(false) { } @@ -1045,6 +1048,10 @@ void netlist_mame_device::device_start() m_old = netlist::netlist_time_ext::zero(); m_rem = netlist::netlist_time_ext::zero(); + m_cur_time = attotime::zero; + + m_device_reset_called = false; + LOGDEVCALLS("device_start exit\n"); } @@ -1061,10 +1068,17 @@ void netlist_mame_device::device_clock_changed() void netlist_mame_device::device_reset() { LOGDEVCALLS("device_reset\n"); - m_cur_time = attotime::zero; - m_old = netlist::netlist_time_ext::zero(); - m_rem = netlist::netlist_time_ext::zero(); - netlist().exec().reset(); + if (!m_device_reset_called) + { + // netlists don't have a reset line, doing a soft-reset is pointless + // the only reason we call these here once after device_start + // is that netlist input devices may be started after the netlist device + // and because the startup code may trigger actions which need all + // devices set up. + netlist().free_setup_resources(); + netlist().exec().reset(); + m_device_reset_called = true; + } } void netlist_mame_device::device_stop() diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 4486eb729a6..22e3a185fe7 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -127,6 +127,7 @@ private: std::unique_ptr m_netlist; func_type m_setup_func; + bool m_device_reset_called; }; // ---------------------------------------------------------------------------------------- diff --git a/src/devices/video/fixfreq.cpp b/src/devices/video/fixfreq.cpp index 732a6994ae4..44c332c066e 100644 --- a/src/devices/video/fixfreq.cpp +++ b/src/devices/video/fixfreq.cpp @@ -119,7 +119,7 @@ void fixedfreq_monitor_state::update_sync_channel(const time_type &time, const d /* falling composite */ //LOG("HSYNC down %f %d %f\n", time * 1e6, m_last_x, m_sync_signal); } - m_last_sync = newval; + m_last_sync_val = newval; m_last_sync_time = time; } @@ -237,7 +237,7 @@ void fixedfreq_device::device_start() m_state.start(); // FIXME: will be done by netlist going forward - save_item(NAME(m_state.m_last_sync)); + save_item(NAME(m_state.m_last_sync_val)); save_item(NAME(m_state.m_last_x)); save_item(NAME(m_state.m_last_y)); save_item(NAME(m_state.m_last_sync_time)); diff --git a/src/devices/video/fixfreq.h b/src/devices/video/fixfreq.h index 6d1da4f22f7..6deeab2f639 100644 --- a/src/devices/video/fixfreq.h +++ b/src/devices/video/fixfreq.h @@ -123,7 +123,7 @@ struct fixedfreq_monitor_state fixedfreq_monitor_state(fixedfreq_monitor_desc &desc, fixedfreq_monitor_intf &intf) : m_desc(desc), m_intf(intf), - m_last_sync(0), + m_last_sync_val(0), m_col(0), m_last_x(0), m_last_y(0), @@ -145,7 +145,7 @@ struct fixedfreq_monitor_state // FIXME: once moved to netlist this may no longer be necessary. // Only copies constructor init - m_last_sync = 0.0; + m_last_sync_val = 0.0; m_col = rgb_t(0,0,0); m_last_x = 0; m_last_y = 0; @@ -177,18 +177,11 @@ struct fixedfreq_monitor_state void reset() { - m_last_sync = 0; + m_last_sync_val = 0; m_col = 0; m_last_x = 0; m_last_y = 0; - //m_last_sync_time = time_type(0); - //m_line_time = time_type(0); - //m_last_hsync_time = time_type(0); - //m_last_vsync_time = time_type(0); - //m_clock_period = time_type(0); m_vsync_filter = 0; - //m_vsync_threshold = 0; - //m_vsync_filter_timeconst = 0; m_sig_vsync = 0; m_sig_composite = 0; m_sig_field = 0; @@ -206,7 +199,7 @@ struct fixedfreq_monitor_state const fixedfreq_monitor_desc &m_desc; fixedfreq_monitor_intf &m_intf; - double m_last_sync; + double m_last_sync_val; uint32_t m_col; float m_last_x; int m_last_y; diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index de2a69a23f7..12a8ce3ffa1 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -126,6 +126,14 @@ namespace analog m_N.set_go_gt_I(a21, a22, rhs2); } + void clear_mat() const noexcept + { + const auto z = nlconst::zero(); + // GO, GT, I + m_P.set_go_gt_I(z, z, z); + m_N.set_go_gt_I(z, z, z); + } + /// \brief Get a const reference to the m_P terminal /// /// This is typically called during initialization to connect @@ -317,6 +325,7 @@ namespace analog NETLIB_RESETI() { m_cap.setparams(exec().gmin()); + clear_mat(); } /// \brief Set capacitance diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index f5e276c7601..f546056ec30 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -272,19 +272,24 @@ namespace netlist log().debug("Searching for solver\n"); m_solver = m_state.get_single_device("solver"); - m_time = netlist_time_ext::zero(); + // Don't reset time + //m_time = netlist_time_ext::zero(); m_queue.clear(); if (m_mainclock != nullptr) - m_mainclock->m_Q.net().set_next_scheduled_time(netlist_time_ext::zero()); + m_mainclock->m_Q.net().set_next_scheduled_time(m_time); //if (m_solver != nullptr) // m_solver->reset(); m_state.reset(); } - void netlist_state_t::reset() + void netlist_state_t::free_setup_resources() { m_setup = nullptr; + } + + void netlist_state_t::reset() + { // Reset all nets once ! log().verbose("Call reset on all nets:"); for (auto & n : nets()) @@ -637,7 +642,7 @@ namespace netlist void detail::net_t::reset() noexcept { - m_next_scheduled_time = netlist_time_ext::zero(); + m_next_scheduled_time = exec().time(); m_in_queue = queue_status::DELIVERED; m_new_Q = 0; @@ -680,6 +685,11 @@ namespace netlist { } + void analog_net_t::reset() noexcept + { + net_t::reset(); + m_cur_Analog = nlconst::zero(); + } // ---------------------------------------------------------------------------------------- // core_terminal_t // ---------------------------------------------------------------------------------------- diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 4e2c84794dc..0891e81c6b4 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -691,7 +691,7 @@ namespace netlist virtual ~net_t() noexcept = default; - void reset() noexcept; + virtual void reset() noexcept; void toggle_new_Q() noexcept { m_new_Q = (m_cur_Q ^ 1); } @@ -952,6 +952,8 @@ namespace netlist analog_net_t(netlist_state_t &nl, const pstring &aname, detail::core_terminal_t *railterminal = nullptr); + void reset() noexcept override; + nl_fptype Q_Analog() const noexcept { return m_cur_Analog; } void set_Q_Analog(nl_fptype v) noexcept { m_cur_Analog = v; } // used by solver code ... @@ -1744,8 +1746,14 @@ namespace netlist /// void print_stats(stats_info &si) const; + /// \brief call reset on all netlist components + /// void reset(); + /// \brief prior to running free no longer needed resources + /// + void free_setup_resources(); + private: device_arena m_pool; // must be deleted last! @@ -1785,10 +1793,7 @@ namespace netlist m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two())); } - NETLIB_RESETI() - { - m_Q.net().set_next_scheduled_time(netlist_time_ext::zero()); - } + NETLIB_RESETI(); NETLIB_UPDATE_PARAMI() { @@ -2147,6 +2152,14 @@ namespace netlist analog_input_t m_GND; }; + namespace devices + { + inline NETLIB_RESET(mainclock) + { + m_Q.net().set_next_scheduled_time(exec().time()); + } + } // namespace devices + // ----------------------------------------------------------------------------- // Hot section // diff --git a/src/lib/netlist/nl_interface.h b/src/lib/netlist/nl_interface.h index dba7bd5248a..fc87855d014 100644 --- a/src/lib/netlist/nl_interface.h +++ b/src/lib/netlist/nl_interface.h @@ -149,14 +149,13 @@ namespace netlist , m_param_offsets(*this, 0, "OFFSET{}", 0.0) { connect(m_feedback, m_Q); + for (auto & elem : m_buffers) + elem = nullptr; } protected: NETLIB_RESETI() { - m_pos = 0; - for (auto & elem : m_buffers) - elem = nullptr; } NETLIB_UPDATEI() @@ -232,8 +231,8 @@ namespace netlist object_array_t m_param_names; object_array_t m_param_mults; object_array_t m_param_offsets; - std::array m_params; - std::array m_buffers; + std::array m_params; + std::array m_buffers; }; } // namespace interface diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index d849e15c755..a4946c00d3e 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -478,6 +478,7 @@ void tool_app_t::run() // Inputs must be read before reset -> will clear setup and parser inps = read_input(nt.setup(), opt_inp()); + nt.free_setup_resources(); nt.exec().reset(); ttr = netlist::netlist_time_ext::from_fp(opt_ttr()); @@ -608,6 +609,7 @@ void tool_app_t::compile_one_and_add_to_map(const pstring &file, // need to reset ... + nt.free_setup_resources(); nt.exec().reset(); auto mp(nt.exec().solver()->create_solver_code(target)); diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index ec457b934d3..10ce81754ec 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -428,7 +428,7 @@ namespace solver void matrix_solver_t::reset() { - m_last_step = netlist_time_ext::zero(); + //m_last_step = netlist_time_ext::zero(); } void matrix_solver_t::step(netlist_time delta) noexcept