forked from Github_Repos/cvw
lsu cleanup down to 346 lines
This commit is contained in:
parent
325724f556
commit
bd320c2f76
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,6 +9,7 @@ __pycache__/
|
|||||||
#External repos
|
#External repos
|
||||||
addins
|
addins
|
||||||
addins/riscv-arch-test/Makefile.include
|
addins/riscv-arch-test/Makefile.include
|
||||||
|
addins/riscv-tests/target
|
||||||
|
|
||||||
#vsim work files to ignore
|
#vsim work files to ignore
|
||||||
transcript
|
transcript
|
||||||
@ -47,4 +48,5 @@ fpga/generator/*.jou
|
|||||||
*.objdump*
|
*.objdump*
|
||||||
*.signature.output
|
*.signature.output
|
||||||
examples/asm/sumtest/sumtest
|
examples/asm/sumtest/sumtest
|
||||||
|
examples/asm/example/example
|
||||||
|
|
||||||
|
@ -32,13 +32,10 @@
|
|||||||
|
|
||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module lsu
|
module lsu (
|
||||||
(
|
|
||||||
input logic clk, reset,
|
input logic clk, reset,
|
||||||
input logic StallM, FlushM, StallW, FlushW,
|
input logic StallM, FlushM, StallW, FlushW,
|
||||||
output logic LSUStallM,
|
output logic LSUStallM,
|
||||||
// Memory Stage
|
|
||||||
|
|
||||||
// connected to cpu (controls)
|
// connected to cpu (controls)
|
||||||
input logic [1:0] MemRWM,
|
input logic [1:0] MemRWM,
|
||||||
input logic [2:0] Funct3M,
|
input logic [2:0] Funct3M,
|
||||||
@ -50,13 +47,11 @@ module lsu
|
|||||||
output logic SquashSCW,
|
output logic SquashSCW,
|
||||||
output logic DCacheMiss,
|
output logic DCacheMiss,
|
||||||
output logic DCacheAccess,
|
output logic DCacheAccess,
|
||||||
|
|
||||||
// address and write data
|
// address and write data
|
||||||
input logic [`XLEN-1:0] IEUAdrE,
|
input logic [`XLEN-1:0] IEUAdrE,
|
||||||
(* mark_debug = "true" *)output logic [`XLEN-1:0] IEUAdrM,
|
(* mark_debug = "true" *)output logic [`XLEN-1:0] IEUAdrM,
|
||||||
input logic [`XLEN-1:0] WriteDataM,
|
input logic [`XLEN-1:0] WriteDataM,
|
||||||
output logic [`XLEN-1:0] ReadDataM,
|
output logic [`XLEN-1:0] ReadDataM,
|
||||||
|
|
||||||
// cpu privilege
|
// cpu privilege
|
||||||
input logic [1:0] PrivilegeModeW,
|
input logic [1:0] PrivilegeModeW,
|
||||||
input logic DTLBFlushM,
|
input logic DTLBFlushM,
|
||||||
@ -65,7 +60,6 @@ module lsu
|
|||||||
output logic LoadMisalignedFaultM, LoadAccessFaultM,
|
output logic LoadMisalignedFaultM, LoadAccessFaultM,
|
||||||
// cpu hazard unit (trap)
|
// cpu hazard unit (trap)
|
||||||
output logic StoreMisalignedFaultM, StoreAccessFaultM,
|
output logic StoreMisalignedFaultM, StoreAccessFaultM,
|
||||||
|
|
||||||
// connect to ahb
|
// connect to ahb
|
||||||
(* mark_debug = "true" *) output logic [`PA_BITS-1:0] LSUBusAdr,
|
(* mark_debug = "true" *) output logic [`PA_BITS-1:0] LSUBusAdr,
|
||||||
(* mark_debug = "true" *) output logic LSUBusRead,
|
(* mark_debug = "true" *) output logic LSUBusRead,
|
||||||
@ -74,31 +68,24 @@ module lsu
|
|||||||
(* mark_debug = "true" *) input logic [`XLEN-1:0] LSUBusHRDATA,
|
(* mark_debug = "true" *) input logic [`XLEN-1:0] LSUBusHRDATA,
|
||||||
(* mark_debug = "true" *) output logic [`XLEN-1:0] LSUBusHWDATA,
|
(* mark_debug = "true" *) output logic [`XLEN-1:0] LSUBusHWDATA,
|
||||||
(* mark_debug = "true" *) output logic [2:0] LSUBusSize,
|
(* mark_debug = "true" *) output logic [2:0] LSUBusSize,
|
||||||
|
|
||||||
// mmu management
|
|
||||||
|
|
||||||
// page table walker
|
// page table walker
|
||||||
input logic [`XLEN-1:0] SATP_REGW, // from csr
|
input logic [`XLEN-1:0] SATP_REGW, // from csr
|
||||||
input logic STATUS_MXR, STATUS_SUM, STATUS_MPRV,
|
input logic STATUS_MXR, STATUS_SUM, STATUS_MPRV,
|
||||||
input logic [1:0] STATUS_MPP,
|
input logic [1:0] STATUS_MPP,
|
||||||
|
|
||||||
input logic [`XLEN-1:0] PCF,
|
input logic [`XLEN-1:0] PCF,
|
||||||
input logic ITLBMissF,
|
input logic ITLBMissF,
|
||||||
output logic [`XLEN-1:0] PTE,
|
output logic [`XLEN-1:0] PTE,
|
||||||
output logic [1:0] PageType,
|
output logic [1:0] PageType,
|
||||||
output logic ITLBWriteF,
|
output logic ITLBWriteF,
|
||||||
|
|
||||||
input var logic [7:0] PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
|
input var logic [7:0] PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
|
||||||
input var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW[`PMP_ENTRIES-1:0] // *** this one especially has a large note attached to it in pmpchecker.
|
input var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW[`PMP_ENTRIES-1:0] // *** this one especially has a large note attached to it in pmpchecker.
|
||||||
);
|
);
|
||||||
|
|
||||||
logic DTLBPageFaultM;
|
logic DTLBPageFaultM;
|
||||||
|
|
||||||
logic [`PA_BITS-1:0] LSUPAdrM; // from mmu to dcache
|
logic [`PA_BITS-1:0] LSUPAdrM; // from mmu to dcache
|
||||||
logic [`XLEN+1:0] IEUAdrExtM;
|
logic [`XLEN+1:0] IEUAdrExtM;
|
||||||
logic DTLBMissM;
|
logic DTLBMissM;
|
||||||
logic DTLBWriteM;
|
logic DTLBWriteM;
|
||||||
|
|
||||||
logic [1:0] LSURWM;
|
logic [1:0] LSURWM;
|
||||||
logic [1:0] PreLSURWM;
|
logic [1:0] PreLSURWM;
|
||||||
logic [2:0] LSUFunct3M;
|
logic [2:0] LSUFunct3M;
|
||||||
@ -109,19 +96,13 @@ module lsu
|
|||||||
logic CPUBusy;
|
logic CPUBusy;
|
||||||
logic MemReadM;
|
logic MemReadM;
|
||||||
logic DCacheStallM;
|
logic DCacheStallM;
|
||||||
|
|
||||||
logic CacheableM;
|
logic CacheableM;
|
||||||
logic SelHPTW;
|
logic SelHPTW;
|
||||||
|
|
||||||
|
|
||||||
logic BusStall;
|
logic BusStall;
|
||||||
|
|
||||||
|
|
||||||
logic InterlockStall;
|
logic InterlockStall;
|
||||||
logic IgnoreRequest;
|
logic IgnoreRequest;
|
||||||
logic BusCommittedM, DCacheCommittedM;
|
logic BusCommittedM, DCacheCommittedM;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// HPTW and Interlock FSM (only needed if VM supported)
|
// HPTW and Interlock FSM (only needed if VM supported)
|
||||||
// MMU include PMP and is needed if any privileged supported
|
// MMU include PMP and is needed if any privileged supported
|
||||||
@ -243,13 +224,6 @@ module lsu
|
|||||||
// Either Data Cache or Data Tightly Integrated Memory or just bus interface
|
// Either Data Cache or Data Tightly Integrated Memory or just bus interface
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
// *** move to top
|
|
||||||
// conditional
|
|
||||||
// 1. ram // controlled by `MEM_DTIM
|
|
||||||
// 2. cache `MEM_DCACHE
|
|
||||||
// 3. wire pass-through
|
|
||||||
|
|
||||||
localparam integer WORDSPERLINE = `MEM_DCACHE ? `DCACHE_LINELENINBITS/`XLEN : 1;
|
localparam integer WORDSPERLINE = `MEM_DCACHE ? `DCACHE_LINELENINBITS/`XLEN : 1;
|
||||||
localparam integer LOGWPL = `MEM_DCACHE ? $clog2(WORDSPERLINE) : 1;
|
localparam integer LOGWPL = `MEM_DCACHE ? $clog2(WORDSPERLINE) : 1;
|
||||||
localparam integer LINELEN = `MEM_DCACHE ? `DCACHE_LINELENINBITS : `XLEN;
|
localparam integer LINELEN = `MEM_DCACHE ? `DCACHE_LINELENINBITS : `XLEN;
|
||||||
@ -258,32 +232,20 @@ module lsu
|
|||||||
localparam integer LINEBYTELEN = LINELEN/8;
|
localparam integer LINEBYTELEN = LINELEN/8;
|
||||||
localparam integer OFFSETLEN = $clog2(LINEBYTELEN);
|
localparam integer OFFSETLEN = $clog2(LINEBYTELEN);
|
||||||
|
|
||||||
// temp
|
|
||||||
|
|
||||||
logic [`XLEN-1:0] FinalAMOWriteDataM, FinalWriteDataM;
|
logic [`XLEN-1:0] FinalAMOWriteDataM, FinalWriteDataM;
|
||||||
(* mark_debug = "true" *) logic [`XLEN-1:0] PreLSUBusHWDATA;
|
(* mark_debug = "true" *) logic [`XLEN-1:0] PreLSUBusHWDATA;
|
||||||
logic [`XLEN-1:0] ReadDataWordM;
|
logic [`XLEN-1:0] ReadDataWordM;
|
||||||
logic [LINELEN-1:0] DCacheMemWriteData;
|
logic [LINELEN-1:0] DCacheMemWriteData;
|
||||||
|
|
||||||
// keep
|
|
||||||
logic [`XLEN-1:0] ReadDataWordMuxM;
|
logic [`XLEN-1:0] ReadDataWordMuxM;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logic [`PA_BITS-1:0] DCacheBusAdr;
|
logic [`PA_BITS-1:0] DCacheBusAdr;
|
||||||
logic [`XLEN-1:0] ReadDataLineSetsM [WORDSPERLINE-1:0];
|
logic [`XLEN-1:0] ReadDataLineSetsM [WORDSPERLINE-1:0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logic DCacheWriteLine;
|
logic DCacheWriteLine;
|
||||||
logic DCacheFetchLine;
|
logic DCacheFetchLine;
|
||||||
logic DCacheBusAck;
|
logic DCacheBusAck;
|
||||||
|
|
||||||
logic SelUncachedAdr;
|
logic SelUncachedAdr;
|
||||||
|
|
||||||
if (`MEM_DTIM) begin : dtim
|
if (`MEM_DTIM) begin : dtim
|
||||||
simpleram #(
|
simpleram #(.BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram (
|
||||||
.BASE(`RAM_BASE), .RANGE(`RAM_RANGE)) ram (
|
|
||||||
.HCLK(clk), .HRESETn(~reset),
|
.HCLK(clk), .HRESETn(~reset),
|
||||||
.HSELRam(1'b1), .HADDR(LSUPAdrM[31:0]),
|
.HSELRam(1'b1), .HADDR(LSUPAdrM[31:0]),
|
||||||
.HWRITE(LSURWM[0]), .HREADY(1'b1),
|
.HWRITE(LSURWM[0]), .HREADY(1'b1),
|
||||||
@ -306,10 +268,8 @@ end else begin : bus // *** lsubusdp
|
|||||||
|
|
||||||
genvar index;
|
genvar index;
|
||||||
for (index = 0; index < WORDSPERLINE; index++) begin:fetchbuffer
|
for (index = 0; index < WORDSPERLINE; index++) begin:fetchbuffer
|
||||||
flopen #(`XLEN) fb(.clk,
|
flopen #(`XLEN) fb(.clk, .en(LSUBusAck & LSUBusRead & (index == WordCount)),
|
||||||
.en(LSUBusAck & LSUBusRead & (index == WordCount)),
|
.d(LSUBusHRDATA), .q(DCacheMemWriteData[(index+1)*`XLEN-1:index*`XLEN]));
|
||||||
.d(LSUBusHRDATA),
|
|
||||||
.q(DCacheMemWriteData[(index+1)*`XLEN-1:index*`XLEN]));
|
|
||||||
end
|
end
|
||||||
|
|
||||||
assign LocalLSUBusAdr = SelUncachedAdr ? LSUPAdrM : DCacheBusAdr ;
|
assign LocalLSUBusAdr = SelUncachedAdr ? LSUPAdrM : DCacheBusAdr ;
|
||||||
|
Loading…
Reference in New Issue
Block a user