From e75a4bfdfd34852aac17456d8470206bad67e64d Mon Sep 17 00:00:00 2001 From: mariusmonton Date: Fri, 13 Sep 2019 00:00:59 +0200 Subject: [PATCH] add missing CSR register MCYcLE and similars --- inc/Registers.h | 5 +++++ src/Registers.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/inc/Registers.h b/inc/Registers.h index 1624980..297db7f 100644 --- a/inc/Registers.h +++ b/inc/Registers.h @@ -49,6 +49,11 @@ #define CSR_STVAL (0x143) #define CSR_SIP (0x144) +#define CSR_MCYCLE (0xB00) +#define CSR_MINSTRET (0xB02) +#define CSR_MCYCLEH (0xB80) +#define CSR_MINSTRETH (0xB82) + #define CSR_CYCLE (0xC00) #define CSR_TIME (0xC01) #define CSR_INSTRET (0xC02) diff --git a/src/Registers.cpp b/src/Registers.cpp index 53c7521..bd8620e 100644 --- a/src/Registers.cpp +++ b/src/Registers.cpp @@ -92,10 +92,12 @@ uint32_t Registers::getCSR(int csr) { switch (csr) { case CSR_CYCLE: + case CSR_MCYCLE: ret_value = (uint64_t)(sc_time(sc_time_stamp() - sc_time(SC_ZERO_TIME)).to_double()) & 0x00000000FFFFFFFF; break; case CSR_CYCLEH: + case CSR_MCYCLEH: ret_value = (uint32_t)((uint64_t)(sc_time(sc_time_stamp() - sc_time(SC_ZERO_TIME)).to_double()) >> 32 & 0x00000000FFFFFFFF); break;