mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Removed 1 cycle delay on store miss.
Changed some logic to partially support atomics.
This commit is contained in:
parent
b9f8c25280
commit
89a7b38f79
77
wally-pipelined/src/cache/dcache.sv
vendored
77
wally-pipelined/src/cache/dcache.sv
vendored
@ -146,7 +146,6 @@ module dcache
|
|||||||
logic PreCntEn;
|
logic PreCntEn;
|
||||||
logic CntEn;
|
logic CntEn;
|
||||||
logic CntReset;
|
logic CntReset;
|
||||||
logic CPUBusy, PreviousCPUBusy;
|
|
||||||
logic SelEvict;
|
logic SelEvict;
|
||||||
|
|
||||||
logic LRUWriteEn;
|
logic LRUWriteEn;
|
||||||
@ -364,27 +363,7 @@ module dcache
|
|||||||
.d(LSUData),
|
.d(LSUData),
|
||||||
.q(SavedReadDataM));
|
.q(SavedReadDataM));
|
||||||
|
|
||||||
// *** BUG remove mux
|
assign ReadDataM = LSUData;
|
||||||
mux2 #(`XLEN)
|
|
||||||
ReadDataMMux(.d0(LSUData),
|
|
||||||
.d1(SavedReadDataM),
|
|
||||||
.s(1'b0),
|
|
||||||
.y(ReadDataM));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This is a confusing point.
|
|
||||||
// The final read data should be updated only if the CPU's StallWtoDCache is low
|
|
||||||
// which means the CPU is ready to take data. Or if the CPU just became
|
|
||||||
// busy. Then when we exit CPU_BUSY we want to ensure the data is not
|
|
||||||
// updated, this is ~PreviousCPUBusy.
|
|
||||||
// also must update if cpu stalled and processing a read miss
|
|
||||||
// which occurs if in state miss read word delay.
|
|
||||||
assign CPUBusy = CurrState == STATE_CPU_BUSY;
|
|
||||||
flop #(1) CPUBusyReg(.clk, .d(CPUBusy), .q(PreviousCPUBusy));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write path
|
// write path
|
||||||
subwordwrite subwordwrite(.HRDATA(ReadDataWordM),
|
subwordwrite subwordwrite(.HRDATA(ReadDataWordM),
|
||||||
@ -398,7 +377,7 @@ module dcache
|
|||||||
logic [`XLEN-1:0] AMOResult;
|
logic [`XLEN-1:0] AMOResult;
|
||||||
amoalu amoalu(.srca(ReadDataM), .srcb(WriteDataM), .funct(Funct7M), .width(Funct3M[1:0]),
|
amoalu amoalu(.srca(ReadDataM), .srcb(WriteDataM), .funct(Funct7M), .width(Funct3M[1:0]),
|
||||||
.result(AMOResult));
|
.result(AMOResult));
|
||||||
mux2 #(`XLEN) wdmux(FinalWriteDataM, AMOResult, SelAMOWrite & AtomicM[1], FinalAMOWriteDataM);
|
mux2 #(`XLEN) wdmux(FinalWriteDataM, AMOResult, AtomicM[1], FinalAMOWriteDataM);
|
||||||
end else
|
end else
|
||||||
assign FinalAMOWriteDataM = FinalWriteDataM;
|
assign FinalAMOWriteDataM = FinalWriteDataM;
|
||||||
endgenerate
|
endgenerate
|
||||||
@ -513,26 +492,22 @@ module dcache
|
|||||||
DCacheStall = 1'b1;
|
DCacheStall = 1'b1;
|
||||||
NextState = STATE_PTW_READY;
|
NextState = STATE_PTW_READY;
|
||||||
end
|
end
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
|
||||||
else if(SelPTW) begin
|
|
||||||
// Now we have activated the ptw.
|
|
||||||
// Do not assert Stall as we are now directing the stall the ptw.
|
|
||||||
NextState = STATE_PTW_READY;
|
|
||||||
CommittedM = 1'b1;
|
|
||||||
end
|
|
||||||
-----/\----- EXCLUDED -----/\----- */
|
|
||||||
// amo hit
|
// amo hit
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
else if(AtomicM[1] & (&MemRWM) & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit & ~DTLBMissM) begin
|
||||||
else if(|AtomicM & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit & ~DTLBMissM) begin
|
SelAdrM = 2'b01;
|
||||||
NextState = STATE_AMO_UPDATE;
|
DCacheStall = 1'b0;
|
||||||
DCacheStall = 1'b1;
|
SRAMWordWriteEnableM = 1'b1;
|
||||||
|
SetDirtyM = 1'b1;
|
||||||
|
LRUWriteEn = 1'b1;
|
||||||
|
|
||||||
if(StallWtoDCache) begin
|
if(StallWtoDCache) begin
|
||||||
NextState = STATE_CPU_BUSY;
|
NextState = STATE_CPU_BUSY;
|
||||||
SelAdrM = 2'b01;
|
SelAdrM = 2'b01;
|
||||||
else NextState = STATE_AMO_UPDATE;
|
|
||||||
end
|
end
|
||||||
-----/\----- EXCLUDED -----/\----- */
|
else begin
|
||||||
|
NextState = STATE_READY;
|
||||||
|
end
|
||||||
|
end
|
||||||
// read hit valid cached
|
// read hit valid cached
|
||||||
else if(MemRWM[1] & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit & ~DTLBMissM) begin
|
else if(MemRWM[1] & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit & ~DTLBMissM) begin
|
||||||
DCacheStall = 1'b0;
|
DCacheStall = 1'b0;
|
||||||
@ -592,22 +567,6 @@ module dcache
|
|||||||
else NextState = STATE_READY;
|
else NextState = STATE_READY;
|
||||||
end
|
end
|
||||||
|
|
||||||
STATE_AMO_UPDATE: begin
|
|
||||||
NextState = STATE_AMO_WRITE;
|
|
||||||
SaveSRAMRead = 1'b1;
|
|
||||||
SRAMWordWriteEnableM = 1'b1; // pipelined 1 cycle
|
|
||||||
end
|
|
||||||
STATE_AMO_WRITE: begin
|
|
||||||
SelAMOWrite = 1'b1;
|
|
||||||
if(StallWtoDCache) begin
|
|
||||||
NextState = STATE_CPU_BUSY;
|
|
||||||
SelAdrM = 2'b01;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
NextState = STATE_READY;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
STATE_MISS_FETCH_WDV: begin
|
STATE_MISS_FETCH_WDV: begin
|
||||||
DCacheStall = 1'b1;
|
DCacheStall = 1'b1;
|
||||||
PreCntEn = 1'b1;
|
PreCntEn = 1'b1;
|
||||||
@ -649,12 +608,12 @@ module dcache
|
|||||||
SelAdrM = 2'b01;
|
SelAdrM = 2'b01;
|
||||||
DCacheStall = 1'b1;
|
DCacheStall = 1'b1;
|
||||||
CommittedM = 1'b1;
|
CommittedM = 1'b1;
|
||||||
if (MemRWM[1]) begin
|
if (MemRWM[0]) begin // handles stores and amo write.
|
||||||
|
NextState = STATE_MISS_WRITE_WORD;
|
||||||
|
end else begin
|
||||||
NextState = STATE_MISS_READ_WORD_DELAY;
|
NextState = STATE_MISS_READ_WORD_DELAY;
|
||||||
// delay state is required as the read signal MemRWM[1] is still high when we
|
// delay state is required as the read signal MemRWM[1] is still high when we
|
||||||
// return to the ready state because the cache is stalling the cpu.
|
// return to the ready state because the cache is stalling the cpu.
|
||||||
end else begin
|
|
||||||
NextState = STATE_MISS_WRITE_WORD;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -675,14 +634,8 @@ module dcache
|
|||||||
SRAMWordWriteEnableM = 1'b1;
|
SRAMWordWriteEnableM = 1'b1;
|
||||||
SetDirtyM = 1'b1;
|
SetDirtyM = 1'b1;
|
||||||
SelAdrM = 2'b01;
|
SelAdrM = 2'b01;
|
||||||
DCacheStall = 1'b1;
|
|
||||||
CommittedM = 1'b1;
|
CommittedM = 1'b1;
|
||||||
LRUWriteEn = 1'b1;
|
LRUWriteEn = 1'b1;
|
||||||
NextState = STATE_MISS_WRITE_WORD_DELAY;
|
|
||||||
end
|
|
||||||
|
|
||||||
STATE_MISS_WRITE_WORD_DELAY: begin
|
|
||||||
CommittedM = 1'b1;
|
|
||||||
if(StallWtoDCache) begin
|
if(StallWtoDCache) begin
|
||||||
NextState = STATE_CPU_BUSY;
|
NextState = STATE_CPU_BUSY;
|
||||||
SelAdrM = 2'b01;
|
SelAdrM = 2'b01;
|
||||||
|
Loading…
Reference in New Issue
Block a user