mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
More icache bugfixes
This commit is contained in:
parent
757b64e487
commit
c32fe09056
5
wally-pipelined/src/cache/dmapped.sv
vendored
5
wally-pipelined/src/cache/dmapped.sv
vendored
@ -70,6 +70,7 @@ module rodirectmappedmem #(parameter NUMLINES=512, parameter LINESIZE = 256, par
|
|||||||
// Machinery to check if a given read is valid and is the desired value
|
// Machinery to check if a given read is valid and is the desired value
|
||||||
logic [TAGWIDTH-1:0] DataTag;
|
logic [TAGWIDTH-1:0] DataTag;
|
||||||
logic [NUMLINES-1:0] ValidOut;
|
logic [NUMLINES-1:0] ValidOut;
|
||||||
|
logic DataValidBit;
|
||||||
|
|
||||||
flopenr #(`XLEN) ReadPAdrFlop(clk, reset, ~stall, ReadPAdr, OldReadPAdr);
|
flopenr #(`XLEN) ReadPAdrFlop(clk, reset, ~stall, ReadPAdr, OldReadPAdr);
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ module rodirectmappedmem #(parameter NUMLINES=512, parameter LINESIZE = 256, par
|
|||||||
ValidOut[WriteSet] <= 1;
|
ValidOut[WriteSet] <= 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
DataValid <= ValidOut[ReadSet] && (DataTag == ReadTag);
|
DataValidBit <= ValidOut[ReadSet];
|
||||||
end
|
end
|
||||||
|
assign DataValid = DataValidBit && (DataTag == ReadTag);
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -61,13 +61,14 @@ module icache(
|
|||||||
logic ICacheMemWriteEnable;
|
logic ICacheMemWriteEnable;
|
||||||
logic [ICACHELINESIZE-1:0] ICacheMemWriteData;
|
logic [ICACHELINESIZE-1:0] ICacheMemWriteData;
|
||||||
logic [`XLEN-1:0] ICacheMemWritePAdr;
|
logic [`XLEN-1:0] ICacheMemWritePAdr;
|
||||||
|
logic EndFetchState;
|
||||||
// Output signals from cache memory
|
// Output signals from cache memory
|
||||||
logic [`XLEN-1:0] ICacheMemReadData;
|
logic [`XLEN-1:0] ICacheMemReadData;
|
||||||
logic ICacheMemReadValid;
|
logic ICacheMemReadValid;
|
||||||
|
|
||||||
rodirectmappedmem #(.LINESIZE(ICACHELINESIZE), .NUMLINES(ICACHENUMLINES), .WORDSIZE(`XLEN)) cachemem(
|
rodirectmappedmem #(.LINESIZE(ICACHELINESIZE), .NUMLINES(ICACHENUMLINES), .WORDSIZE(`XLEN)) cachemem(
|
||||||
.*,
|
.*,
|
||||||
.stall(StallF && (~ICacheStallF || ~InstrAckF)),
|
.stall(StallF && (~ICacheStallF || ~EndFetchState)),
|
||||||
.flush(FlushMem),
|
.flush(FlushMem),
|
||||||
.ReadUpperPAdr(ICacheMemReadUpperPAdr),
|
.ReadUpperPAdr(ICacheMemReadUpperPAdr),
|
||||||
.ReadLowerAdr(ICacheMemReadLowerAdr),
|
.ReadLowerAdr(ICacheMemReadLowerAdr),
|
||||||
@ -116,7 +117,7 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
output logic [31:0] InstrRawD,
|
output logic [31:0] InstrRawD,
|
||||||
|
|
||||||
// Outputs to pipeline control stuff
|
// Outputs to pipeline control stuff
|
||||||
output logic ICacheStallF,
|
output logic ICacheStallF, EndFetchState,
|
||||||
|
|
||||||
// Signals to/from ahblite interface
|
// Signals to/from ahblite interface
|
||||||
// A read containing the requested data
|
// A read containing the requested data
|
||||||
@ -142,6 +143,7 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
// Detect if the instruction is compressed
|
// Detect if the instruction is compressed
|
||||||
assign CompressedF = AlignedInstrRawF[1:0] != 2'b11;
|
assign CompressedF = AlignedInstrRawF[1:0] != 2'b11;
|
||||||
|
|
||||||
|
|
||||||
// Handle happy path (data in cache, reads aligned)
|
// Handle happy path (data in cache, reads aligned)
|
||||||
|
|
||||||
generate
|
generate
|
||||||
@ -216,7 +218,7 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
localparam integer LOGWPL = $clog2(WORDSPERLINE);
|
localparam integer LOGWPL = $clog2(WORDSPERLINE);
|
||||||
localparam integer OFFSETWIDTH = $clog2(LINESIZE/8);
|
localparam integer OFFSETWIDTH = $clog2(LINESIZE/8);
|
||||||
|
|
||||||
logic FetchState, EndFetchState, BeginFetchState;
|
logic FetchState, BeginFetchState;
|
||||||
logic [LOGWPL:0] FetchWordNum, NextFetchWordNum;
|
logic [LOGWPL:0] FetchWordNum, NextFetchWordNum;
|
||||||
logic [`XLEN-1:0] LineAlignedPCPF;
|
logic [`XLEN-1:0] LineAlignedPCPF;
|
||||||
|
|
||||||
@ -232,26 +234,27 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
|
|
||||||
// Enter the fetch state when we hit a cache fault
|
// Enter the fetch state when we hit a cache fault
|
||||||
always_comb begin
|
always_comb begin
|
||||||
assign BeginFetchState = ~ICacheMemReadValid & ~FetchState;
|
BeginFetchState = ~ICacheMemReadValid & ~FetchState & (FetchWordNum == 0);
|
||||||
end
|
end
|
||||||
|
// Exit the fetch state once the cache line has been loaded
|
||||||
|
flopr #(1) EndFetchStateFlop(clk, reset, ICacheMemWriteEnable, EndFetchState);
|
||||||
|
|
||||||
// Machinery to request the correct addresses from main memory
|
// Machinery to request the correct addresses from main memory
|
||||||
always_comb begin
|
always_comb begin
|
||||||
assign InstrReadF = FetchState & ~EndFetchState;
|
InstrReadF = FetchState & ~EndFetchState & ~ICacheMemWriteEnable;
|
||||||
assign LineAlignedPCPF = {ICacheMemReadUpperPAdr, ICacheMemReadLowerAdr[11:OFFSETWIDTH], {OFFSETWIDTH{1'b0}}};
|
LineAlignedPCPF = {ICacheMemReadUpperPAdr, ICacheMemReadLowerAdr[11:OFFSETWIDTH], {OFFSETWIDTH{1'b0}}};
|
||||||
assign InstrPAdrF = LineAlignedPCPF + FetchWordNum*(`XLEN/8);
|
InstrPAdrF = LineAlignedPCPF + FetchWordNum*(`XLEN/8);
|
||||||
assign NextFetchWordNum = FetchState ? FetchWordNum+InstrAckF : {LOGWPL+1{1'b0}};
|
NextFetchWordNum = FetchState ? FetchWordNum+InstrAckF : {LOGWPL+1{1'b0}};
|
||||||
end
|
end
|
||||||
|
|
||||||
// Write to cache memory when we have the line here
|
// Write to cache memory when we have the line here
|
||||||
always_comb begin
|
always_comb begin
|
||||||
assign EndFetchState = FetchWordNum == {1'b1, {LOGWPL{1'b0}}} & FetchState;
|
ICacheMemWritePAdr = LineAlignedPCPF;
|
||||||
assign ICacheMemWritePAdr = LineAlignedPCPF;
|
ICacheMemWriteEnable = FetchWordNum == {1'b1, {LOGWPL{1'b0}}} & FetchState & ~EndFetchState;
|
||||||
assign ICacheMemWriteEnable = EndFetchState;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
// Stall the pipeline while loading a new line from memory
|
// Stall the pipeline while loading a new line from memory
|
||||||
always_comb begin
|
always_comb begin
|
||||||
assign FaultStall = FetchState | ~ICacheMemReadValid;
|
FaultStall = FetchState | ~ICacheMemReadValid;
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user