diff options
author | couriersud <couriersud@gmx.org> | 2020-05-25 23:57:16 +0200 |
---|---|---|
committer | couriersud <couriersud@gmx.org> | 2020-05-25 23:57:49 +0200 |
commit | 54293ab546ae60f5493eb09368de207c17870284 (patch) | |
tree | ffa909de2c79d30186c8fceee12c3dc4ac05733f | |
parent | e97a8709a8bd73ccd5b37ab4848fd685098b1936 (diff) |
netlist: small memory system cleanup. (nw)
-rw-r--r-- | src/devices/machine/netlist.cpp | 10 | ||||
-rw-r--r-- | src/lib/netlist/devices/nld_74125.cpp | 2 | ||||
-rw-r--r-- | src/lib/netlist/devices/nld_7448.cpp | 4 | ||||
-rw-r--r-- | src/lib/netlist/devices/nlid_system.h | 7 | ||||
-rw-r--r-- | src/lib/netlist/devices/nlid_truthtable.cpp | 196 | ||||
-rw-r--r-- | src/lib/netlist/devices/nlid_truthtable.h | 222 | ||||
-rw-r--r-- | src/lib/netlist/nl_base.cpp | 5 | ||||
-rw-r--r-- | src/lib/netlist/nl_base.h | 10 | ||||
-rwxr-xr-x | src/lib/netlist/nl_setup.cpp | 8 | ||||
-rw-r--r-- | src/lib/netlist/plib/palloc.h | 19 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.cpp | 2 |
11 files changed, 245 insertions, 240 deletions
diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index 295c6e6fd4c..8b3971acf2e 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -535,9 +535,9 @@ public: for (int i = 0; i < MAX_INPUT_CHANNELS; i++) { - m_channels[i].m_param_name = anetlist.make_object<netlist::param_str_t>(*this, plib::pfmt("CHAN{1}")(i), ""); - m_channels[i].m_param_mult = anetlist.make_object<netlist::param_fp_t>(*this, plib::pfmt("MULT{1}")(i), 1.0); - m_channels[i].m_param_offset = anetlist.make_object<netlist::param_fp_t>(*this, plib::pfmt("OFFSET{1}")(i), 0.0); + m_channels[i].m_param_name = anetlist.make_pool_object<netlist::param_str_t>(*this, plib::pfmt("CHAN{1}")(i), ""); + m_channels[i].m_param_mult = anetlist.make_pool_object<netlist::param_fp_t>(*this, plib::pfmt("MULT{1}")(i), 1.0); + m_channels[i].m_param_offset = anetlist.make_pool_object<netlist::param_fp_t>(*this, plib::pfmt("OFFSET{1}")(i), 0.0); } } @@ -808,7 +808,7 @@ void netlist_mame_analog_output_device::custom_netlist_additions(netlist::netlis if (owner()->has_running_machine()) m_delegate.resolve(); - auto dev = nlstate.make_object<NETLIB_NAME(analog_callback)>(nlstate, dname); + auto dev = nlstate.make_pool_object<NETLIB_NAME(analog_callback)>(nlstate, dname); dev->register_callback(std::move(m_delegate)); nlstate.register_device(dname, std::move(dev)); nlstate.parser().register_link(dname + ".IN", pin); @@ -841,7 +841,7 @@ void netlist_mame_logic_output_device::custom_netlist_additions(netlist::netlist if (owner()->has_running_machine()) m_delegate.resolve(); - auto dev = nlstate.make_object<NETLIB_NAME(logic_callback)>(nlstate, dname); + auto dev = nlstate.make_pool_object<NETLIB_NAME(logic_callback)>(nlstate, dname); dev->register_callback(std::move(m_delegate)); nlstate.register_device(dname, std::move(dev)); nlstate.parser().register_link(dname + ".IN", pin); diff --git a/src/lib/netlist/devices/nld_74125.cpp b/src/lib/netlist/devices/nld_74125.cpp index 4a8f7960ff8..244ff1d1fc1 100644 --- a/src/lib/netlist/devices/nld_74125.cpp +++ b/src/lib/netlist/devices/nld_74125.cpp @@ -21,7 +21,7 @@ namespace netlist template<typename O, typename... Args> uptr(O &owner, const pstring &name, Args&&... args) - : unique_pool_ptr<T>(owner.template make_object<T>(owner, name, std::forward<Args>(args)...)) + : unique_pool_ptr<T>(owner.template make_pool_object<T>(owner, name, std::forward<Args>(args)...)) { } C14CONSTEXPR auto operator ()() noexcept -> decltype((*unique_pool_ptr<T>::get())()) { return (*this->get())(); } diff --git a/src/lib/netlist/devices/nld_7448.cpp b/src/lib/netlist/devices/nld_7448.cpp index 80314db4ee1..150bfa3acfc 100644 --- a/src/lib/netlist/devices/nld_7448.cpp +++ b/src/lib/netlist/devices/nld_7448.cpp @@ -5,8 +5,8 @@ * */ -#include "nld_7448.h" -#include "nlid_truthtable.h" +#include "nl_base.h" +#include "nl_factory.h" #include <array> diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 1993f4b1adb..cc102f18521 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -353,7 +353,7 @@ namespace devices for (int i=0; i < m_N(); i++) { pstring inpname = plib::pfmt("A{1}")(i); - m_I.push_back(state().make_object<analog_input_t>(*this, inpname)); + m_I.push_back(state().make_pool_object<analog_input_t>(*this, inpname)); inps.push_back(inpname); m_vals.push_back(nlconst::zero()); } @@ -376,13 +376,14 @@ namespace devices } private: + using pf_type = plib::pfunction<nl_fptype>; param_int_t m_N; param_str_t m_func; analog_output_t m_Q; std::vector<unique_pool_ptr<analog_input_t>> m_I; - std::vector<nl_fptype> m_vals; - state_var<plib::pfunction<nl_fptype>> m_compiled; + pf_type::values_container m_vals; + state_var<pf_type> m_compiled; }; diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index bc1fe256324..094517d2c73 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -1,10 +1,9 @@ // license:GPL-2.0+ // copyright-holders:Couriersud +#include "nl_base.h" +#include "nl_factory.h" #include "nlid_truthtable.h" -#include "netlist/nl_factory.h" -#include "plib/palloc.h" -#include "plib/plists.h" #include <bitset> #include <cstdint> @@ -15,6 +14,197 @@ namespace netlist namespace devices { + template<std::size_t m_NI, std::size_t m_NO> + class NETLIB_NAME(truthtable_t) : public device_t + { + public: + + using type_t = typename plib::fast_type_for_bits<m_NO + m_NI>::type; + + static constexpr const std::size_t m_num_bits = m_NI; + static constexpr const std::size_t m_size = (1 << (m_num_bits)); + static constexpr const type_t m_outmask = ((1 << m_NO) - 1); + + struct truthtable_t + { + truthtable_t() + : m_timing_index{0} + {} + + std::array<type_t, m_size> m_out_state; + std::array<uint_least8_t, m_size * m_NO> m_timing_index; + std::array<netlist_time, 16> m_timing_nt; + }; + + template <class C> + nld_truthtable_t(C &owner, const pstring &name, + const pstring &model, + truthtable_t &ttp, const std::vector<pstring> &desc) + : device_t(owner, name, model) +#if USE_TT_ALTERNATIVE + , m_state(*this, "m_state", 0) +#endif + , m_ign(*this, "m_ign", 0) + , m_ttp(ttp) + /* FIXME: the family should provide the names of the power-terminals! */ + , m_power_pins(*this) + { + init(desc); + } + + void init(const std::vector<pstring> &desc); + + NETLIB_RESETI() + { + int active_outputs = 0; + m_ign = 0; +#if USE_TT_ALTERNATIVE + m_state = 0; +#endif + for (std::size_t i = 0; i < m_NI; ++i) + { + m_I[i].activate(); +#if USE_TT_ALTERNATIVE + m_state |= (m_I[i]() << i); +#endif + } + for (auto &q : m_Q) + if (q.has_net() && q.net().has_connections()) + active_outputs++; + set_active_outputs(active_outputs); + } + + // update is only called during startup here ... + NETLIB_UPDATEI() + { +#if USE_TT_ALTERNATIVE + m_state = 0; + for (std::size_t i = 0; i < m_NI; ++i) + { + m_state |= (m_I[i]() << i); + } +#endif + process<true>(); + } + +#if USE_TT_ALTERNATIVE + template <std::size_t N> + void update_N() noexcept + { + m_state &= ~(1<<N); + m_state |= (m_I[N]() << N); + process<true>(); + } +#endif + + void inc_active() noexcept override + { + process<false>(); + } + + void dec_active() noexcept override + { + for (std::size_t i = 0; i< m_NI; i++) + m_I[i].inactivate(); + m_ign = (1<<m_NI)-1; + } + + protected: + + private: + + template<bool doOUT> + void process() noexcept + { + netlist_time_ext mt(netlist_time_ext::zero()); + type_t nstate(0); + type_t ign(m_ign); + + if (doOUT) + { +#if !USE_TT_ALTERNATIVE + for (auto I = m_I.begin(); ign != 0; ign >>= 1, ++I) + if (ign & 1) + I->activate(); + for (std::size_t i = 0; i < m_NI; i++) + nstate |= (m_I[i]() << i); +#else + nstate = m_state; + for (std::size_t i = 0; ign != 0; ign >>= 1, ++i) + { + if (ign & 1) + { + nstate &= ~(1 << i); + m_I[i].activate(); + nstate |= (m_I[i]() << i); + } + } +#endif + } + else + for (std::size_t i = 0; i < m_NI; i++) + { + m_I[i].activate(); + nstate |= (m_I[i]() << i); + mt = std::max(this->m_I[i].net().next_scheduled_time(), mt); + } + + const type_t outstate(m_ttp.m_out_state[nstate]); + type_t out(outstate & m_outmask); + + m_ign = outstate >> m_NO; + + const auto *t(&m_ttp.m_timing_index[nstate * m_NO]); + + if (doOUT) + //for (std::size_t i = 0; i < m_NO; ++i) + // m_Q[i].push((out >> i) & 1, tim[t[i]]); + this->push(out, t); + else + { + const auto *tim = m_ttp.m_timing_nt.data(); + for (std::size_t i = 0; i < m_NO; ++i) + m_Q[i].set_Q_time((out >> i) & 1, mt + tim[t[i]]); + } + + ign = m_ign; + for (auto I = m_I.begin(); ign != 0; ign >>= 1, ++I) + if (ign & 1) + I->inactivate(); +#if USE_TT_ALTERNATIVE + m_state = nstate; +#endif + } + + template<typename T> + void push(const T &v, const std::uint_least8_t * t) + { + if (m_NO >= 1) m_Q[0].push((v >> 0) & 1, m_ttp.m_timing_nt[t[0]]); + if (m_NO >= 2) m_Q[1].push((v >> 1) & 1, m_ttp.m_timing_nt[t[1]]); + if (m_NO >= 3) m_Q[2].push((v >> 2) & 1, m_ttp.m_timing_nt[t[2]]); + if (m_NO >= 4) m_Q[3].push((v >> 3) & 1, m_ttp.m_timing_nt[t[3]]); + if (m_NO >= 5) m_Q[4].push((v >> 4) & 1, m_ttp.m_timing_nt[t[4]]); + if (m_NO >= 6) m_Q[5].push((v >> 5) & 1, m_ttp.m_timing_nt[t[5]]); + if (m_NO >= 7) m_Q[6].push((v >> 6) & 1, m_ttp.m_timing_nt[t[6]]); + if (m_NO >= 8) m_Q[7].push((v >> 7) & 1, m_ttp.m_timing_nt[t[7]]); + for (std::size_t i = 8; i < m_NO; i++) + m_Q[i].push((v >> i) & 1, m_ttp.m_timing_nt[t[i]]); + } + + + plib::uninitialised_array_t<logic_input_t, m_NI> m_I; + plib::uninitialised_array_t<logic_output_t, m_NO> m_Q; + +#if USE_TT_ALTERNATIVE + state_var<type_t> m_state; +#endif + state_var<type_t> m_ign; + const truthtable_t m_ttp; + /* FIXME: the family should provide the names of the power-terminals! */ + nld_power_pins m_power_pins; + }; + + // ---------------------------------------------------------------------------------------- // int compatible bitset .... // ---------------------------------------------------------------------------------------- diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index 2e8ae3fe348..14ee3d00624 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -8,228 +8,28 @@ #ifndef NLID_TRUTHTABLE_H_ #define NLID_TRUTHTABLE_H_ -#include "netlist/devices/nlid_system.h" -#include "netlist/nl_base.h" -#include "netlist/nl_setup.h" -#include "plib/ptypes.h" -#include "plib/putil.h" +#include "nl_factory.h" +#include "nl_setup.h" #define USE_TT_ALTERNATIVE (0) namespace netlist { -namespace devices -{ - - template<std::size_t m_NI, std::size_t m_NO> - class NETLIB_NAME(truthtable_t) : public device_t + namespace factory { - public: - - using type_t = typename plib::fast_type_for_bits<m_NO + m_NI>::type; - - static constexpr const std::size_t m_num_bits = m_NI; - static constexpr const std::size_t m_size = (1 << (m_num_bits)); - static constexpr const type_t m_outmask = ((1 << m_NO) - 1); - - struct truthtable_t + class truthtable_base_element_t : public factory::element_t { - truthtable_t() - : m_timing_index{0} - {} + public: + truthtable_base_element_t(const pstring &name,properties &&props); - std::array<type_t, m_size> m_out_state; - std::array<uint_least8_t, m_size * m_NO> m_timing_index; - std::array<netlist_time, 16> m_timing_nt; + std::vector<pstring> m_desc; + pstring m_family_name; }; - template <class C> - nld_truthtable_t(C &owner, const pstring &name, - const pstring &model, - truthtable_t &ttp, const std::vector<pstring> &desc) - : device_t(owner, name, model) -#if USE_TT_ALTERNATIVE - , m_state(*this, "m_state", 0) -#endif - , m_ign(*this, "m_ign", 0) - , m_ttp(ttp) - /* FIXME: the family should provide the names of the power-terminals! */ - , m_power_pins(*this) - { - init(desc); - } - - void init(const std::vector<pstring> &desc); - - NETLIB_RESETI() - { - int active_outputs = 0; - m_ign = 0; -#if USE_TT_ALTERNATIVE - m_state = 0; -#endif - for (std::size_t i = 0; i < m_NI; ++i) - { - m_I[i].activate(); -#if USE_TT_ALTERNATIVE - m_state |= (m_I[i]() << i); -#endif - } - for (auto &q : m_Q) - if (q.has_net() && q.net().has_connections()) - active_outputs++; - set_active_outputs(active_outputs); - } - - // update is only called during startup here ... - NETLIB_UPDATEI() - { -#if USE_TT_ALTERNATIVE - m_state = 0; - for (std::size_t i = 0; i < m_NI; ++i) - { - m_state |= (m_I[i]() << i); - } -#endif - process<true>(); - } - -#if USE_TT_ALTERNATIVE - template <std::size_t N> - void update_N() noexcept - { - m_state &= ~(1<<N); - m_state |= (m_I[N]() << N); - process<true>(); - } -#endif - - void inc_active() noexcept override - { - process<false>(); - } - - void dec_active() noexcept override - { - for (std::size_t i = 0; i< m_NI; i++) - m_I[i].inactivate(); - m_ign = (1<<m_NI)-1; - } - - protected: - - private: - - template<bool doOUT> - void process() noexcept - { - netlist_time_ext mt(netlist_time_ext::zero()); - type_t nstate(0); - type_t ign(m_ign); - - if (doOUT) - { -#if !USE_TT_ALTERNATIVE - for (auto I = m_I.begin(); ign != 0; ign >>= 1, ++I) - if (ign & 1) - I->activate(); - for (std::size_t i = 0; i < m_NI; i++) - nstate |= (m_I[i]() << i); -#else - nstate = m_state; - for (std::size_t i = 0; ign != 0; ign >>= 1, ++i) - { - if (ign & 1) - { - nstate &= ~(1 << i); - m_I[i].activate(); - nstate |= (m_I[i]() << i); - } - } -#endif - } - else - for (std::size_t i = 0; i < m_NI; i++) - { - m_I[i].activate(); - nstate |= (m_I[i]() << i); - mt = std::max(this->m_I[i].net().next_scheduled_time(), mt); - } - - const type_t outstate(m_ttp.m_out_state[nstate]); - type_t out(outstate & m_outmask); - - m_ign = outstate >> m_NO; - - const auto *t(&m_ttp.m_timing_index[nstate * m_NO]); - - if (doOUT) - //for (std::size_t i = 0; i < m_NO; ++i) - // m_Q[i].push((out >> i) & 1, tim[t[i]]); - this->push(out, t); - else - { - const auto *tim = m_ttp.m_timing_nt.data(); - for (std::size_t i = 0; i < m_NO; ++i) - m_Q[i].set_Q_time((out >> i) & 1, mt + tim[t[i]]); - } - - ign = m_ign; - for (auto I = m_I.begin(); ign != 0; ign >>= 1, ++I) - if (ign & 1) - I->inactivate(); -#if USE_TT_ALTERNATIVE - m_state = nstate; -#endif - } - - template<typename T> - void push(const T &v, const std::uint_least8_t * t) - { - if (m_NO >= 1) m_Q[0].push((v >> 0) & 1, m_ttp.m_timing_nt[t[0]]); - if (m_NO >= 2) m_Q[1].push((v >> 1) & 1, m_ttp.m_timing_nt[t[1]]); - if (m_NO >= 3) m_Q[2].push((v >> 2) & 1, m_ttp.m_timing_nt[t[2]]); - if (m_NO >= 4) m_Q[3].push((v >> 3) & 1, m_ttp.m_timing_nt[t[3]]); - if (m_NO >= 5) m_Q[4].push((v >> 4) & 1, m_ttp.m_timing_nt[t[4]]); - if (m_NO >= 6) m_Q[5].push((v >> 5) & 1, m_ttp.m_timing_nt[t[5]]); - if (m_NO >= 7) m_Q[6].push((v >> 6) & 1, m_ttp.m_timing_nt[t[6]]); - if (m_NO >= 8) m_Q[7].push((v >> 7) & 1, m_ttp.m_timing_nt[t[7]]); - for (std::size_t i = 8; i < m_NO; i++) - m_Q[i].push((v >> i) & 1, m_ttp.m_timing_nt[t[i]]); - } - + plib::unique_ptr<truthtable_base_element_t> truthtable_create(tt_desc &desc, + properties &&props); - plib::uninitialised_array_t<logic_input_t, m_NI> m_I; - plib::uninitialised_array_t<logic_output_t, m_NO> m_Q; - -#if USE_TT_ALTERNATIVE - state_var<type_t> m_state; -#endif - state_var<type_t> m_ign; - const truthtable_t m_ttp; - /* FIXME: the family should provide the names of the power-terminals! */ - nld_power_pins m_power_pins; - }; - -} // namespace devices - -namespace factory -{ - class truthtable_base_element_t : public factory::element_t - { - public: - truthtable_base_element_t(const pstring &name,properties &&props); - - std::vector<pstring> m_desc; - pstring m_family_name; - }; - - plib::unique_ptr<truthtable_base_element_t> truthtable_create(tt_desc &desc, - properties &&props); - -} // namespace factory + } // namespace factory } // namespace netlist - - #endif // NLID_TRUTHTABLE_H_ diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 8297b9aff51..30f13b9cfe6 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -484,7 +484,7 @@ namespace netlist , m_active_outputs(*this, "m_active_outputs", 1) { if (exec().stats_enabled()) - m_stats = owner.make_object<stats_t>(); + m_stats = owner.make_pool_object<stats_t>(); } core_device_t::core_device_t(core_device_t &owner, const pstring &name) @@ -492,9 +492,10 @@ namespace netlist , m_hint_deactivate(false) , m_active_outputs(*this, "m_active_outputs", 1) { + //printf("owned device: %s\n", this->name().c_str()); owner.state().register_device(this->name(), owned_pool_ptr<core_device_t>(this, false)); if (exec().stats_enabled()) - m_stats = owner.state().make_object<stats_t>(); + m_stats = owner.state().make_pool_object<stats_t>(); } void core_device_t::set_default_delegate(detail::core_terminal_t &term) diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 99314f58321..f61c7007941 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -575,7 +575,7 @@ namespace netlist // to ease template design template<typename T, typename... Args> - unique_pool_ptr<T> make_object(Args&&... args); + unique_pool_ptr<T> make_pool_object(Args&&... args); private: netlist_t & m_netlist; @@ -1753,7 +1753,7 @@ namespace netlist family_collection_type &family_cache() { return m_family_cache; } template<typename T, typename... Args> - unique_pool_ptr<T> make_object(Args&&... args) + unique_pool_ptr<T> make_pool_object(Args&&... args) { return m_pool.make_unique<T>(std::forward<Args>(args)...); } @@ -2476,9 +2476,9 @@ namespace netlist } template<typename T, typename... Args> - inline unique_pool_ptr<T> detail::netlist_object_t::make_object(Args&&... args) + inline unique_pool_ptr<T> detail::netlist_object_t::make_pool_object(Args&&... args) { - return state().make_object<T>(std::forward<Args>(args)...); + return state().make_pool_object<T>(std::forward<Args>(args)...); } inline void param_t::update_param() noexcept @@ -2546,7 +2546,7 @@ namespace netlist template<class O, class C, typename... Args> void base_device_t::create_and_register_subdevice(O &owner, const pstring &name, unique_pool_ptr<C> &dev, Args&&... args) { - dev = state().make_object<C>(owner, name, std::forward<Args>(args)...); + dev = state().make_pool_object<C>(owner, name, std::forward<Args>(args)...); } inline netlist_state_t &detail::device_object_t::state() noexcept diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 179d8684082..fc34942e734 100755 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -1314,9 +1314,9 @@ public: case family_type::CMOS: case family_type::NMOS: case family_type::PMOS: - return anetlist.make_object<devices::nld_d_to_a_proxy>(anetlist, name, proxied); + return anetlist.make_pool_object<devices::nld_d_to_a_proxy>(anetlist, name, proxied); } - return anetlist.make_object<devices::nld_d_to_a_proxy>(anetlist, name, proxied); + return anetlist.make_pool_object<devices::nld_d_to_a_proxy>(anetlist, name, proxied); } unique_pool_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, const logic_input_t *proxied) const override @@ -1329,9 +1329,9 @@ public: case family_type::CMOS: case family_type::NMOS: case family_type::PMOS: - return anetlist.make_object<devices::nld_a_to_d_proxy>(anetlist, name, proxied); + return anetlist.make_pool_object<devices::nld_a_to_d_proxy>(anetlist, name, proxied); } - return anetlist.make_object<devices::nld_a_to_d_proxy>(anetlist, name, proxied); + return anetlist.make_pool_object<devices::nld_a_to_d_proxy>(anetlist, name, proxied); } private: family_type m_family_type; diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 0537305adbd..4adf287196d 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -247,6 +247,19 @@ namespace plib { m_a.deallocate(p, n); } + template<typename U, typename... Args> + void construct(U* p, Args&&... args) + { + // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) + ::new (static_cast<void *>(p)) U(std::forward<Args>(args)...); + } + + template<typename U> + void destroy(U* p) + { + p->~U(); + } + template <class AR1, class T1, std::size_t A1, class AR2, class T2, std::size_t A2> friend bool operator==(const arena_allocator<AR1, T1, A1>& lhs, // NOLINT const arena_allocator<AR2, T2, A2>& rhs) noexcept; @@ -459,11 +472,11 @@ namespace plib { //============================================================ // FIXME: needs a separate file - template <class T, std::size_t ALIGN = PALIGN_VECTOROPT> - class aligned_vector : public std::vector<T, aligned_allocator<T, ALIGN>> + template <typename T, std::size_t ALIGN = PALIGN_VECTOROPT, typename A = aligned_allocator<T, ALIGN>> + class aligned_vector : public std::vector<T, A> { public: - using base = std::vector<T, aligned_allocator<T, ALIGN>>; + using base = std::vector<T, A>; using reference = typename base::reference; using const_reference = typename base::const_reference; diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 11c8a60df60..b5b2adf2245 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -121,7 +121,7 @@ namespace solver { pstring nname(this->name() + "." + pstring(plib::pfmt("m{1}")(m_inps.size()))); nl_assert(p->net().is_analog()); - auto net_proxy_output_u = state().make_object<proxied_analog_output_t>(*this, nname, static_cast<analog_net_t *>(&p->net())); + auto net_proxy_output_u = state().make_pool_object<proxied_analog_output_t>(*this, nname, static_cast<analog_net_t *>(&p->net())); net_proxy_output = net_proxy_output_u.get(); m_inps.emplace_back(std::move(net_proxy_output_u)); } |