mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Moved the sub cache line read logic to lsu/ifu.
This commit is contained in:
parent
725852362e
commit
290430cda8
14
pipelined/src/cache/cache.sv
vendored
14
pipelined/src/cache/cache.sv
vendored
@ -42,12 +42,12 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, DCACHE = 1) (
|
|||||||
input logic [11:0] NextAdr, // virtual address, but we only use the lower 12 bits.
|
input logic [11:0] NextAdr, // virtual address, but we only use the lower 12 bits.
|
||||||
input logic [`PA_BITS-1:0] PAdr, // physical address
|
input logic [`PA_BITS-1:0] PAdr, // physical address
|
||||||
input logic [`XLEN-1:0] FinalWriteData,
|
input logic [`XLEN-1:0] FinalWriteData,
|
||||||
output logic [`XLEN-1:0] ReadDataWord,
|
|
||||||
output logic CacheCommitted,
|
output logic CacheCommitted,
|
||||||
output logic CacheStall,
|
output logic CacheStall,
|
||||||
// to performance counters to cpu
|
// to performance counters to cpu
|
||||||
output logic CacheMiss,
|
output logic CacheMiss,
|
||||||
output logic CacheAccess,
|
output logic CacheAccess,
|
||||||
|
output logic save, restore,
|
||||||
// lsu control
|
// lsu control
|
||||||
input logic IgnoreRequest,
|
input logic IgnoreRequest,
|
||||||
// Bus fsm interface
|
// Bus fsm interface
|
||||||
@ -56,6 +56,7 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, DCACHE = 1) (
|
|||||||
input logic CacheBusAck,
|
input logic CacheBusAck,
|
||||||
output logic [`PA_BITS-1:0] CacheBusAdr,
|
output logic [`PA_BITS-1:0] CacheBusAdr,
|
||||||
input logic [LINELEN-1:0] CacheMemWriteData,
|
input logic [LINELEN-1:0] CacheMemWriteData,
|
||||||
|
output logic [LINELEN-1:0] ReadDataLine,
|
||||||
output logic [`XLEN-1:0] ReadDataLineSets [(LINELEN/`XLEN)-1:0]);
|
output logic [`XLEN-1:0] ReadDataLineSets [(LINELEN/`XLEN)-1:0]);
|
||||||
|
|
||||||
// Cache parameters
|
// Cache parameters
|
||||||
@ -77,7 +78,6 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, DCACHE = 1) (
|
|||||||
logic [LINELEN-1:0] ReadDataLineWay [NUMWAYS-1:0];
|
logic [LINELEN-1:0] ReadDataLineWay [NUMWAYS-1:0];
|
||||||
logic [NUMWAYS-1:0] WayHit;
|
logic [NUMWAYS-1:0] WayHit;
|
||||||
logic CacheHit;
|
logic CacheHit;
|
||||||
logic [LINELEN-1:0] ReadDataLine;
|
|
||||||
logic [WORDSPERLINE-1:0] SRAMWordEnable;
|
logic [WORDSPERLINE-1:0] SRAMWordEnable;
|
||||||
logic SRAMWordWriteEnable;
|
logic SRAMWordWriteEnable;
|
||||||
logic SRAMLineWriteEnable;
|
logic SRAMLineWriteEnable;
|
||||||
@ -106,7 +106,6 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, DCACHE = 1) (
|
|||||||
logic [NUMWAYS-1:0] VDWriteEnableWay;
|
logic [NUMWAYS-1:0] VDWriteEnableWay;
|
||||||
logic SelFlush;
|
logic SelFlush;
|
||||||
logic ResetOrFlushAdr, ResetOrFlushWay;
|
logic ResetOrFlushAdr, ResetOrFlushWay;
|
||||||
logic save, restore;
|
|
||||||
logic [NUMWAYS-1:0] WayHitSaved, WayHitRaw;
|
logic [NUMWAYS-1:0] WayHitSaved, WayHitRaw;
|
||||||
logic [LINELEN-1:0] ReadDataLineRaw, ReadDataLineSaved;
|
logic [LINELEN-1:0] ReadDataLineRaw, ReadDataLineSaved;
|
||||||
|
|
||||||
@ -159,20 +158,11 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, DCACHE = 1) (
|
|||||||
// *** give this a module name to match block diagram
|
// *** give this a module name to match block diagram
|
||||||
genvar index;
|
genvar index;
|
||||||
if(DCACHE == 1) begin: readdata
|
if(DCACHE == 1) begin: readdata
|
||||||
subcachelineread #(LINELEN, `XLEN, `XLEN) subcachelineread(
|
|
||||||
.clk, .reset, .PAdr, .save, .restore,
|
|
||||||
.ReadDataLine, .ReadDataWord);
|
|
||||||
// *** only here temporary
|
// *** only here temporary
|
||||||
for (index = 0; index < WORDSPERLINE; index++) begin:readdatalinesetsmux
|
for (index = 0; index < WORDSPERLINE; index++) begin:readdatalinesetsmux
|
||||||
assign ReadDataLineSets[index] = ReadDataLine[((index+1)*`XLEN)-1: (index*`XLEN)];
|
assign ReadDataLineSets[index] = ReadDataLine[((index+1)*`XLEN)-1: (index*`XLEN)];
|
||||||
end
|
end
|
||||||
end else begin: readdata
|
end else begin: readdata
|
||||||
logic [31:0] FinalInstrRawF;
|
|
||||||
subcachelineread #(LINELEN, 32, 16) subcachelineread(
|
|
||||||
.clk, .reset, .PAdr, .save, .restore,
|
|
||||||
.ReadDataLine, .ReadDataWord(FinalInstrRawF));
|
|
||||||
if (`XLEN == 64) assign ReadDataWord = {32'b0, FinalInstrRawF};
|
|
||||||
else assign ReadDataWord = FinalInstrRawF;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -92,7 +92,7 @@ module ifu (
|
|||||||
logic [`XLEN-3:0] PCPlusUpperF;
|
logic [`XLEN-3:0] PCPlusUpperF;
|
||||||
logic CompressedF;
|
logic CompressedF;
|
||||||
logic [31:0] InstrRawD, InstrRawF;
|
logic [31:0] InstrRawD, InstrRawF;
|
||||||
logic [`XLEN-1:0] FinalInstrRawF;
|
logic [31:0] FinalInstrRawF;
|
||||||
|
|
||||||
logic [31:0] InstrE;
|
logic [31:0] InstrE;
|
||||||
logic [`XLEN-1:0] PCD;
|
logic [`XLEN-1:0] PCD;
|
||||||
@ -180,12 +180,14 @@ module ifu (
|
|||||||
end else begin : bus
|
end else begin : bus
|
||||||
localparam integer WORDSPERLINE = (`IMEM == `MEM_CACHE) ? `ICACHE_LINELENINBITS/`XLEN : 1;
|
localparam integer WORDSPERLINE = (`IMEM == `MEM_CACHE) ? `ICACHE_LINELENINBITS/`XLEN : 1;
|
||||||
localparam integer LINELEN = (`IMEM == `MEM_CACHE) ? `ICACHE_LINELENINBITS : `XLEN;
|
localparam integer LINELEN = (`IMEM == `MEM_CACHE) ? `ICACHE_LINELENINBITS : `XLEN;
|
||||||
|
logic [LINELEN-1:0] ReadDataLine;
|
||||||
logic [LINELEN-1:0] ICacheMemWriteData;
|
logic [LINELEN-1:0] ICacheMemWriteData;
|
||||||
logic [`PA_BITS-1:0] ICacheBusAdr;
|
logic [`PA_BITS-1:0] ICacheBusAdr;
|
||||||
logic ICacheBusAck;
|
logic ICacheBusAck;
|
||||||
|
logic save,restore;
|
||||||
|
logic [31:0] temp;
|
||||||
|
|
||||||
|
busdp #(WORDSPERLINE, LINELEN, 32)
|
||||||
busdp #(WORDSPERLINE, LINELEN)
|
|
||||||
busdp(.clk, .reset,
|
busdp(.clk, .reset,
|
||||||
.LSUBusHRDATA(IFUBusHRDATA), .LSUBusAck(IFUBusAck), .LSUBusWrite(),
|
.LSUBusHRDATA(IFUBusHRDATA), .LSUBusAck(IFUBusAck), .LSUBusWrite(),
|
||||||
.LSUBusRead(IFUBusRead), .LSUBusHWDATA(), .LSUBusSize(),
|
.LSUBusRead(IFUBusRead), .LSUBusHWDATA(), .LSUBusSize(),
|
||||||
@ -193,10 +195,14 @@ module ifu (
|
|||||||
.ReadDataLineSetsM(), .DCacheFetchLine(ICacheFetchLine),
|
.ReadDataLineSetsM(), .DCacheFetchLine(ICacheFetchLine),
|
||||||
.DCacheWriteLine(1'b0), .DCacheBusAck(ICacheBusAck),
|
.DCacheWriteLine(1'b0), .DCacheBusAck(ICacheBusAck),
|
||||||
.DCacheMemWriteData(ICacheMemWriteData), .LSUPAdrM(PCPF),
|
.DCacheMemWriteData(ICacheMemWriteData), .LSUPAdrM(PCPF),
|
||||||
.FinalAMOWriteDataM(), .ReadDataWordM(FinalInstrRawF), .ReadDataWordMuxM(AllInstrRawF),
|
.FinalAMOWriteDataM(), .ReadDataWordM(FinalInstrRawF), .ReadDataWordMuxM(AllInstrRawF[31:0]),
|
||||||
.IgnoreRequest(ITLBMissF), .LSURWM(2'b10), .CPUBusy, .CacheableM(CacheableF),
|
.IgnoreRequest(ITLBMissF), .LSURWM(2'b10), .CPUBusy, .CacheableM(CacheableF),
|
||||||
.BusStall, .BusCommittedM());
|
.BusStall, .BusCommittedM());
|
||||||
|
|
||||||
|
subcachelineread #(LINELEN, 32, 16) subcachelineread(
|
||||||
|
.clk, .reset, .PAdr(PCPF), .save, .restore,
|
||||||
|
.ReadDataLine, .ReadDataWord(FinalInstrRawF));
|
||||||
|
|
||||||
if(`IMEM == `MEM_CACHE) begin : icache
|
if(`IMEM == `MEM_CACHE) begin : icache
|
||||||
logic [1:0] IFURWF;
|
logic [1:0] IFURWF;
|
||||||
assign IFURWF = CacheableF ? 2'b10 : 2'b00;
|
assign IFURWF = CacheableF ? 2'b10 : 2'b00;
|
||||||
@ -207,8 +213,9 @@ module ifu (
|
|||||||
icache(.clk, .reset, .CPUBusy, .IgnoreRequest(ITLBMissF),
|
icache(.clk, .reset, .CPUBusy, .IgnoreRequest(ITLBMissF),
|
||||||
.CacheMemWriteData(ICacheMemWriteData), .CacheBusAck(ICacheBusAck),
|
.CacheMemWriteData(ICacheMemWriteData), .CacheBusAck(ICacheBusAck),
|
||||||
.CacheBusAdr(ICacheBusAdr), .CacheStall(ICacheStallF),
|
.CacheBusAdr(ICacheBusAdr), .CacheStall(ICacheStallF),
|
||||||
.ReadDataWord(FinalInstrRawF), .CacheFetchLine(ICacheFetchLine),
|
.CacheFetchLine(ICacheFetchLine),
|
||||||
.CacheWriteLine(), .ReadDataLineSets(),
|
.CacheWriteLine(), .ReadDataLineSets(), .ReadDataLine(ReadDataLine),
|
||||||
|
.save, .restore,
|
||||||
.CacheMiss(ICacheMiss), .CacheAccess(ICacheAccess),
|
.CacheMiss(ICacheMiss), .CacheAccess(ICacheAccess),
|
||||||
.FinalWriteData('0),
|
.FinalWriteData('0),
|
||||||
.RW(IFURWF),
|
.RW(IFURWF),
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module busdp #(parameter WORDSPERLINE, parameter LINELEN)
|
module busdp #(parameter WORDSPERLINE, parameter LINELEN, WORDLEN)
|
||||||
(
|
(
|
||||||
input logic clk, reset,
|
input logic clk, reset,
|
||||||
// bus interface
|
// bus interface
|
||||||
@ -58,8 +58,8 @@ module busdp #(parameter WORDSPERLINE, parameter LINELEN)
|
|||||||
// lsu interface
|
// lsu interface
|
||||||
input logic [`PA_BITS-1:0] LSUPAdrM,
|
input logic [`PA_BITS-1:0] LSUPAdrM,
|
||||||
input logic [`XLEN-1:0] FinalAMOWriteDataM,
|
input logic [`XLEN-1:0] FinalAMOWriteDataM,
|
||||||
input logic [`XLEN-1:0] ReadDataWordM,
|
input logic [WORDLEN-1:0] ReadDataWordM,
|
||||||
output logic [`XLEN-1:0] ReadDataWordMuxM,
|
output logic [WORDLEN-1:0] ReadDataWordMuxM,
|
||||||
input logic IgnoreRequest,
|
input logic IgnoreRequest,
|
||||||
input logic [1:0] LSURWM,
|
input logic [1:0] LSURWM,
|
||||||
input logic CPUBusy,
|
input logic CPUBusy,
|
||||||
@ -90,8 +90,8 @@ module busdp #(parameter WORDSPERLINE, parameter LINELEN)
|
|||||||
.d0(PreLSUBusHWDATA), .d1(FinalAMOWriteDataM), .s(SelUncachedAdr), .y(LSUBusHWDATA));
|
.d0(PreLSUBusHWDATA), .d1(FinalAMOWriteDataM), .s(SelUncachedAdr), .y(LSUBusHWDATA));
|
||||||
mux2 #(3) lsubussizemux(
|
mux2 #(3) lsubussizemux(
|
||||||
.d0(`XLEN == 32 ? 3'b010 : 3'b011), .d1(LSUFunct3M), .s(SelUncachedAdr), .y(LSUBusSize));
|
.d0(`XLEN == 32 ? 3'b010 : 3'b011), .d1(LSUFunct3M), .s(SelUncachedAdr), .y(LSUBusSize));
|
||||||
mux2 #(`XLEN) UnCachedDataMux(
|
mux2 #(WORDLEN) UnCachedDataMux(
|
||||||
.d0(ReadDataWordM), .d1(DCacheMemWriteData[`XLEN-1:0]), .s(SelUncachedAdr), .y(ReadDataWordMuxM));
|
.d0(ReadDataWordM), .d1(DCacheMemWriteData[WORDLEN-1:0]), .s(SelUncachedAdr), .y(ReadDataWordMuxM));
|
||||||
|
|
||||||
busfsm #(WordCountThreshold, LOGWPL, (`DMEM == `MEM_CACHE)) // *** cleanup
|
busfsm #(WordCountThreshold, LOGWPL, (`DMEM == `MEM_CACHE)) // *** cleanup
|
||||||
busfsm(.clk, .reset, .IgnoreRequest, .LSURWM, .DCacheFetchLine, .DCacheWriteLine,
|
busfsm(.clk, .reset, .IgnoreRequest, .LSURWM, .DCacheFetchLine, .DCacheWriteLine,
|
||||||
|
@ -184,13 +184,15 @@ module lsu (
|
|||||||
localparam integer WORDSPERLINE = (`DMEM == `MEM_CACHE) ? `DCACHE_LINELENINBITS/`XLEN : 1;
|
localparam integer WORDSPERLINE = (`DMEM == `MEM_CACHE) ? `DCACHE_LINELENINBITS/`XLEN : 1;
|
||||||
localparam integer LINELEN = (`DMEM == `MEM_CACHE) ? `DCACHE_LINELENINBITS : `XLEN;
|
localparam integer LINELEN = (`DMEM == `MEM_CACHE) ? `DCACHE_LINELENINBITS : `XLEN;
|
||||||
logic [`XLEN-1:0] ReadDataLineSetsM [WORDSPERLINE-1:0];
|
logic [`XLEN-1:0] ReadDataLineSetsM [WORDSPERLINE-1:0];
|
||||||
|
logic [LINELEN-1:0] ReadDataLineM;
|
||||||
logic [LINELEN-1:0] DCacheMemWriteData;
|
logic [LINELEN-1:0] DCacheMemWriteData;
|
||||||
logic [`PA_BITS-1:0] DCacheBusAdr;
|
logic [`PA_BITS-1:0] DCacheBusAdr;
|
||||||
logic DCacheWriteLine;
|
logic DCacheWriteLine;
|
||||||
logic DCacheFetchLine;
|
logic DCacheFetchLine;
|
||||||
logic DCacheBusAck;
|
logic DCacheBusAck;
|
||||||
|
logic save,restore;
|
||||||
|
|
||||||
busdp #(WORDSPERLINE, LINELEN) busdp(
|
busdp #(WORDSPERLINE, LINELEN, `XLEN) busdp(
|
||||||
.clk, .reset,
|
.clk, .reset,
|
||||||
.LSUBusHRDATA, .LSUBusAck, .LSUBusWrite, .LSUBusRead, .LSUBusHWDATA, .LSUBusSize,
|
.LSUBusHRDATA, .LSUBusAck, .LSUBusWrite, .LSUBusRead, .LSUBusHWDATA, .LSUBusSize,
|
||||||
.LSUFunct3M, .LSUBusAdr, .DCacheBusAdr, .ReadDataLineSetsM, .DCacheFetchLine,
|
.LSUFunct3M, .LSUBusAdr, .DCacheBusAdr, .ReadDataLineSetsM, .DCacheFetchLine,
|
||||||
@ -198,16 +200,21 @@ module lsu (
|
|||||||
.ReadDataWordM, .ReadDataWordMuxM, .IgnoreRequest, .LSURWM, .CPUBusy, .CacheableM,
|
.ReadDataWordM, .ReadDataWordMuxM, .IgnoreRequest, .LSURWM, .CPUBusy, .CacheableM,
|
||||||
.BusStall, .BusCommittedM);
|
.BusStall, .BusCommittedM);
|
||||||
|
|
||||||
|
subcachelineread #(LINELEN, `XLEN, `XLEN) subcachelineread(
|
||||||
|
.clk, .reset, .PAdr(LSUPAdrM), .save, .restore,
|
||||||
|
.ReadDataLine(ReadDataLineM), .ReadDataWord(ReadDataWordM));
|
||||||
|
|
||||||
if(`DMEM == `MEM_CACHE) begin : dcache
|
if(`DMEM == `MEM_CACHE) begin : dcache
|
||||||
cache #(.LINELEN(`DCACHE_LINELENINBITS), .NUMLINES(`DCACHE_WAYSIZEINBYTES*8/LINELEN),
|
cache #(.LINELEN(`DCACHE_LINELENINBITS), .NUMLINES(`DCACHE_WAYSIZEINBYTES*8/LINELEN),
|
||||||
.NUMWAYS(`DCACHE_NUMWAYS), .DCACHE(1)) dcache(
|
.NUMWAYS(`DCACHE_NUMWAYS), .DCACHE(1)) dcache(
|
||||||
.clk, .reset, .CPUBusy,
|
.clk, .reset, .CPUBusy,
|
||||||
.RW(CacheableM ? LSURWM : 2'b00), .FlushCache(FlushDCacheM),
|
.RW(CacheableM ? LSURWM : 2'b00), .FlushCache(FlushDCacheM),
|
||||||
.Atomic(CacheableM ? LSUAtomicM : 2'b00), .NextAdr(LSUAdrE), .PAdr(LSUPAdrM),
|
.Atomic(CacheableM ? LSUAtomicM : 2'b00), .NextAdr(LSUAdrE), .PAdr(LSUPAdrM),
|
||||||
.FinalWriteData(FinalWriteDataM), .ReadDataWord(ReadDataWordM),
|
.save, .restore,
|
||||||
|
.FinalWriteData(FinalWriteDataM),
|
||||||
.CacheStall(DCacheStallM), .CacheMiss(DCacheMiss), .CacheAccess(DCacheAccess),
|
.CacheStall(DCacheStallM), .CacheMiss(DCacheMiss), .CacheAccess(DCacheAccess),
|
||||||
.IgnoreRequest, .CacheCommitted(DCacheCommittedM), .CacheBusAdr(DCacheBusAdr),
|
.IgnoreRequest, .CacheCommitted(DCacheCommittedM), .CacheBusAdr(DCacheBusAdr),
|
||||||
.ReadDataLineSets(ReadDataLineSetsM), .CacheMemWriteData(DCacheMemWriteData),
|
.ReadDataLineSets(ReadDataLineSetsM), .ReadDataLine(ReadDataLineM), .CacheMemWriteData(DCacheMemWriteData),
|
||||||
.CacheFetchLine(DCacheFetchLine), .CacheWriteLine(DCacheWriteLine),
|
.CacheFetchLine(DCacheFetchLine), .CacheWriteLine(DCacheWriteLine),
|
||||||
.CacheBusAck(DCacheBusAck), .InvalidateCacheM(1'b0));
|
.CacheBusAck(DCacheBusAck), .InvalidateCacheM(1'b0));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user