mirror of
https://github.com/holub/mame
synced 2025-07-04 01:18:59 +03:00
netlist: Fix 128 bit integer support.
This commit is contained in:
parent
5a2f41d1a5
commit
1fffeb33c0
@ -125,7 +125,7 @@
|
|||||||
/// This is about 10% slower on a skylake processor for pongf.
|
/// This is about 10% slower on a skylake processor for pongf.
|
||||||
///
|
///
|
||||||
#ifndef NL_PREFER_INT128
|
#ifndef NL_PREFER_INT128
|
||||||
#define NL_PREFER_INT128 (0)
|
#define NL_PREFER_INT128 (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// \brief Support float type for matrix calculations.
|
/// \brief Support float type for matrix calculations.
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "ppmf.h"
|
#include "ppmf.h"
|
||||||
#include "pstring.h"
|
#include "pstring.h"
|
||||||
#include "ptypes.h"
|
#include "ptypes.h"
|
||||||
|
#include "pgsl.h"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
@ -63,6 +64,18 @@ namespace plib {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct ptype_traits;
|
struct ptype_traits;
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct ptype_traits<compile_info::int128_type>
|
||||||
|
{
|
||||||
|
// FIXME: need native support at some time
|
||||||
|
static constexpr const bool is_signed = true;
|
||||||
|
static char32_t fmt_spec() { return 'd'; }
|
||||||
|
static void streamify(std::ostream &s, const compile_info::int128_type &v)
|
||||||
|
{
|
||||||
|
s << narrow_cast<long long>(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ptype_traits<bool> : ptype_traits_base<bool>
|
struct ptype_traits<bool> : ptype_traits_base<bool>
|
||||||
{
|
{
|
||||||
@ -160,6 +173,7 @@ namespace plib {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ptype_traits<char *> : ptype_traits_base<char *>
|
struct ptype_traits<char *> : ptype_traits_base<char *>
|
||||||
{
|
{
|
||||||
|
@ -53,8 +53,14 @@ namespace plib
|
|||||||
constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept
|
constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept
|
||||||
: m_time(nom * (RES / den)) { }
|
: m_time(nom * (RES / den)) { }
|
||||||
|
|
||||||
template <typename O>
|
template <typename O, typename = std::enable_if_t<ptime_le<ptime<O, RES>, ptime>::value>>
|
||||||
constexpr explicit ptime(const ptime<O, RES> &rhs) noexcept
|
constexpr ptime(const ptime<O, RES> &rhs) noexcept
|
||||||
|
: m_time(static_cast<TYPE>(rhs.m_time))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename O, typename T = std::enable_if_t<!ptime_le<ptime<O, RES>, ptime>::value, int>>
|
||||||
|
constexpr explicit ptime(const ptime<O, RES> &rhs, T dummy = 0) noexcept
|
||||||
: m_time(static_cast<TYPE>(rhs.m_time))
|
: m_time(static_cast<TYPE>(rhs.m_time))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -82,27 +88,18 @@ namespace plib
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
template <typename O>
|
template <typename O>
|
||||||
constexpr ptime operator-(const ptime<O, RES> &rhs) const noexcept
|
constexpr ptime operator-(const ptime<O, RES> &rhs) const noexcept
|
||||||
{
|
{
|
||||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||||
return ptime(m_time - rhs.m_time);
|
return ptime(m_time - rhs.m_time);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
template <typename O>
|
|
||||||
constexpr ptime operator-(ptime<O, RES> rhs) const noexcept
|
|
||||||
{
|
|
||||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
|
||||||
return (rhs -= (*this)); // causes a crash - FIXME
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
template <typename O>
|
template <typename O>
|
||||||
constexpr ptime operator+(ptime<O, RES> rhs) const noexcept
|
constexpr ptime operator+(ptime<O, RES> rhs) const noexcept
|
||||||
{
|
{
|
||||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||||
return (rhs += *this);
|
return ptime(m_time + rhs.m_time);
|
||||||
//return ptime(m_time + rhs.m_time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename M>
|
template <typename M>
|
||||||
@ -137,7 +134,8 @@ namespace plib
|
|||||||
template <typename O>
|
template <typename O>
|
||||||
friend constexpr bool operator>(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
friend constexpr bool operator>(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||||
{
|
{
|
||||||
return (rhs < lhs);
|
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||||
|
return (lhs.m_time > rhs.as_raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O>
|
template <typename O>
|
||||||
@ -155,7 +153,7 @@ namespace plib
|
|||||||
template <typename O>
|
template <typename O>
|
||||||
friend constexpr bool operator==(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
friend constexpr bool operator==(const ptime &lhs, const ptime<O, RES> &rhs) noexcept
|
||||||
{
|
{
|
||||||
return lhs.m_time == rhs.m_time;
|
return lhs.m_time == rhs.as_raw();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O>
|
template <typename O>
|
||||||
|
@ -476,7 +476,7 @@ namespace solver
|
|||||||
resched = solve_nr_base();
|
resched = solve_nr_base();
|
||||||
// update timestep calculation
|
// update timestep calculation
|
||||||
next_time_step = compute_next_timestep(m_params.m_min_ts_ts(), m_params.m_min_ts_ts(), m_params.m_max_timestep);
|
next_time_step = compute_next_timestep(m_params.m_min_ts_ts(), m_params.m_min_ts_ts(), m_params.m_max_timestep);
|
||||||
delta -= netlist_time_ext::from_fp(m_params.m_min_ts_ts());
|
delta -= netlist_time::from_fp(m_params.m_min_ts_ts());
|
||||||
}
|
}
|
||||||
// try remaining time using compute_next_timestep
|
// try remaining time using compute_next_timestep
|
||||||
while (delta > netlist_time::zero())
|
while (delta > netlist_time::zero())
|
||||||
@ -507,13 +507,13 @@ namespace solver
|
|||||||
|
|
||||||
netlist_time matrix_solver_t::solve(netlist_time_ext now, const char *source)
|
netlist_time matrix_solver_t::solve(netlist_time_ext now, const char *source)
|
||||||
{
|
{
|
||||||
netlist_time_ext delta = now - m_last_step();
|
netlist_time delta = static_cast<netlist_time>(now - m_last_step());
|
||||||
PFDEBUG(printf("solve %.10f\n", delta.as_double());)
|
PFDEBUG(printf("solve %.10f\n", delta.as_double());)
|
||||||
plib::unused_var(source);
|
plib::unused_var(source);
|
||||||
|
|
||||||
// We are already up to date. Avoid oscillations.
|
// We are already up to date. Avoid oscillations.
|
||||||
// FIXME: Make this a parameter!
|
// FIXME: Make this a parameter!
|
||||||
if (delta < netlist_time_ext::quantum())
|
if (delta < netlist_time::quantum())
|
||||||
{
|
{
|
||||||
//printf("solve return %s at %f\n", source, now.as_double());
|
//printf("solve return %s at %f\n", source, now.as_double());
|
||||||
return timestep_device_count() > 0 ? netlist_time::from_fp(m_params.m_min_timestep) : netlist_time::zero();
|
return timestep_device_count() > 0 ? netlist_time::from_fp(m_params.m_min_timestep) : netlist_time::zero();
|
||||||
|
@ -113,7 +113,7 @@ namespace devices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_queue.empty())
|
if (!m_queue.empty())
|
||||||
m_Q_step.net().toggle_and_push_to_queue(m_queue.top().exec_time() - now);
|
m_Q_step.net().toggle_and_push_to_queue(static_cast<netlist_time>(m_queue.top().exec_time() - now));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NETLIB_NAME(solver) :: reschedule(solver::matrix_solver_t *solv, netlist_time ts)
|
void NETLIB_NAME(solver) :: reschedule(solver::matrix_solver_t *solv, netlist_time ts)
|
||||||
|
Loading…
Reference in New Issue
Block a user