diff options
author | 2020-10-02 19:57:29 +0200 | |
---|---|---|
committer | 2020-10-02 19:58:31 +0200 | |
commit | c797d55aafead48ec97baa4b6314d72aca6dec72 (patch) | |
tree | b6dc4fe75cdc2770f859eaf98ce4090457c81ddf | |
parent | fe47fcf9f193f1a2ffb4d3eedfd134ff6b216e62 (diff) |
netlist: move core_terms to netlist_state.
* These are used during creation and reset only. No need to
maintain them on net_t level.
-rw-r--r-- | src/lib/netlist/core/netlist_state.h | 7 | ||||
-rw-r--r-- | src/lib/netlist/core/nets.h | 35 | ||||
-rw-r--r-- | src/lib/netlist/devices/nlid_truthtable.cpp | 2 | ||||
-rw-r--r-- | src/lib/netlist/nl_base.cpp | 8 | ||||
-rw-r--r-- | src/lib/netlist/nl_setup.cpp | 31 | ||||
-rw-r--r-- | src/lib/netlist/plib/pconfig.h | 5 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.cpp | 10 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_solver.cpp | 34 |
8 files changed, 71 insertions, 61 deletions
diff --git a/src/lib/netlist/core/netlist_state.h b/src/lib/netlist/core/netlist_state.h index dc9888579f5..fd0a1449217 100644 --- a/src/lib/netlist/core/netlist_state.h +++ b/src/lib/netlist/core/netlist_state.h @@ -236,6 +236,11 @@ namespace netlist /// void free_setup_resources(); + std::vector<detail::core_terminal_t *> &core_terms(const detail::net_t &net) noexcept + { + return m_core_terms[&net]; + } + private: device_arena m_pool; // must be deleted last! @@ -253,6 +258,8 @@ namespace netlist devices_collection_type m_devices; // sole use is to manage lifetime of family objects family_collection_type m_family_cache; + // all terms for a net + std::unordered_map<const detail::net_t *, std::vector<detail::core_terminal_t *>> m_core_terms; // dummy version int m_dummy_version; }; diff --git a/src/lib/netlist/core/nets.h b/src/lib/netlist/core/nets.h index 8fe7ab6bb3c..7062f1572aa 100644 --- a/src/lib/netlist/core/nets.h +++ b/src/lib/netlist/core/nets.h @@ -67,29 +67,26 @@ namespace netlist void push_to_queue(const netlist_time &delay) noexcept { - if (has_connections()) - { - if (!!is_queued()) - exec().qremove(this); + if (!!is_queued()) + exec().qremove(this); - m_next_scheduled_time = exec().time() + delay; + m_next_scheduled_time = exec().time() + delay; #if (AVOID_NOOP_QUEUE_PUSHES) m_in_queue = (m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE : (m_new_Q != m_cur_Q ? queue_status::QUEUED : queue_status::DELIVERED)); - if (m_in_queue == queue_status::QUEUED) - exec().qpush(m_next_scheduled_time, this); + if (m_in_queue == queue_status::QUEUED) + exec().qpush(m_next_scheduled_time, this); else update_inputs(); #else - m_in_queue = m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE : queue_status::QUEUED; - if (m_in_queue == queue_status::QUEUED) - exec().qpush(m_next_scheduled_time, this); - else - update_inputs(); + m_in_queue = m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE : queue_status::QUEUED; + if (m_in_queue == queue_status::QUEUED) + exec().qpush(m_next_scheduled_time, this); + else + update_inputs(); #endif - } } - bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } + constexpr bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } // ----------------------------------------------------------------------------- // Very hot @@ -138,14 +135,12 @@ namespace netlist } } - const netlist_time_ext &next_scheduled_time() const noexcept { return m_next_scheduled_time; } + constexpr const netlist_time_ext &next_scheduled_time() const noexcept { return m_next_scheduled_time; } void set_next_scheduled_time(netlist_time_ext ntime) noexcept { m_next_scheduled_time = ntime; } bool is_rail_net() const noexcept { return !(m_railterminal == nullptr); } core_terminal_t & railterminal() const noexcept { return *m_railterminal; } - bool has_connections() const noexcept { return !m_core_terms.empty(); } - void add_to_active_list(core_terminal_t &term) noexcept { if (!m_list_active.empty()) @@ -207,7 +202,7 @@ namespace netlist void rebuild_list(); // rebuild m_list after a load - std::vector<core_terminal_t *> &core_terms() noexcept { return m_core_terms; } + //std::vector<core_terminal_t *> &core_terms() noexcept { return state().m_core_terms[this]; } void update_inputs() noexcept { @@ -221,7 +216,7 @@ namespace netlist protected: // only used for logic nets - const netlist_sig_t &Q() const noexcept { return m_cur_Q; } + constexpr const netlist_sig_t &Q() const noexcept { return m_cur_Q; } // only used for logic nets void initial(netlist_sig_t val) noexcept @@ -269,7 +264,7 @@ namespace netlist state_var<netlist_time_ext> m_next_scheduled_time; core_terminal_t * m_railterminal; - 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 ... }; } // namespace detail diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index 74e0f37c92b..db2471a704e 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -75,7 +75,7 @@ namespace devices #endif } for (auto &q : m_Q) - if (q.has_net() && q.net().has_connections()) + if (q.has_net() && !exec().nlstate().core_terms(q.net()).empty()) active_outputs++; set_active_outputs(active_outputs); } diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 2baf96d73fc..165a79f915d 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -245,6 +245,7 @@ namespace netlist ENTRY_EX(sizeof(base_device_t)) ENTRY_EX(sizeof(device_t)) + ENTRY_EX(sizeof(logic_t)) ENTRY_EX(sizeof(logic_input_t)) ENTRY_EX(sizeof(logic_output_t)) ENTRY_EX(sizeof(param_model_t)) @@ -252,6 +253,7 @@ namespace netlist ENTRY_EX(sizeof(state_var<int>)) ENTRY_EX(sizeof(pstring)) ENTRY_EX(sizeof(core_device_t::stats_t)) + ENTRY_EX(sizeof(std::vector<detail::core_terminal_t *>)) ENTRY_EX(sizeof(plib::plog_level)) ENTRY_EX(sizeof(nldelegate)) @@ -337,7 +339,7 @@ namespace netlist for (auto &n : m_nets) { n->update_inputs(); // only used if USE_COPY_INSTEAD_OF_REFERENCE == 1 - for (auto & term : n->core_terms()) + for (auto & term : core_terms(*n)) { if (!plib::container::contains(t, &term->delegate())) { @@ -618,7 +620,7 @@ namespace netlist // rebuild m_list m_list_active.clear(); - for (auto & term : core_terms()) + for (auto & term : exec().nlstate().core_terms(*this)) if (term->terminal_state() != logic_t::STATE_INP_PASSIVE) { m_list_active.push_back(term); @@ -643,7 +645,7 @@ namespace netlist // rebuild m_list and reset terminals to active or analog out state m_list_active.clear(); - for (core_terminal_t *ct : core_terms()) + for (core_terminal_t *ct : exec().nlstate().core_terms(*this)) { ct->reset(); if (ct->terminal_state() != logic_t::STATE_INP_PASSIVE) diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 8392f156117..2247bf111d4 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -732,7 +732,7 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(const detail::core_terminal_t &o m_proxy_cnt++; // connect all existing terminals to new net - for (auto & p : out.net().core_terms()) + for (auto & p : nlstate().core_terms(out.net())) { p->clear_net(); // de-link from all nets ... if (!connect(new_proxy->proxy_term(), *p)) @@ -743,7 +743,7 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(const detail::core_terminal_t &o new_proxy->proxy_term().name(), (*p).name())); } } - out.net().core_terms().clear(); + nlstate().core_terms(out.net()).clear(); add_terminal(out.net(), new_proxy->in()); @@ -784,7 +784,7 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp) if (inp.has_net()) { - for (detail::core_terminal_t * p : inp.net().core_terms()) + for (detail::core_terminal_t * p : nlstate().core_terms(inp.net())) { // inp may already belongs to the logic net. Thus skip it here. // It will be removed by the clear further down. @@ -800,7 +800,7 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp) } } } - inp.net().core_terms().clear(); // clear the list + nlstate().core_terms(inp.net()).clear(); // clear the list } inp.clear_net(); add_terminal(ret->out().net(), inp); @@ -974,7 +974,7 @@ bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_term ret = connect(t2, t1.net().railterminal()); if (!ret) { - for (auto & t : t1.net().core_terms()) + for (auto & t : nlstate().core_terms(t1.net())) { if (t->is_type(detail::terminal_type::TERMINAL)) ret = connect(t2, *t); @@ -989,7 +989,7 @@ bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_term ret = connect(t1, t2.net().railterminal()); if (!ret) { - for (auto & t : t2.net().core_terms()) + for (auto & t : nlstate().core_terms(t2.net())) { if (t->is_type(detail::terminal_type::TERMINAL)) ret = connect(t1, *t); @@ -1175,7 +1175,7 @@ void setup_t::resolve_inputs() log().error(ME_TERMINAL_1_WITHOUT_NET(name_da)); err = true; } - else if (!term->net().has_connections()) + else if (nlstate().core_terms(term->net()).empty()) { if (term->is_logic_input()) log().warning(MW_LOGIC_INPUT_1_WITHOUT_CONNECTIONS(name_da)); @@ -1226,7 +1226,7 @@ void setup_t::resolve_inputs() void setup_t::add_terminal(detail::net_t &net, detail::core_terminal_t &terminal) noexcept(false) { - for (auto &t : net.core_terms()) + for (auto &t : nlstate().core_terms(net)) if (t == &terminal) { log().fatal(MF_NET_1_DUPLICATE_TERMINAL_2(net.name(), t->name())); @@ -1235,15 +1235,15 @@ void setup_t::add_terminal(detail::net_t &net, detail::core_terminal_t &terminal terminal.set_net(&net); - net.core_terms().push_back(&terminal); + nlstate().core_terms(net).push_back(&terminal); } void setup_t::remove_terminal(detail::net_t &net, detail::core_terminal_t &terminal) noexcept(false) { - if (plib::container::contains(net.core_terms(), &terminal)) + if (plib::container::contains(nlstate().core_terms(net), &terminal)) { terminal.set_net(nullptr); - plib::container::remove(net.core_terms(), &terminal); + plib::container::remove(nlstate().core_terms(net), &terminal); } else { @@ -1254,9 +1254,9 @@ void setup_t::remove_terminal(detail::net_t &net, detail::core_terminal_t &termi void setup_t::move_connections(detail::net_t &net, detail::net_t &dest_net) { - for (auto &ct : net.core_terms()) + for (auto &ct : nlstate().core_terms(net)) add_terminal(dest_net, *ct); - net.core_terms().clear(); + nlstate().core_terms(net).clear(); } @@ -1531,8 +1531,9 @@ void setup_t::delete_empty_nets() std::remove_if(m_nlstate.nets().begin(), m_nlstate.nets().end(), [](device_arena::owned_ptr<detail::net_t> &net) { - if (!net->has_connections()) + if (net->state().core_terms(*net).empty()) { + // FIXME: need to remove from state->m_core_terms as well. net->state().log().verbose("Deleting net {1} ...", net->name()); net->state().run_state_manager().remove_save_items(net.get()); return true; @@ -1683,7 +1684,7 @@ void setup_t::prepare_to_run() for (auto &n : m_nlstate.nets()) { - for (auto & term : n->core_terms()) + for (auto & term : m_nlstate.core_terms(*n)) if (!term->delegate()) { log().fatal(MF_DELEGATE_NOT_SET_1(term->name())); diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 8e34b01a3b8..4253ff355b1 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -75,8 +75,13 @@ #define PALIGN_MIN_SIZE (16) +#if (PUSE_ALIGNED_OPTIMIZATIONS) #define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) #define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) +#else +#define PALIGNAS_CACHELINE() +#define PALIGNAS_VECTOROPT() +#endif // FIXME: Breaks mame build on windows mingw due to -Wattribute // also triggers -Wattribute on ARM diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 02cf471b397..944234fa8c8 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -86,15 +86,15 @@ namespace solver for (std::size_t k = 0; k < nets.size(); k++) { - analog_net_t *net = nets[k]; + analog_net_t &net = *nets[k]; - log().debug("adding net with {1} populated connections\n", net->core_terms().size()); + log().debug("adding net with {1} populated connections\n", setup.nlstate().core_terms(net).size()); - net->set_solver(this); + net.set_solver(this); - for (auto &p : net->core_terms()) + for (auto &p : setup.nlstate().core_terms(net)) { - log().debug("{1} {2} {3}\n", p->name(), net->name(), net->is_rail_net()); + log().debug("{1} {2} {3}\n", p->name(), net.name(), net.is_rail_net()); switch (p->type()) { case detail::terminal_type::TERMINAL: diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index ae241566da9..4852ce3391a 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -278,20 +278,20 @@ namespace devices struct net_splitter { - void run(netlist_state_t &netlist) + void run(netlist_state_t &nlstate) { - for (auto & net : netlist.nets()) + for (auto & net : nlstate.nets()) { - netlist.log().verbose("processing {1}", net->name()); - if (!net->is_rail_net() && net->has_connections()) + nlstate.log().verbose("processing {1}", net->name()); + if (!net->is_rail_net() && !nlstate.core_terms(*net).empty()) { - netlist.log().verbose(" ==> not a rail net"); + nlstate.log().verbose(" ==> not a rail net"); // Must be an analog net auto &n = dynamic_cast<analog_net_t &>(*net); if (!already_processed(n)) { groupspre.emplace_back(NETLIB_NAME(solver)::net_list_t()); - process_net(netlist, n); + process_net(nlstate, n); } } } @@ -344,30 +344,30 @@ namespace devices } // NOLINTNEXTLINE(misc-no-recursion) - void process_net(netlist_state_t &netlist, analog_net_t &n) + void process_net(netlist_state_t &nlstate, analog_net_t &n) { // ignore empty nets. FIXME: print a warning message - netlist.log().verbose("Net {}", n.name()); - if (n.has_connections()) + nlstate.log().verbose("Net {}", n.name()); + if (!nlstate.core_terms(n).empty()) { // add the net groupspre.back().push_back(&n); // process all terminals connected to this net - for (auto &term : n.core_terms()) + for (auto &term : nlstate.core_terms(n)) { - netlist.log().verbose("Term {} {}", term->name(), static_cast<int>(term->type())); + nlstate.log().verbose("Term {} {}", term->name(), static_cast<int>(term->type())); // only process analog terminals if (term->is_type(detail::terminal_type::TERMINAL)) { auto &pt = dynamic_cast<terminal_t &>(*term); // check the connected terminal - const auto *const connected_terminals = netlist.setup().get_connected_terminals(pt); + const auto *const connected_terminals = nlstate.setup().get_connected_terminals(pt); for (const auto *ct = connected_terminals->begin(); *ct != nullptr; ct++) { analog_net_t &connected_net = (*ct)->net(); - netlist.log().verbose(" Connected net {}", connected_net.name()); + nlstate.log().verbose(" Connected net {}", connected_net.name()); if (!check_if_processed_and_join(connected_net)) - process_net(netlist, connected_net); + process_net(nlstate, connected_net); } } } @@ -407,7 +407,7 @@ namespace devices state().log().error(ME_SOLVER_CONSISTENCY_RAIL_NET(n->name())); num_errors++; } - for (const auto &t : n->core_terms()) + for (const auto &t : state().core_terms(*n)) { if (!t->has_net()) { @@ -472,9 +472,9 @@ namespace devices for (auto &n : grp) { log().verbose("Net {1}", n->name()); - for (const auto &pcore : n->core_terms()) + for (const auto &t : state().core_terms(*n)) { - log().verbose(" {1}", pcore->name()); + log().verbose(" {1}", t->name()); } } |