From c8f80967a61a698ad73fd69396804af2a5ba2f62 Mon Sep 17 00:00:00 2001 From: Kip Macsai-Goren Date: Wed, 23 Jun 2021 19:59:06 -0400 Subject: [PATCH] added a few very simple arbitrations in the lsuArb that pass regression. cleaned up a few unused signals. Added several comments and concerns to lsuarb so I can remember where my thoughts were at the end of the day. --- wally-pipelined/src/ifu/ifu.sv | 2 +- wally-pipelined/src/lsu/lsu.sv | 6 +- wally-pipelined/src/lsu/lsuArb.sv | 85 ++++++++++++++----- wally-pipelined/src/mmu/mmu.sv | 2 +- wally-pipelined/src/mmu/pagetablewalker.sv | 2 +- .../src/wally/wallypipelinedhart.sv | 21 +++-- 6 files changed, 87 insertions(+), 31 deletions(-) diff --git a/wally-pipelined/src/ifu/ifu.sv b/wally-pipelined/src/ifu/ifu.sv index 46d7d0ea..909644a8 100644 --- a/wally-pipelined/src/ifu/ifu.sv +++ b/wally-pipelined/src/ifu/ifu.sv @@ -76,7 +76,7 @@ module ifu ( // pmp/pma (inside mmu) signals. *** temporarily from AHB bus but eventually replace with internal versions pre H input logic [31:0] HADDR, - input logic [2:0] HSIZE, HBURST, + input logic [2:0] HSIZE, input logic HWRITE, input logic ExecuteAccessF, //read, write, and atomic access are all set to zero because this mmu is onlt working with instructinos in the F stage. input logic [63:0] PMPCFG01_REGW, PMPCFG23_REGW, // *** all of these come from the privileged unit, so they're gonna have to come over into ifu and dmem diff --git a/wally-pipelined/src/lsu/lsu.sv b/wally-pipelined/src/lsu/lsu.sv index f20327bc..f53bc7c8 100644 --- a/wally-pipelined/src/lsu/lsu.sv +++ b/wally-pipelined/src/lsu/lsu.sv @@ -42,9 +42,6 @@ module lsu ( output logic SquashSCW, output logic DataMisalignedM, - // part of the page table walker - input logic DisableTranslation, - // address and write data input logic [`XLEN-1:0] MemAdrM, input logic [`XLEN-1:0] WriteDataM, @@ -78,6 +75,7 @@ module lsu ( input logic STATUS_MXR, STATUS_SUM, // from csr input logic DTLBWriteM, output logic DTLBMissM, + input logic DisableTranslation, // used to stop intermediate PTE physical addresses being saved to TLB. @@ -85,7 +83,7 @@ module lsu ( // PMA/PMP (inside mmu) signals input logic [31:0] HADDR, // *** replace all of these H inputs with physical adress once pma checkers have been edited to use paddr as well. - input logic [2:0] HSIZE, HBURST, + input logic [2:0] HSIZE, input logic HWRITE, input logic AtomicAccessM, WriteAccessM, ReadAccessM, // execute access is hardwired to zero in this mmu because we're only working with data in the M stage. input logic [63:0] PMPCFG01_REGW, PMPCFG23_REGW, // *** all of these come from the privileged unit, so thwyre gonna have to come over into ifu and dmem diff --git a/wally-pipelined/src/lsu/lsuArb.sv b/wally-pipelined/src/lsu/lsuArb.sv index 14dcd6f7..832ea423 100644 --- a/wally-pipelined/src/lsu/lsuArb.sv +++ b/wally-pipelined/src/lsu/lsuArb.sv @@ -26,29 +26,76 @@ `include "wally-config.vh" -module lsuArb - (input logic clk, reset, +module lsuArb ( + input logic clk, reset, // signals from page table walker - output logic [`XLEN-1:0] MMUReadPTE, - input logic MMUTranslate, // *** rename to HPTWReq - output logic MMUReady, - input logic [`XLEN-1:0] MMUPAdr, +// output logic [`XLEN-1:0] MMUReadPTE, // *** it seems like this is the value out of the ahblite that gets sent back to the ptw. I don;t think it needs to get checked until the next paddr has been extracted from it. + input logic MMUTranslate, // *** rename to HPTWReq +// output logic MMUReady, // *** Similar reason to mmuReadPTE + input logic [`XLEN-1:0] MMUPAdr, - // signal from CPU - input logic [1:0] MemRWM, - input logic [2:0] Funct3M, - input logic [1:0] AtomicM, - // back to CPU - output logic CommittedM, - output logic SquashSCW, - output logic DataMisalignedM, + // signal from CPU + input logic [1:0] MemRWM, + input logic [2:0] Funct3M, + input logic [1:0] AtomicM, + input logic [`XLEN-1:0] MemAdrM, // memory addrress to be checked coming from the CPU. *** this will be used to arbitrate to decide HADDR going into the PM checks, but it also gets sent in its normal form to the lsu because we need the virtual address for the tlb. + // back to CPU - // to LSU - output logic DisableTranslation, - output logic [1:0] MemRWMtoLSU, - output logic [2:0] Funct3MtoLSU, - output logic [1:0] AtomicMtoLSU, + /* *** unused for not (23 June 2021) + output logic CommittedM, + output logic SquashSCW, + output logic DataMisalignedM, +*/ + // to LSU + output logic DisableTranslation, + output logic [1:0] MemRWMtoLSU, + output logic [2:0] Funct3MtoLSU, + output logic [1:0] AtomicMtoLSU + + /* *********** KMG: A lot of the rest of the signals that need to be arbitrated are going to be very annoying + these are the ones that used to get sent from the ahb to the pma checkers. but our eventual + goal is to have many of them sent thru the pmp/pma FIRST before the bus can get to them. + + deciding how to choose the right Haddr for the PM checkers will be difficult since they currently get + HADDR from the ahblite which seems like it could come from any number of sources, while we will eventually be narrowing it down to two possible sources. + + other problems arise when some signals like HSIZE are used in the PM checks but there's also a differnent size input to the tlb and both of these get to go through the mmu. + which one should be chosen for which device? can the be merged somehow? + +*/ + + /*// pmp/pma specifics sent through lsu + output logic [`XLEN-1:0] HADDRtoLSU, + output logic [2:0] HSIZEtoLSU // *** May not actually need to be arbitrated, since I'm +*/ +); + +/* *** these are all the signals that get sent to the pmp/pma chackers straight from the ahblite. We want to switch it around so the + checkers get these signals first and then the newly checked values can get sent to the ahblite. + input logic [31:0] HADDR, // *** replace all of these H inputs with physical adress once pma checkers have been edited to use paddr as well. + input logic [2:0] HSIZE, + input logic HWRITE, + input logic AtomicAccessM, WriteAccessM, ReadAccessM, // execute access is hardwired to zero in this mmu because we're only working with data in the M stage. +*/ + + generate + if (`XLEN == 32) begin + + assign Funct3MtoLSU = MMUTranslate ? 3'b010 : Funct3M; // *** is this the right thing for the msB? + + end else begin + + assign Funct3MtoLSU = MMUTranslate ? 3'b011 : Funct3M; // *** is this the right thing for the msB? + + end + endgenerate + + assign AtomicMtoLSU = MMUTranslate ? 2'b00 : AtomicM; + assign MemRWMtoLSU = MemRWM; // *** along with the rest of the lsu, the mmu uses memrwm in it's pure form so I think we can just forward it through + assign DisableTranslation = MMUTranslate; +// assign HADDRtoLSU = MMUTranslate ? MMUPAdr : MemAdrM; // *** Potentially a huge breaking point since the PM checks always get HADDR from ahblite and not necessarily just these two sources. this will need to be looked over when we fix PM to only take physical addresses. +// assign HSIZEtoLSU = {1'b0, Funct3MtoLSU[1:0]}; // the Hsize is always just the funct3M indicating the size of the data transfer. diff --git a/wally-pipelined/src/mmu/mmu.sv b/wally-pipelined/src/mmu/mmu.sv index e6d003b3..60f46b04 100644 --- a/wally-pipelined/src/mmu/mmu.sv +++ b/wally-pipelined/src/mmu/mmu.sv @@ -68,7 +68,7 @@ module mmu #(parameter ENTRY_BITS = 3, // PMA checker signals input logic [31:0] HADDR, - input logic [2:0] HSIZE, HBURST, + input logic [2:0] HSIZE, input logic HWRITE, input logic AtomicAccessM, ExecuteAccessF, WriteAccessM, ReadAccessM, input logic [63:0] PMPCFG01_REGW, PMPCFG23_REGW, // *** all of these come from the privileged unit, so thwyre gonna have to come over into ifu and dmem diff --git a/wally-pipelined/src/mmu/pagetablewalker.sv b/wally-pipelined/src/mmu/pagetablewalker.sv index 785a4aa7..abafd2ce 100644 --- a/wally-pipelined/src/mmu/pagetablewalker.sv +++ b/wally-pipelined/src/mmu/pagetablewalker.sv @@ -52,7 +52,7 @@ module pagetablewalker ( - // *** modify to send to LSU + // *** modify to send to LSU // *** KMG: These are inputs/results from the ahblite whose addresses should have already been checked, so I don't think they need to be sent through the LSU input logic [`XLEN-1:0] MMUReadPTE, input logic MMUReady, diff --git a/wally-pipelined/src/wally/wallypipelinedhart.sv b/wally-pipelined/src/wally/wallypipelinedhart.sv index 303fd5ad..a82b84e0 100644 --- a/wally-pipelined/src/wally/wallypipelinedhart.sv +++ b/wally-pipelined/src/wally/wallypipelinedhart.sv @@ -155,7 +155,12 @@ module wallypipelinedhart ( logic [4:0] InstrClassM; logic [`XLEN-1:0] HRDATAW; - + + // IEU vs HPTW arbitration signals to send to LSU + logic DisableTranslation; + logic [1:0] MemRWMtoLSU; + logic [2:0] Funct3MtoLSU; + logic [1:0] AtomicMtoLSU; ifu ifu(.InstrInF(InstrRData), .*); // instruction fetch unit: PC, branch prediction, instruction cache @@ -174,13 +179,19 @@ module wallypipelinedhart ( .MemSizeM(Funct3M[1:0]), .UnsignedLoadM(Funct3M[2]), .*); */ + // arbiter between IEU and pagetablewalker + lsuArb arbiter(.MMUTranslate(MMUTranslate), .MMUPAdr(MMUPAdr), .MemRWM(MemRWM|FMemRWM), + .Funct3M(Funct3M), .AtomicM(AtomicM), .MemAdrM(MemAdrM), + // outputs to LSU + .DisableTranslation(DisableTranslation), .MemRWMtoLSU(MemRWMtoLSU), .Funct3MtoLSU(Funct3MtoLSU), + .AtomicMtoLSU(AtomicMtoLSU), .*); - lsu lsu(.MemRWM(MemRWM|FMemRWM), .WriteDataM(WriteDatatmpM),.*, - .ReadDataW(ReadDataW), - .DisableTranslation(1'b0) // *** will connect to page table walker arbiter -); // data cache unit + lsu lsu(.MemRWM(MemRWMtoLSU), .AtomicM(AtomicMtoLSU), .Funct3M(Funct3MtoLSU), + .DisableTranslation(DisableTranslation), + .WriteDataM(WriteDatatmpM), + .ReadDataW(ReadDataW), .* ); // data cache unit ahblite ebu( //.InstrReadF(1'b0),