diff options
-rw-r--r-- | src/lib/netlist/nl_config.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/pfmtlog.h | 14 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptime.h | 28 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.cpp | 6 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_solver.cpp | 2 |
5 files changed, 32 insertions, 20 deletions
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 3bd57c2771d..9d6b99bd38b 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -125,7 +125,7 @@ /// This is about 10% slower on a skylake processor for pongf. /// #ifndef NL_PREFER_INT128 -#define NL_PREFER_INT128 (0) +#define NL_PREFER_INT128 (1) #endif /// \brief Support float type for matrix calculations. diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h index ae8998b9dee..f00f3db7215 100644 --- a/src/lib/netlist/plib/pfmtlog.h +++ b/src/lib/netlist/plib/pfmtlog.h @@ -12,6 +12,7 @@ #include "ppmf.h" #include "pstring.h" #include "ptypes.h" +#include "pgsl.h" #include <limits> #include <locale> @@ -64,6 +65,18 @@ namespace plib { 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<> struct ptype_traits<bool> : ptype_traits_base<bool> { }; @@ -160,6 +173,7 @@ namespace plib { }; #endif + template<> struct ptype_traits<char *> : ptype_traits_base<char *> { diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h index 9274467d0c2..ab55feb261b 100644 --- a/src/lib/netlist/plib/ptime.h +++ b/src/lib/netlist/plib/ptime.h @@ -53,8 +53,14 @@ namespace plib constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept : m_time(nom * (RES / den)) { } - template <typename O> - constexpr explicit ptime(const ptime<O, RES> &rhs) noexcept + template <typename O, typename = std::enable_if_t<ptime_le<ptime<O, RES>, ptime>::value>> + 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)) { } @@ -82,27 +88,18 @@ namespace plib return *this; } -#if 1 template <typename O> constexpr ptime operator-(const ptime<O, RES> &rhs) const noexcept { static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type"); 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> constexpr ptime operator+(ptime<O, RES> rhs) const noexcept { 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> @@ -137,7 +134,8 @@ namespace plib template <typename O> 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> @@ -155,7 +153,7 @@ namespace plib template <typename O> 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> diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 4076de4bd12..02cf471b397 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -476,7 +476,7 @@ namespace solver resched = solve_nr_base(); // 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); - 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 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_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());) plib::unused_var(source); // We are already up to date. Avoid oscillations. // 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()); return timestep_device_count() > 0 ? netlist_time::from_fp(m_params.m_min_timestep) : netlist_time::zero(); diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 9ea31925b98..a9ff476728d 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -113,7 +113,7 @@ namespace devices } } 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) |