From f011567c77896f657e3c802b2fb6d9ccaad00a12 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 9 Apr 2017 13:24:12 +0200 Subject: Parametrized device activation in truthtables. (nw) --- src/lib/netlist/devices/nlid_truthtable.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index 84f49f7c305..92e1b6d49ed 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -67,9 +67,10 @@ namespace netlist typedef typename uint_for_size::value>::type type_t; - static constexpr std::size_t m_num_bits = m_NI; - static constexpr std::size_t m_size = (1 << (m_num_bits)); - static constexpr type_t m_outmask = ((1 << m_NO) - 1); + 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); + static constexpr const std::size_t m_min_devices_for_deactivate = 2; struct truthtable_t { @@ -115,7 +116,7 @@ namespace netlist void inc_active() NL_NOEXCEPT override { - if (m_NI > 1) + if (m_NI >= m_min_devices_for_deactivate) if (++m_active == 1) { process(); @@ -130,7 +131,7 @@ namespace netlist * can decide for each individual gate whether it is beneficial to * ignore deactivation. */ - if (m_NI > 1) + if (m_NI >= m_min_devices_for_deactivate) if (--m_active == 0) { for (std::size_t i = 0; i< m_NI; i++) @@ -152,7 +153,7 @@ namespace netlist netlist_time mt(netlist_time::zero()); type_t nstate(0); - if (m_NI > 1) + if (m_NI >= m_min_devices_for_deactivate) { type_t ign(m_ign); if (!doOUT) @@ -174,13 +175,14 @@ namespace netlist else { if (!doOUT) - { - nstate |= m_I[0](); - //mt = std::max(this->m_I[0].net().time(), mt); - mt = this->m_I[0].net().time(); - } + for (std::size_t i = 0; i < m_NI; i++) + { + nstate |= (m_I[i]() << i); + mt = std::max(this->m_I[i].net().time(), mt); + } else - nstate |= m_I[0](); + for (std::size_t i = 0; i < m_NI; i++) + nstate |= (m_I[i]() << i); } const type_t outstate(m_ttp.m_outs[nstate]); @@ -199,7 +201,7 @@ namespace netlist for (std::size_t i = 0; i < m_NO; out >>= 1, ++i) m_Q[i].set_Q_time(out & 1, mt + tim[t[i]]); - if (m_NI > 1) + if (m_NI >= m_min_devices_for_deactivate) { type_t ign(m_ign); for (auto I = m_I.begin(); ign != 0; ign >>= 1, ++I) -- cgit v1.2.3