Merge branch 'main' of github.com:davidharrishmc/riscv-wally into main

This commit is contained in:
Ross Thompson 2021-07-04 17:07:57 -05:00
commit b2c5c3f637
6 changed files with 13 additions and 10 deletions

View File

@ -217,7 +217,7 @@ module lsu (
mmu #(.TLB_ENTRIES(`DTLB_ENTRY_BITS), .IMMU(0)) mmu #(.TLB_ENTRIES(`DTLB_ENTRIES), .IMMU(0))
dmmu(.TLBAccessType(MemRWMtoLSU), dmmu(.TLBAccessType(MemRWMtoLSU),
.VirtualAddress(MemAdrMtoLSU), .VirtualAddress(MemAdrMtoLSU),
.Size(Funct3MtoLSU[1:0]), .Size(Funct3MtoLSU[1:0]),

View File

@ -95,7 +95,7 @@ module tlb #(parameter TLB_ENTRIES = 8,
logic [`SVMODE_BITS-1:0] SvMode; logic [`SVMODE_BITS-1:0] SvMode;
logic [1:0] EffectivePrivilegeMode; // privilege mode, possibly modified by MPRV logic [1:0] EffectivePrivilegeMode; // privilege mode, possibly modified by MPRV
logic [TLB_ENTRIES-1:0] ReadLines, WriteLines, WriteEnables, Global; // used as the one-hot encoding of WriteIndex logic [TLB_ENTRIES-1:0] ReadLines, WriteLines, WriteEnables, PTE_G; // used as the one-hot encoding of WriteIndex
// Sections of the virtual and physical addresses // Sections of the virtual and physical addresses
logic [`VPN_BITS-1:0] VirtualPageNumber; logic [`VPN_BITS-1:0] VirtualPageNumber;
@ -107,7 +107,7 @@ module tlb #(parameter TLB_ENTRIES = 8,
logic [7:0] PTEAccessBits; logic [7:0] PTEAccessBits;
logic [11:0] PageOffset; logic [11:0] PageOffset;
logic PTE_U, PTE_X, PTE_W, PTE_R; // Useful PTE Control Bits logic PTE_D, PTE_A, PTE_U, PTE_X, PTE_W, PTE_R; // Useful PTE Control Bits
logic [1:0] HitPageType; logic [1:0] HitPageType;
logic CAMHit; logic CAMHit;
logic [`ASID_BITS-1:0] ASID; logic [`ASID_BITS-1:0] ASID;
@ -153,6 +153,7 @@ module tlb #(parameter TLB_ENTRIES = 8,
tlbphysicalpagemask PageMask(VirtualPageNumber, PhysicalPageNumber, HitPageType, PhysicalPageNumberMixed); tlbphysicalpagemask PageMask(VirtualPageNumber, PhysicalPageNumber, HitPageType, PhysicalPageNumberMixed);
// unswizzle useful PTE bits // unswizzle useful PTE bits
assign {PTE_D, PTE_A} = PTEAccessBits[7:6];
assign {PTE_U, PTE_X, PTE_W, PTE_R} = PTEAccessBits[4:1]; assign {PTE_U, PTE_X, PTE_W, PTE_R} = PTEAccessBits[4:1];
// Check whether the access is allowed, page faulting if not. // Check whether the access is allowed, page faulting if not.

View File

@ -36,7 +36,7 @@ module tlbcam #(parameter TLB_ENTRIES = 8,
input logic [1:0] PageTypeWriteVal, input logic [1:0] PageTypeWriteVal,
input logic TLBFlush, input logic TLBFlush,
input logic [TLB_ENTRIES-1:0] WriteEnables, input logic [TLB_ENTRIES-1:0] WriteEnables,
input logic [TLB_ENTRIES-1:0] Global input logic [TLB_ENTRIES-1:0] PTE_G,
input logic [`ASID_BITS-1:0] ASID, input logic [`ASID_BITS-1:0] ASID,
output logic [TLB_ENTRIES-1:0] ReadLines, output logic [TLB_ENTRIES-1:0] ReadLines,
output logic [1:0] HitPageType, output logic [1:0] HitPageType,

View File

@ -34,7 +34,7 @@ module tlbcamline #(parameter KEY_BITS = 20,
input logic [`VPN_BITS-1:0] VirtualPageNumber, // The requested page number to compare against the key input logic [`VPN_BITS-1:0] VirtualPageNumber, // The requested page number to compare against the key
input logic [`ASID_BITS-1:0] ASID, input logic [`ASID_BITS-1:0] ASID,
input logic WriteEnable, // Write a new entry to this line input logic WriteEnable, // Write a new entry to this line
input logic Global, input logic PTE_G,
input logic [1:0] PageTypeWriteVal, input logic [1:0] PageTypeWriteVal,
input logic TLBFlush, // Flush this line (set valid to 0) input logic TLBFlush, // Flush this line (set valid to 0)
output logic [1:0] PageTypeRead, // *** should this be the stored version or the always updated one? output logic [1:0] PageTypeRead, // *** should this be the stored version or the always updated one?
@ -57,7 +57,7 @@ module tlbcamline #(parameter KEY_BITS = 20,
logic [SEGMENT_BITS-1:0] Key0, Key1, Query0, Query1; logic [SEGMENT_BITS-1:0] Key0, Key1, Query0, Query1;
logic MatchASID, Match0, Match1; logic MatchASID, Match0, Match1;
assign MatchASID = (ASID == Key_ASID) | Global; assign MatchASID = (ASID == Key_ASID) | PTE_G;
generate generate
if (`XLEN == 32) begin if (`XLEN == 32) begin

View File

@ -33,14 +33,14 @@ module tlbram #(parameter TLB_ENTRIES = 8) (
input logic [TLB_ENTRIES-1:0] ReadLines, WriteEnables, input logic [TLB_ENTRIES-1:0] ReadLines, WriteEnables,
output logic [`PPN_BITS-1:0] PhysicalPageNumber, output logic [`PPN_BITS-1:0] PhysicalPageNumber,
output logic [7:0] PTEAccessBits, output logic [7:0] PTEAccessBits,
output logic [TLB_ENTRIES-1:0] Global output logic [TLB_ENTRIES-1:0] PTE_G
); );
logic [`XLEN-1:0] RamRead[TLB_ENTRIES-1:0]; logic [`XLEN-1:0] RamRead[TLB_ENTRIES-1:0];
logic [`XLEN-1:0] PageTableEntry; logic [`XLEN-1:0] PageTableEntry;
// Generate a flop for every entry in the RAM // Generate a flop for every entry in the RAM
tlbramline #(`XLEN) tlblineram[TLB_ENTRIES-1:0](clk, reset, ReadLines, WriteEnables, PTEWriteVal, RamRead); tlbramline #(`XLEN) tlblineram[TLB_ENTRIES-1:0](clk, reset, ReadLines, WriteEnables, PTEWriteVal, RamRead, PTE_G);
assign PageTableEntry = RamRead.or; // OR each column of RAM read to read PTE assign PageTableEntry = RamRead.or; // OR each column of RAM read to read PTE
assign PTEAccessBits = PageTableEntry[7:0]; assign PTEAccessBits = PageTableEntry[7:0];

View File

@ -29,10 +29,12 @@ module tlbramline #(parameter WIDTH)
(input logic clk, reset, (input logic clk, reset,
input logic re, we, input logic re, we,
input logic [WIDTH-1:0] d, input logic [WIDTH-1:0] d,
output logic [WIDTH-1:0] q); output logic [WIDTH-1:0] q,
output logic PTE_G);
logic [WIDTH-1:0] line; logic [WIDTH-1:0] line;
flopenr #(`XLEN) pteflop(clk, reset, we, d, line); flopenr #(`XLEN) pteflop(clk, reset, we, d, line);
assign q = re ? line : 0; assign q = re ? line : 0;
assign PTE_G = line[5]; // send global bit to CAM as part of ASID matching
endmodule endmodule