Add dummy h3.msleep CSR to rvcpp

This commit is contained in:
Luke Wren 2024-05-11 11:02:01 +01:00
parent a84742abd4
commit 6db1edc675
3 changed files with 106 additions and 90 deletions

View File

@ -425,4 +425,12 @@
#define CSR_MENTROPY 0xF15
#define CSR_MNOISE 0x7A9
#define CSR_HAZARD3_MEIEA 0xbe0
#define CSR_HAZARD3_MEIPA 0xbe1
#define CSR_HAZARD3_MEIFA 0xbe2
#define CSR_HAZARD3_MEIPRA 0xbe3
#define CSR_HAZARD3_MEINEXT 0xbe4
#define CSR_HAZARD3_MEICONTEXT 0xbe5
#define CSR_HAZARD3_MSLEEP 0xbf0
#endif

View File

@ -27,6 +27,7 @@ class RVCSR {
ux_t mscratch;
ux_t mepc;
ux_t mcause;
ux_t hazard3_msleep;
ux_t pmpaddr[PMP_REGIONS];
ux_t pmpcfg[PMP_REGIONS / 4];
@ -79,6 +80,7 @@ public:
mscratch = 0;
mepc = 0;
mcause = 0;
hazard3_msleep = 0;
pending_write_addr = {};
for (int i = 0; i < PMP_REGIONS; ++i) {
pmpaddr[i] = 0;

View File

@ -54,6 +54,8 @@ void RVCSR::step() {
case CSR_MINSTRETH: minstreth = pending_write_data; break;
case CSR_MCOUNTINHIBIT: mcountinhibit = pending_write_data & 0x7u; break;
case CSR_HAZARD3_MSLEEP: hazard3_msleep = pending_write_data & 0x7u; break;
default: break;
}
@ -125,6 +127,8 @@ std::optional<ux_t> RVCSR::read(uint16_t addr, bool side_effect) {
case CSR_PMPADDR14: return pmpaddr[14];
case CSR_PMPADDR15: return pmpaddr[15];
case CSR_HAZARD3_MSLEEP: return hazard3_msleep;
default: return {};
}
}
@ -190,6 +194,8 @@ bool RVCSR::write(uint16_t addr, ux_t data, uint op) {
case CSR_PMPADDR14: break;
case CSR_PMPADDR15: break;
case CSR_HAZARD3_MSLEEP: break;
default: return false;
}
return true;