Add read-only counter CSRs to readability/writability tests, and fix cycleh being unreadable when U mode is not implemented

This commit is contained in:
Luke Wren 2022-05-24 16:44:03 +01:00
parent d62861159f
commit 0199f48087
3 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 ));