Implement sfence.vma and fix tlb writing

This commit is contained in:
Thomas Fleming 2021-04-01 15:55:05 -04:00
parent 853ddeba15
commit fdb20ee1cf
6 changed files with 11 additions and 14 deletions

View File

@ -61,7 +61,7 @@ module ifu (
input logic [1:0] PrivilegeModeW, input logic [1:0] PrivilegeModeW,
input logic [`XLEN-1:0] PageTableEntryF, input logic [`XLEN-1:0] PageTableEntryF,
input logic [`XLEN-1:0] SATP_REGW, input logic [`XLEN-1:0] SATP_REGW,
input logic ITLBWriteF, // ITLBFlushF, input logic ITLBWriteF, ITLBFlushF,
output logic ITLBMissF, ITLBHitF output logic ITLBMissF, ITLBHitF
); );
@ -75,11 +75,6 @@ module ifu (
logic [31:0] nop = 32'h00000013; // instruction for NOP logic [31:0] nop = 32'h00000013; // instruction for NOP
logic [`XLEN-1:0] ITLBInstrPAdrF, ICacheInstrPAdrF; logic [`XLEN-1:0] ITLBInstrPAdrF, ICacheInstrPAdrF;
// *** temporary hack until walker is hooked up -- Thomas F
// logic [`XLEN-1:0] PageTableEntryF = '0;
logic ITLBFlushF = '0;
// logic ITLBWriteF = '0;
tlb #(3) itlb(clk, reset, SATP_REGW, PrivilegeModeW, 1'b1, PCF, PageTableEntryF, ITLBWriteF, ITLBFlushF, tlb #(3) itlb(clk, reset, SATP_REGW, PrivilegeModeW, 1'b1, PCF, PageTableEntryF, ITLBWriteF, ITLBFlushF,
ITLBInstrPAdrF, ITLBMissF, ITLBHitF); ITLBInstrPAdrF, ITLBMissF, ITLBHitF);

View File

@ -126,9 +126,6 @@ module tlb #(parameter ENTRY_BITS = 3) (
assign VirtualPageNumber = VirtualAddress[`VPN_BITS+11:12]; assign VirtualPageNumber = VirtualAddress[`VPN_BITS+11:12];
assign PageOffset = VirtualAddress[11:0]; assign PageOffset = VirtualAddress[11:0];
// Choose a read or write location to the entry list
mux2 #(3) indexmux(VPNIndex, WriteIndex, TLBWrite, EntryIndex);
// Currently use random replacement algorithm // Currently use random replacement algorithm
tlb_rand rdm(.*); tlb_rand rdm(.*);
@ -160,7 +157,8 @@ endmodule
module tlb_ram #(parameter ENTRY_BITS = 3) ( module tlb_ram #(parameter ENTRY_BITS = 3) (
input clk, reset, input clk, reset,
input [ENTRY_BITS-1:0] EntryIndex, input [ENTRY_BITS-1:0] VPNIndex, // Index to read from
input [ENTRY_BITS-1:0] WriteIndex,
input [`XLEN-1:0] PageTableEntryWrite, input [`XLEN-1:0] PageTableEntryWrite,
input TLBWrite, input TLBWrite,
@ -171,10 +169,10 @@ module tlb_ram #(parameter ENTRY_BITS = 3) (
logic [`XLEN-1:0] ram [0:NENTRIES-1]; logic [`XLEN-1:0] ram [0:NENTRIES-1];
always @(posedge clk) begin always @(posedge clk) begin
if (TLBWrite) ram[EntryIndex] <= PageTableEntryWrite; if (TLBWrite) ram[WriteIndex] <= PageTableEntryWrite;
end end
assign PageTableEntry = ram[EntryIndex]; assign PageTableEntry = ram[VPNIndex];
initial begin initial begin
for (int i = 0; i < NENTRIES; i++) for (int i = 0; i < NENTRIES; i++)

View File

@ -72,7 +72,7 @@ module csrs #(parameter
assign WriteSEPCM = STrapM | (CSRSWriteM && (CSRAdrM == SEPC)); assign WriteSEPCM = STrapM | (CSRSWriteM && (CSRAdrM == SEPC));
assign WriteSCAUSEM = STrapM | (CSRSWriteM && (CSRAdrM == SCAUSE)); assign WriteSCAUSEM = STrapM | (CSRSWriteM && (CSRAdrM == SCAUSE));
assign WriteSTVALM = STrapM | (CSRSWriteM && (CSRAdrM == STVAL)); assign WriteSTVALM = STrapM | (CSRSWriteM && (CSRAdrM == STVAL));
assign WriteSATPM = STrapM | (CSRSWriteM && (CSRAdrM == SATP)); assign WriteSATPM = CSRSWriteM && (CSRAdrM == SATP);
assign WriteSCOUNTERENM = CSRSWriteM && (CSRAdrM == SCOUNTEREN); assign WriteSCOUNTERENM = CSRSWriteM && (CSRAdrM == SCOUNTEREN);
// CSRs // CSRs

View File

@ -36,6 +36,7 @@ module privileged (
output logic [`XLEN-1:0] CSRReadValW, output logic [`XLEN-1:0] CSRReadValW,
output logic [`XLEN-1:0] PrivilegedNextPCM, output logic [`XLEN-1:0] PrivilegedNextPCM,
output logic RetM, TrapM, output logic RetM, TrapM,
output logic ITLBFlushF, DTLBFlushM,
input logic InstrValidW, FloatRegWriteW, LoadStallD, BPPredWrongM, input logic InstrValidW, FloatRegWriteW, LoadStallD, BPPredWrongM,
input logic [3:0] InstrClassM, input logic [3:0] InstrClassM,
input logic PrivilegedM, input logic PrivilegedM,
@ -119,6 +120,8 @@ module privileged (
assign BreakpointFaultM = ebreakM; // could have other causes too assign BreakpointFaultM = ebreakM; // could have other causes too
assign EcallFaultM = ecallM; assign EcallFaultM = ecallM;
assign ITLBFlushF = sfencevmaM;
assign DTLBFlushM = sfencevmaM;
// *** Page faults now driven by page table walker. Might need to make the // *** Page faults now driven by page table walker. Might need to make the
// below signals ORs of a walker fault and a tlb fault if both of those come in // below signals ORs of a walker fault and a tlb fault if both of those come in
// assign InstrPageFaultM = 0; // assign InstrPageFaultM = 0;

View File

@ -92,6 +92,7 @@ module wallypipelinedhart (
// memory management unit signals // memory management unit signals
logic ITLBWriteF, DTLBWriteM; logic ITLBWriteF, DTLBWriteM;
logic ITLBFlushF, DTLBFlushM;
logic ITLBMissF, ITLBHitF; logic ITLBMissF, ITLBHitF;
logic DTLBMissM, DTLBHitM; logic DTLBMissM, DTLBHitM;
logic [`XLEN-1:0] SATP_REGW; logic [`XLEN-1:0] SATP_REGW;

View File

@ -367,7 +367,7 @@ string tests32i[] = {
// if (`F_SUPPORTED) tests = {tests64f, tests}; // if (`F_SUPPORTED) tests = {tests64f, tests};
// if (`D_SUPPORTED) tests = {tests64d, tests}; // if (`D_SUPPORTED) tests = {tests64d, tests};
if (`A_SUPPORTED) tests = {tests, tests64a}; if (`A_SUPPORTED) tests = {tests, tests64a};
if (`MEM_VIRTMEM) tests = {tests, tests64mmu}; //if (`MEM_VIRTMEM) tests = {tests, tests64mmu};
end end
// tests = {tests64a, tests}; // tests = {tests64a, tests};
tests = {tests, tests64p}; tests = {tests, tests64p};