Implemented mhpmevent[3:31] as read-only zero rather than illegal

This commit is contained in:
David Harris 2024-10-15 09:08:25 -07:00
parent de8a707361
commit 150641e5d3

View File

@ -8,7 +8,6 @@
// See RISC-V Privileged Mode Specification 20190608 3.1.10-11 // See RISC-V Privileged Mode Specification 20190608 3.1.10-11
// //
// Documentation: RISC-V System on Chip Design // Documentation: RISC-V System on Chip Design
// MHPMEVENT is not supported
// //
// A component of the CORE-V-WALLY configurable RISC-V project. // A component of the CORE-V-WALLY configurable RISC-V project.
// https://github.com/openhwgroup/cvw // https://github.com/openhwgroup/cvw
@ -66,7 +65,8 @@ module csrc import cvw::*; #(parameter cvw_t P) (
localparam MTIME = 12'hB01; // this is a memory-mapped register; no such CSR exists, and access should faul; localparam MTIME = 12'hB01; // this is a memory-mapped register; no such CSR exists, and access should faul;
localparam MHPMCOUNTERHBASE = 12'hB80; localparam MHPMCOUNTERHBASE = 12'hB80;
localparam MTIMEH = 12'hB81; // this is a memory-mapped register; no such CSR exists, and access should fault localparam MTIMEH = 12'hB81; // this is a memory-mapped register; no such CSR exists, and access should fault
localparam MHPMEVENTBASE = 12'h320; localparam MHPMEVENTBASE = 12'h323;
localparam MHPMEVENTLAST = 12'h33F;
localparam HPMCOUNTERBASE = 12'hC00; localparam HPMCOUNTERBASE = 12'hC00;
localparam HPMCOUNTERHBASE = 12'hC80; localparam HPMCOUNTERHBASE = 12'hC80;
localparam TIME = 12'hC01; localparam TIME = 12'hC01;
@ -156,6 +156,9 @@ module csrc import cvw::*; #(parameter cvw_t P) (
if (PrivilegeModeW == P.M_MODE | if (PrivilegeModeW == P.M_MODE |
MCOUNTEREN_REGW[CounterNumM] & (!P.S_SUPPORTED | PrivilegeModeW == P.S_MODE | SCOUNTEREN_REGW[CounterNumM])) begin MCOUNTEREN_REGW[CounterNumM] & (!P.S_SUPPORTED | PrivilegeModeW == P.S_MODE | SCOUNTEREN_REGW[CounterNumM])) begin
IllegalCSRCAccessM = 1'b0; IllegalCSRCAccessM = 1'b0;
if (CSRAdrM >= MHPMEVENTBASE & CSRAdrM <= MHPMEVENTLAST) begin
CSRCReadValM = '0; // mphmevent[3:31] tied to read-only zero
end else begin
if (P.XLEN==64) begin // 64-bit counter reads if (P.XLEN==64) begin // 64-bit counter reads
// Veri lator doesn't realize this only occurs for XLEN=64 // Veri lator doesn't realize this only occurs for XLEN=64
/* verilator lint_off WIDTH */ /* verilator lint_off WIDTH */
@ -188,6 +191,7 @@ module csrc import cvw::*; #(parameter cvw_t P) (
IllegalCSRCAccessM = 1'b1; // requested CSR doesn't exist IllegalCSRCAccessM = 1'b1; // requested CSR doesn't exist
end end
end end
end
end else begin end else begin
CSRCReadValM = '0; CSRCReadValM = '0;
IllegalCSRCAccessM = 1'b1; // no privileges for this csr IllegalCSRCAccessM = 1'b1; // no privileges for this csr