From 4f719645294607598313b81719b031a99c12392d Mon Sep 17 00:00:00 2001 From: David Harris Date: Fri, 4 Jun 2021 09:15:42 -0400 Subject: [PATCH] Fixed RV32 MMU constants --- .../config/shared/wally-constants.vh | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/wally-pipelined/config/shared/wally-constants.vh b/wally-pipelined/config/shared/wally-constants.vh index cc6c27fc..ec225f8c 100644 --- a/wally-pipelined/config/shared/wally-constants.vh +++ b/wally-pipelined/config/shared/wally-constants.vh @@ -28,13 +28,33 @@ // OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /////////////////////////////////////////// +`include "wally-config.vh" + +/* // Virtual Memory Constants (sv48) -`define VPN_SEGMENT_BITS 9 -`define VPN_BITS 36 -`define PPN_HIGH_SEGMENT_BITS 17 -`define PPN_BITS 44 -`define PA_BITS 56 -`define SVMODE_BITS 4 +`define VPN_SEGMENT_BITS_RV64 9 +`define VPN_BITS_RV64 36 +`define PPN_HIGH_SEGMENT_BITS_RV64 17 +`define PPN_BITS_RV64 44 +`define PA_BITS_RV64 56 +`define SVMODE_BITS_RV64 4 +// Virtual Memory Constants (sv32) +`define VPN_SEGMENT_BITS_RV32 10 +`define VPN_BITS_RV32 20 +`define PPN_HIGH_SEGMENT_BITS_RV32 12 +`define PPN_BITS_RV32 22 +`define PA_BITS_RV32 34 +`define SVMODE_BITS_RV32 1 +*/ + +// Virtual Memory Constants +`define VPN_SEGMENT_BITS (`XLEN == 32 ? 10 : 9) +`define VPN_BITS (`XLEN==32 ? (2*`VPN_SEGMENT_BITS) : (4*`VPN_SEGMENT_BITS)) +`define PPN_HIGH_SEGMENT_BITS (`XLEN==32 ? 12 : 17) +`define PPN_BITS (`XLEN==32 ? 22 : 44) +`define PA_BITS (`XLEN==32 ? 34 : 56) +`define SVMODE_BITS (`XLEN == 32 ? 1 : 4) + // constants to check SATP_MODE against // defined in Table 4.3 of the privileged spec `define NO_TRANSLATE 0