mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Cleanup busdp.
This commit is contained in:
parent
7c3d6bbdb4
commit
fa8914a830
@ -82,21 +82,16 @@ module busdp #(parameter WORDSPERLINE, parameter LINELEN)
|
|||||||
.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 ;
|
|
||||||
|
mux2 #(`PA_BITS) localadrmux(DCacheBusAdr, LSUPAdrM, SelUncachedAdr, LocalLSUBusAdr);
|
||||||
assign LSUBusAdr = ({{`PA_BITS-LOGWPL{1'b0}}, WordCount} << $clog2(`XLEN/8)) + LocalLSUBusAdr;
|
assign LSUBusAdr = ({{`PA_BITS-LOGWPL{1'b0}}, WordCount} << $clog2(`XLEN/8)) + LocalLSUBusAdr;
|
||||||
assign PreLSUBusHWDATA = ReadDataLineSetsM[WordCount]; // only in lsu, not ifu
|
assign PreLSUBusHWDATA = ReadDataLineSetsM[WordCount]; // only in lsu, not ifu
|
||||||
// exclude the subword write for uncached. We don't read the data first so we cannot
|
mux2 #(`XLEN) lsubushwdatamux(.d0(PreLSUBusHWDATA), .d1(FinalAMOWriteDataM),
|
||||||
// select the subword by masking. Subword write also exists inside the uncore to
|
.s(SelUncachedAdr), .y(LSUBusHWDATA));
|
||||||
// suport subword masking for i/o. I'm not sure if this is necessary.
|
mux2 #(3) lsubussizemux(.d0(`XLEN == 32 ? 3'b010 : 3'b011), .d1(LSUFunct3M),
|
||||||
assign LSUBusHWDATA = SelUncachedAdr ? FinalAMOWriteDataM : PreLSUBusHWDATA; // only in lsu, not ifu
|
.s(SelUncachedAdr), .y(LSUBusSize));
|
||||||
|
mux2 #(`XLEN) UnCachedDataMux(.d0(ReadDataWordM), .d1(DCacheMemWriteData[`XLEN-1:0]),
|
||||||
assign LSUBusSize = SelUncachedAdr ? LSUFunct3M : (`XLEN == 32 ? 3'b010 : 3'b011); // ifu: always the XLEN value.
|
.s(SelUncachedAdr), .y(ReadDataWordMuxM));
|
||||||
|
|
||||||
// select between dcache and direct from the BUS. Always selected if no dcache.
|
|
||||||
mux2 #(`XLEN) UnCachedDataMux(.d0(ReadDataWordM),
|
|
||||||
.d1(DCacheMemWriteData[`XLEN-1:0]),
|
|
||||||
.s(SelUncachedAdr),
|
|
||||||
.y(ReadDataWordMuxM));
|
|
||||||
|
|
||||||
busfsm #(WordCountThreshold, LOGWPL, `MEM_DCACHE)
|
busfsm #(WordCountThreshold, LOGWPL, `MEM_DCACHE)
|
||||||
busfsm(.clk, .reset, .IgnoreRequest, .LSURWM, .DCacheFetchLine, .DCacheWriteLine,
|
busfsm(.clk, .reset, .IgnoreRequest, .LSURWM, .DCacheFetchLine, .DCacheWriteLine,
|
||||||
|
@ -61,13 +61,13 @@ module lsu (
|
|||||||
// cpu hazard unit (trap)
|
// cpu hazard unit (trap)
|
||||||
output logic StoreAmoMisalignedFaultM, StoreAmoAccessFaultM,
|
output logic StoreAmoMisalignedFaultM, StoreAmoAccessFaultM,
|
||||||
// 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,
|
||||||
(* mark_debug = "true" *) output logic LSUBusWrite,
|
(* mark_debug = "true" *) output logic LSUBusWrite,
|
||||||
(* mark_debug = "true" *) input logic LSUBusAck,
|
(* mark_debug = "true" *) input logic LSUBusAck,
|
||||||
(* 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,
|
||||||
// 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,
|
||||||
@ -89,7 +89,7 @@ module lsu (
|
|||||||
logic [2:0] LSUFunct3M;
|
logic [2:0] LSUFunct3M;
|
||||||
logic [6:0] LSUFunct7M;
|
logic [6:0] LSUFunct7M;
|
||||||
logic [1:0] LSUAtomicM;
|
logic [1:0] LSUAtomicM;
|
||||||
(* mark_debug = "true" *) logic [`PA_BITS-1:0] PreLSUPAdrM, LocalLSUBusAdr;
|
(* mark_debug = "true" *) logic [`PA_BITS-1:0] PreLSUPAdrM;
|
||||||
logic [11:0] PreLSUAdrE, LSUAdrE;
|
logic [11:0] PreLSUAdrE, LSUAdrE;
|
||||||
logic CPUBusy;
|
logic CPUBusy;
|
||||||
logic DCacheStallM;
|
logic DCacheStallM;
|
||||||
@ -100,12 +100,12 @@ module lsu (
|
|||||||
logic IgnoreRequest;
|
logic IgnoreRequest;
|
||||||
logic BusCommittedM, DCacheCommittedM;
|
logic BusCommittedM, DCacheCommittedM;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
flopenrc #(`XLEN) AddressMReg(clk, reset, FlushM, ~StallM, IEUAdrE, IEUAdrM);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
flopenrc #(`XLEN) AddressMReg(clk, reset, FlushM, ~StallM, IEUAdrE, IEUAdrM);
|
|
||||||
|
|
||||||
logic [`XLEN+1:0] IEUAdrExtM;
|
logic [`XLEN+1:0] IEUAdrExtM;
|
||||||
assign IEUAdrExtM = {2'b00, IEUAdrM};
|
assign IEUAdrExtM = {2'b00, IEUAdrM};
|
||||||
@ -118,8 +118,7 @@ module lsu (
|
|||||||
.LSUAdrE, .PreLSUPAdrM, .CPUBusy, .InterlockStall, .SelHPTW,
|
.LSUAdrE, .PreLSUPAdrM, .CPUBusy, .InterlockStall, .SelHPTW,
|
||||||
.IgnoreRequest);
|
.IgnoreRequest);
|
||||||
|
|
||||||
end // if (`MEM_VIRTMEM)
|
end else begin
|
||||||
else begin
|
|
||||||
assign {InterlockStall, SelHPTW, PTE, PageType, DTLBWriteM, ITLBWriteF} = '0;
|
assign {InterlockStall, SelHPTW, PTE, PageType, DTLBWriteM, ITLBWriteF} = '0;
|
||||||
assign IgnoreRequest = TrapM;
|
assign IgnoreRequest = TrapM;
|
||||||
assign CPUBusy = StallW;
|
assign CPUBusy = StallW;
|
||||||
@ -168,10 +167,10 @@ module lsu (
|
|||||||
end
|
end
|
||||||
assign LSUStallM = DCacheStallM | InterlockStall | BusStall;
|
assign LSUStallM = DCacheStallM | InterlockStall | BusStall;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Hart Memory System
|
// Hart Memory System
|
||||||
// Either Data Cache or Data Tightly Integrated Memory or just bus interface
|
// Either Data Cache or Data Tightly Integrated Memory or just bus interface
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
localparam integer WORDSPERLINE = `MEM_DCACHE ? `DCACHE_LINELENINBITS/`XLEN : 1;
|
localparam integer WORDSPERLINE = `MEM_DCACHE ? `DCACHE_LINELENINBITS/`XLEN : 1;
|
||||||
localparam integer LINELEN = `MEM_DCACHE ? `DCACHE_LINELENINBITS : `XLEN;
|
localparam integer LINELEN = `MEM_DCACHE ? `DCACHE_LINELENINBITS : `XLEN;
|
||||||
@ -207,13 +206,14 @@ module lsu (
|
|||||||
cache #(.LINELEN(`DCACHE_LINELENINBITS), .NUMLINES(`DCACHE_WAYSIZEINBYTES*8/LINELEN),
|
cache #(.LINELEN(`DCACHE_LINELENINBITS), .NUMLINES(`DCACHE_WAYSIZEINBYTES*8/LINELEN),
|
||||||
.NUMWAYS(`DCACHE_NUMWAYS), .DCACHE(1))
|
.NUMWAYS(`DCACHE_NUMWAYS), .DCACHE(1))
|
||||||
dcache(.clk, .reset, .CPUBusy,
|
dcache(.clk, .reset, .CPUBusy,
|
||||||
.RW(CacheableM ? LSURWM : 2'b00), .FlushCache(FlushDCacheM), .Atomic(CacheableM ? LSUAtomicM : 2'b00),
|
.RW(CacheableM ? LSURWM : 2'b00), .FlushCache(FlushDCacheM),
|
||||||
.NextAdr(LSUAdrE), .PAdr(LSUPAdrM),
|
.Atomic(CacheableM ? LSUAtomicM : 2'b00), .NextAdr(LSUAdrE), .PAdr(LSUPAdrM),
|
||||||
.FinalWriteData(FinalWriteDataM), .ReadDataWord(ReadDataWordM), .CacheStall(DCacheStallM),
|
.FinalWriteData(FinalWriteDataM), .ReadDataWord(ReadDataWordM),
|
||||||
.CacheMiss(DCacheMiss), .CacheAccess(DCacheAccess),
|
.CacheStall(DCacheStallM), .CacheMiss(DCacheMiss), .CacheAccess(DCacheAccess),
|
||||||
.IgnoreRequest, .CacheCommitted(DCacheCommittedM),
|
.IgnoreRequest, .CacheCommitted(DCacheCommittedM), .CacheBusAdr(DCacheBusAdr),
|
||||||
.CacheBusAdr(DCacheBusAdr), .ReadDataLineSets(ReadDataLineSetsM), .CacheMemWriteData(DCacheMemWriteData),
|
.ReadDataLineSets(ReadDataLineSetsM), .CacheMemWriteData(DCacheMemWriteData),
|
||||||
.CacheFetchLine(DCacheFetchLine), .CacheWriteLine(DCacheWriteLine), .CacheBusAck(DCacheBusAck), .InvalidateCacheM(1'b0));
|
.CacheFetchLine(DCacheFetchLine), .CacheWriteLine(DCacheWriteLine),
|
||||||
|
.CacheBusAck(DCacheBusAck), .InvalidateCacheM(1'b0));
|
||||||
|
|
||||||
end else begin : passthrough
|
end else begin : passthrough
|
||||||
assign {ReadDataWordM, DCacheStallM, DCacheCommittedM, DCacheWriteLine, DCacheFetchLine, DCacheBusAdr} = '0;
|
assign {ReadDataWordM, DCacheStallM, DCacheCommittedM, DCacheWriteLine, DCacheFetchLine, DCacheBusAdr} = '0;
|
||||||
@ -237,19 +237,16 @@ module lsu (
|
|||||||
.HWDATAIN(FinalAMOWriteDataM),
|
.HWDATAIN(FinalAMOWriteDataM),
|
||||||
.HWDATA(FinalWriteDataM));
|
.HWDATA(FinalWriteDataM));
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Atomic operations
|
// Atomic operations
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (`A_SUPPORTED) begin:lrsc
|
if (`A_SUPPORTED) begin:lrsc
|
||||||
/*atomic atomic(.clk, .reset, .FlushW, .CPUBusy, .MemRead, .PreLSURWM, .LSUAtomicM, .LSUPAdrM,
|
atomic atomic(.clk, .reset, .FlushW, .CPUBusy, .ReadDataM, .WriteDataM, .LSUPAdrM,
|
||||||
.SquashSCM, .LSURWM, ... ); *** */
|
.LSUFunct7M, .LSUFunct3M, .LSUAtomicM, .PreLSURWM, .IgnoreRequest,
|
||||||
atomic atomic(.clk, .reset, .FlushW, .CPUBusy, .ReadDataM, .WriteDataM, .LSUPAdrM, .LSUFunct7M,
|
.DTLBMissM, .FinalAMOWriteDataM, .SquashSCW, .LSURWM);
|
||||||
.LSUFunct3M, .LSUAtomicM, .PreLSURWM, .IgnoreRequest, .DTLBMissM,
|
|
||||||
.FinalAMOWriteDataM, .SquashSCW, .LSURWM);
|
|
||||||
|
|
||||||
end else begin:lrsc
|
end else begin:lrsc
|
||||||
assign SquashSCW = 0; assign LSURWM = PreLSURWM; assign FinalAMOWriteDataM = WriteDataM;
|
assign SquashSCW = 0; assign LSURWM = PreLSURWM; assign FinalAMOWriteDataM = WriteDataM;
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user