diff --git a/src/machine/memory/backend/aclintmtimer.cpp b/src/machine/memory/backend/aclintmtimer.cpp index 6b77fe9f..af1dd581 100644 --- a/src/machine/memory/backend/aclintmtimer.cpp +++ b/src/machine/memory/backend/aclintmtimer.cpp @@ -21,7 +21,7 @@ AclintMtimer::AclintMtimer(Endian simulated_machine_endian) value = 0; } - mtime_start_offset = QTime::currentTime(); + clock.start(); qt_timer_id = -1; } @@ -31,9 +31,7 @@ AclintMtimer::~AclintMtimer() { } uint64_t AclintMtimer::mtime_fetch_current() const { - QTime current_time = QTime::currentTime(); - - mtime_last_current_fetch = mtime_start_offset.msecsTo(current_time) * (uint64_t)10000; + mtime_last_current_fetch = clock.elapsed() * (uint64_t)10000; return mtime_last_current_fetch; } diff --git a/src/machine/memory/backend/aclintmtimer.h b/src/machine/memory/backend/aclintmtimer.h index 44f324f9..2b622991 100644 --- a/src/machine/memory/backend/aclintmtimer.h +++ b/src/machine/memory/backend/aclintmtimer.h @@ -6,6 +6,7 @@ #include #include +#include namespace machine { namespace aclint { @@ -63,8 +64,8 @@ namespace machine { namespace aclint { unsigned mtimecmp_count; uint64_t mtimecmp_value[ACLINT_MTIMECMP_COUNT_MAX] {}; + QElapsedTimer clock; const uint8_t mtimer_irq_level; - QTime mtime_start_offset; uint64_t mtime_user_offset = 0; mutable uint64_t mtime_last_current_fetch = 0; mutable bool mtimer_irq_active = false;