mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
netlist: Better integretation of INT128. (nw)
Also some minor optimisations bringing pong and breakout to previous performance.
This commit is contained in:
parent
80aeecc227
commit
fff7f6ef55
@ -524,7 +524,7 @@ public:
|
||||
|
||||
NETLIB_NAME(sound_in)(netlist::netlist_state_t &anetlist, const pstring &name)
|
||||
: netlist::device_t(anetlist, name)
|
||||
, m_sample_time(attotime::zero)
|
||||
, m_sample_time(netlist::netlist_time::zero())
|
||||
, m_feedback(*this, "FB") // clock part
|
||||
, m_Q(*this, "Q")
|
||||
, m_pos(0)
|
||||
@ -570,14 +570,14 @@ protected:
|
||||
}
|
||||
m_pos++;
|
||||
|
||||
m_Q.net().toggle_and_push_to_queue(nltime_from_attotime(m_sample_time));
|
||||
m_Q.net().toggle_and_push_to_queue(m_sample_time);
|
||||
}
|
||||
|
||||
public:
|
||||
void resolve(attotime sample_time)
|
||||
{
|
||||
m_pos = 0;
|
||||
m_sample_time = sample_time;
|
||||
m_sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(sample_time).as_raw()));
|
||||
|
||||
for (int i = 0; i < MAX_INPUT_CHANNELS; i++)
|
||||
{
|
||||
@ -597,7 +597,7 @@ public:
|
||||
void buffer_reset(attotime sample_time, int num_samples, S **inputs)
|
||||
{
|
||||
m_samples = num_samples;
|
||||
m_sample_time = sample_time;
|
||||
m_sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(sample_time).as_raw()));
|
||||
|
||||
m_pos = 0;
|
||||
for (int i=0; i < m_num_channels; i++)
|
||||
@ -619,7 +619,7 @@ public:
|
||||
|
||||
private:
|
||||
channel m_channels[MAX_INPUT_CHANNELS];
|
||||
attotime m_sample_time;
|
||||
netlist::netlist_time m_sample_time;
|
||||
|
||||
netlist::logic_input_t m_feedback;
|
||||
netlist::logic_output_t m_Q;
|
||||
@ -1497,7 +1497,7 @@ void netlist_mame_sound_device::device_start()
|
||||
fatalerror("illegal channel number");
|
||||
m_out[chan] = outdev;
|
||||
m_out[chan]->m_sample_time = netlist::netlist_time::from_hz(clock());
|
||||
m_out[chan]->buffer_reset(netlist::netlist_time::zero());
|
||||
m_out[chan]->buffer_reset(netlist::netlist_time_ext::zero());
|
||||
}
|
||||
|
||||
// Configure inputs
|
||||
|
@ -26,7 +26,7 @@ namespace devices
|
||||
{
|
||||
public:
|
||||
|
||||
using type_t = typename plib::least_type_for_bits<m_NO + m_NI>::type;
|
||||
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));
|
||||
@ -161,16 +161,18 @@ namespace devices
|
||||
|
||||
m_ign = outstate >> m_NO;
|
||||
|
||||
const std::size_t timebase(nstate * m_NO);
|
||||
const auto *t(&m_ttp.m_timing_index[timebase]);
|
||||
const auto *tim = m_ttp.m_timing_nt.data();
|
||||
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]]);
|
||||
//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)
|
||||
@ -181,6 +183,22 @@ namespace devices
|
||||
#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;
|
||||
|
||||
|
@ -2092,11 +2092,9 @@ namespace netlist
|
||||
(*this)[i].push((v >> i) & 1, t);
|
||||
}
|
||||
|
||||
template<typename T, std::size_t NT>
|
||||
void push(const T &v, const std::array<netlist_time, NT> &t)
|
||||
template<typename T>
|
||||
void push(const T &v, const netlist_time * t)
|
||||
{
|
||||
static_assert(NT >= N, "Not enough timing entries provided");
|
||||
|
||||
if (N >= 1) (*this)[0].push((v >> 0) & 1, t[0]);
|
||||
if (N >= 2) (*this)[1].push((v >> 1) & 1, t[1]);
|
||||
if (N >= 3) (*this)[2].push((v >> 2) & 1, t[2]);
|
||||
@ -2109,6 +2107,14 @@ namespace netlist
|
||||
(*this)[i].push((v >> i) & 1, t[i]);
|
||||
}
|
||||
|
||||
template<typename T, std::size_t NT>
|
||||
void push(const T &v, const std::array<netlist_time, NT> &t)
|
||||
{
|
||||
static_assert(NT >= N, "Not enough timing entries provided");
|
||||
|
||||
push(v, t.data());
|
||||
}
|
||||
|
||||
void set_tristate(netlist_sig_t v,
|
||||
netlist_time ts_off_on, netlist_time ts_on_off) noexcept
|
||||
{
|
||||
|
@ -117,32 +117,40 @@ namespace plib
|
||||
return ptime(m_time / rhs);
|
||||
}
|
||||
|
||||
friend constexpr bool operator<(const ptime &lhs, const ptime &rhs) noexcept
|
||||
template <typename O>
|
||||
friend constexpr bool operator<(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||
{
|
||||
return (lhs.m_time < rhs.m_time);
|
||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||
return (lhs.m_time < rhs.as_raw());
|
||||
//return (lhs.m_time < rhs.m_time);
|
||||
}
|
||||
|
||||
friend constexpr bool operator>(const ptime &lhs, const ptime &rhs) noexcept
|
||||
template <typename O>
|
||||
friend constexpr bool operator>(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||
{
|
||||
return (rhs < lhs);
|
||||
}
|
||||
|
||||
friend constexpr bool operator<=(const ptime &lhs, const ptime &rhs) noexcept
|
||||
template <typename O>
|
||||
friend constexpr bool operator<=(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
friend constexpr bool operator>=(const ptime &lhs, const ptime &rhs) noexcept
|
||||
template <typename O>
|
||||
friend constexpr bool operator>=(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
friend constexpr bool operator==(const ptime &lhs, const ptime &rhs) noexcept
|
||||
template <typename O>
|
||||
friend constexpr bool operator==(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||
{
|
||||
return lhs.m_time == rhs.m_time;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=(const ptime &lhs, const ptime &rhs) noexcept
|
||||
template <typename O>
|
||||
friend constexpr bool operator!=(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
@ -95,7 +95,12 @@ namespace plib
|
||||
bits <= 8 ? 1 :
|
||||
bits <= 16 ? 2 :
|
||||
bits <= 32 ? 4 :
|
||||
#if (PHAS_INT128)
|
||||
bits <= 64 ? 8 :
|
||||
16
|
||||
#else
|
||||
8
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
@ -104,12 +109,20 @@ namespace plib
|
||||
template<> struct least_type_for_size<2> { using type = uint_least16_t; };
|
||||
template<> struct least_type_for_size<4> { using type = uint_least32_t; };
|
||||
template<> struct least_type_for_size<8> { using type = uint_least64_t; };
|
||||
#if (PHAS_INT128)
|
||||
template<> struct least_type_for_size<16> { using type = UINT128; };
|
||||
#endif
|
||||
|
||||
// This is different to the standard library. Mappings provided in stdint
|
||||
// are not always fastest.
|
||||
template<unsigned N> struct fast_type_for_size;
|
||||
template<> struct fast_type_for_size<1> { using type = uint_fast8_t; };
|
||||
template<> struct fast_type_for_size<2> { using type = uint_fast16_t; };
|
||||
template<> struct fast_type_for_size<4> { using type = uint_fast32_t; };
|
||||
template<> struct fast_type_for_size<1> { using type = uint32_t; };
|
||||
template<> struct fast_type_for_size<2> { using type = uint32_t; };
|
||||
template<> struct fast_type_for_size<4> { using type = uint32_t; };
|
||||
template<> struct fast_type_for_size<8> { using type = uint_fast64_t; };
|
||||
#if (PHAS_INT128)
|
||||
template<> struct fast_type_for_size<16> { using type = UINT128; };
|
||||
#endif
|
||||
|
||||
template<unsigned bits>
|
||||
struct least_type_for_bits
|
||||
|
Loading…
Reference in New Issue
Block a user