Skip to content

Commit

Permalink
made changes for ResEnc in tlbcontrol
Browse files Browse the repository at this point in the history
  • Loading branch information
Zain2050 committed Dec 24, 2024
1 parent 608d2ce commit 7d57d83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mmu/tlb/tlbcontrol.sv
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module tlbcontrol import cvw::*; #(parameter cvw_t P, ITLB = 0) (
logic TLBAccess;
logic ImproperPrivilege;
logic BadPBMT, BadNAPOT, BadReserved;
logic ReservedEncoding;
logic InvalidAccess;
logic PreUpdateDA, PrePageFault;

Expand Down Expand Up @@ -88,16 +89,17 @@ module tlbcontrol import cvw::*; #(parameter cvw_t P, ITLB = 0) (
assign BadPBMT = ((PTE_PBMT != 0) & ~(P.SVPBMT_SUPPORTED & ENVCFG_PBMTE)) | PTE_PBMT == 3; // PBMT must be zero if not supported; value of 3 is reserved
assign BadNAPOT = PTE_N & (~P.SVNAPOT_SUPPORTED | ~NAPOT4); // N must be be 0 if CVNAPOT is not supported or not 64 KiB contiguous region
assign BadReserved = PTE_RESERVED; // Reserved bits must be zero
assign ReservedEncoding = PTE_W & ~PTE_R; // fault on reserved encoding with R=0, W=1 to match ImperasDV behavior

// Check whether the access is allowed, page faulting if not.
if (ITLB == 1) begin:itlb // Instruction TLB fault checking
// User mode may only execute user mode pages, and supervisor mode may
// only execute non-user mode pages.
assign ImproperPrivilege = ((PrivilegeModeW == P.U_MODE) & ~PTE_U) | ((PrivilegeModeW == P.S_MODE) & PTE_U);
assign PreUpdateDA = ~PTE_A;
assign InvalidAccess = ~PTE_X;
assign InvalidAccess = ~PTE_X | ReservedEncoding;
end else begin:dtlb // Data TLB fault checking
logic InvalidRead, InvalidWrite, ReservedEncoding;
logic InvalidRead, InvalidWrite;
logic InvalidCBOM, InvalidCBOZ;

// User mode may only load/store from user mode pages, and supervisor mode
Expand All @@ -112,7 +114,6 @@ module tlbcontrol import cvw::*; #(parameter cvw_t P, ITLB = 0) (
assign InvalidWrite = WriteAccess & ~PTE_W;
assign InvalidCBOM = (|CMOpM[2:0]) & (~PTE_R & (~STATUS_MXR | ~PTE_X));
assign InvalidCBOZ = CMOpM[3] & ~PTE_W;
assign ReservedEncoding = PTE_W & ~PTE_R; // fault on reserved encoding with R=0, W=1 to match ImperasDV behavior
assign InvalidAccess = InvalidRead | InvalidWrite | InvalidCBOM | InvalidCBOZ | ReservedEncoding;
assign PreUpdateDA = ~PTE_A | WriteAccess & ~PTE_D;
end
Expand Down

0 comments on commit 7d57d83

Please sign in to comment.