diff --git a/hdl/hazard3_csr.v b/hdl/hazard3_csr.v index ab149c7..e1c94fb 100644 --- a/hdl/hazard3_csr.v +++ b/hdl/hazard3_csr.v @@ -715,7 +715,7 @@ always @ (*) begin decode_match = mcounteren_cy ? match_uro : match_mro; rdata = mcycle; end - CYCLEH: if (CSR_COUNTER && U_MODE) begin + CYCLEH: if (CSR_COUNTER) begin decode_match = mcounteren_cy ? match_uro : match_mro; rdata = mcycleh; end diff --git a/test/sim/sw_testcases/csr_readable.c b/test/sim/sw_testcases/csr_readable.c index b1f35ad..1b8d303 100644 --- a/test/sim/sw_testcases/csr_readable.c +++ b/test/sim/sw_testcases/csr_readable.c @@ -123,6 +123,11 @@ int main() { (void)read_csr(mhpmcounter30h); (void)read_csr(mhpmcounter31h); + (void)read_csr(cycle); + (void)read_csr(cycleh); + (void)read_csr(instret); + (void)read_csr(instreth); + (void)read_csr(mcountinhibit); (void)read_csr(mhpmevent3); (void)read_csr(tselect); diff --git a/test/sim/sw_testcases/csr_writable.c b/test/sim/sw_testcases/csr_writable.c index 47d8daf..f93d014 100644 --- a/test/sim/sw_testcases/csr_writable.c +++ b/test/sim/sw_testcases/csr_writable.c @@ -30,6 +30,14 @@ CSR was 302 CSR was 303 -> exception, mcause = 2 // write to medeleg, unimplemented CSR was 303 +-> exception, mcause = 2 // write to cycle, read-only +CSR was c00 +-> exception, mcause = 2 // write to cycleh, read-only +CSR was c80 +-> exception, mcause = 2 // write to instret, read-only +CSR was c02 +-> exception, mcause = 2 // write to instreth, read-only +CSR was c82 -> exception, mcause = 2 // write to tselect, unimplemented but we permit reads as a workaround for an OpenOCD bug CSR was 7a0 -> exception, mcause = 2 // read of tdata1, unimplemented @@ -148,6 +156,11 @@ int main() { write_csr(mhpmcounter30h, read_csr(mhpmcounter30h )); write_csr(mhpmcounter31h, read_csr(mhpmcounter31h )); + write_csr(cycle, read_csr(cycle )); + write_csr(cycleh, read_csr(cycleh )); + write_csr(instret, read_csr(instret )); + write_csr(instreth, read_csr(instreth )); + write_csr(mcountinhibit, read_csr(mcountinhibit )); write_csr(mhpmevent3, read_csr(mhpmevent3 )); write_csr(tselect, read_csr(tselect ));