Skip to content

Commit

Permalink
Core: use QElapsedTimer also in aclintmtimer
Browse files Browse the repository at this point in the history
  • Loading branch information
jdupak authored and ppisa committed Dec 23, 2024
1 parent 759d64a commit ca0a918
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/machine/memory/backend/aclintmtimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AclintMtimer::AclintMtimer(Endian simulated_machine_endian)
value = 0;
}

mtime_start_offset = QTime::currentTime();
clock.start();
qt_timer_id = -1;
}

Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/machine/memory/backend/aclintmtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <QTime>
#include <cstdint>
#include <qelapsedtimer.h>

namespace machine { namespace aclint {

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca0a918

Please sign in to comment.