From 565b76672a03e6d408463d7ede13d3f584bf5b4c Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Sun, 30 May 2021 18:42:43 +0100 Subject: [PATCH] Make MVENDORID/MARCHID/MIMPID configurable --- hdl/hazard3_config.vh | 14 ++++++++++++++ hdl/hazard3_csr.v | 15 ++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/hdl/hazard3_config.vh b/hdl/hazard3_config.vh index 7518e60..fdb24eb 100644 --- a/hdl/hazard3_config.vh +++ b/hdl/hazard3_config.vh @@ -35,6 +35,20 @@ parameter CSR_M_TRAP = 1, // CSR_COUNTER: Include performance counters and relevant M-mode CSRs parameter CSR_COUNTER = 0, +// ---------------------------------------------------------------------------- +// ID registers + +// JEDEC JEP106-compliant vendor ID, can be left at 0 if "not implemented or +// that this is a non-commercial implementation" (RISC-V spec). +// 31:7 is continuation code count, 6:0 is ID. Parity bit is not stored. +parameter MVENDORID_VAL = 32'h0, + +// Architecture ID for Hazard3, currently 0 because unregistered. (TODO) +parameter MARCHID_VAL = 32'h0, + +// Implementation ID for this specific version of Hazard3. Git hash is perfect. +parameter MIMPID_VAL = 32'h0, + // ---------------------------------------------------------------------------- // Performance/size options diff --git a/hdl/hazard3_csr.v b/hdl/hazard3_csr.v index 4d164e2..222724e 100644 --- a/hdl/hazard3_csr.v +++ b/hdl/hazard3_csr.v @@ -419,7 +419,7 @@ always @ (*) begin decode_match = 1'b1; rdata = { 2'h1, // MXL: 32-bit - {XLEN-28{1'b0}}, // WLRL + {XLEN-28{1'b0}}, // WLRL 13'd0, // Z...N, no |EXTENSION_M, @@ -432,18 +432,15 @@ always @ (*) begin end MVENDORID: if (CSR_M_MANDATORY) begin decode_match = !wen_soon; // MRO - // I don't have a JEDEC ID. It is legal to tie this to 0 if non-commercial. - rdata = {XLEN{1'b0}}; + rdata = MVENDORID_VAL; end MARCHID: if (CSR_M_MANDATORY) begin decode_match = !wen_soon; // MRO - // I don't have a RV foundation ID. It is legal to tie this to 0. - rdata = {XLEN{1'b0}}; + rdata = MARCHID_VAL; end MIMPID: if (CSR_M_MANDATORY) begin decode_match = !wen_soon; // MRO - // TODO put git SHA or something here - rdata = {XLEN{1'b0}}; + rdata = MIMPID_VAL; end MHARTID: if (CSR_M_MANDATORY) begin decode_match = !wen_soon; // MRO @@ -473,6 +470,10 @@ always @ (*) begin }; end + // MSTATUSH is not implemented (permitted when all fields would be tied to + // zero -- those fields being MBE and SBE, which are zero because we are + // pure little-endian.) + // MEDELEG, MIDELEG should not exist for M-only implementations. Will raise // illegal instruction exception if accessed.