forked from Github_Repos/cvw
More progress on icache controller
This commit is contained in:
parent
ad0d77e9e1
commit
ba95557c44
@ -150,14 +150,15 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
// Handle cache faults
|
// Handle cache faults
|
||||||
|
|
||||||
localparam integer WORDSPERLINE = LINESIZE/`XLEN;
|
localparam integer WORDSPERLINE = LINESIZE/`XLEN;
|
||||||
|
localparam integer LOGWPL = $clog2(WORDSPERLINE);
|
||||||
localparam integer OFFSETWIDTH = $clog2(LINESIZE/8);
|
localparam integer OFFSETWIDTH = $clog2(LINESIZE/8);
|
||||||
|
|
||||||
logic FetchState;
|
logic FetchState, EndFetchState, BeginFetchState;
|
||||||
logic [$clog2(WORDSPERLINE)-1:0] FetchWordNum;
|
logic [LOGWPL:0] FetchWordNum, NextFetchWordNum;
|
||||||
logic [`XLEN-1:0] LineAlignedPCPF;
|
logic [`XLEN-1:0] LineAlignedPCPF;
|
||||||
|
|
||||||
flopr #(1) FetchStateFlop(clk, reset, 1'b0, FetchState);
|
flopr #(1) FetchStateFlop(clk, reset, BeginFetchState | (FetchState & ~EndFetchState), FetchState);
|
||||||
flopr #($clog2(WORDSPERLINE)) FetchWordNumFlop(clk, reset, {$clog2(WORDSPERLINE){1'b0}}, FetchWordNum);
|
flopr #(LOGWPL+1) FetchWordNumFlop(clk, reset, NextFetchWordNum, FetchWordNum);
|
||||||
|
|
||||||
genvar i;
|
genvar i;
|
||||||
generate
|
generate
|
||||||
@ -166,10 +167,23 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
end
|
end
|
||||||
endgenerate
|
endgenerate
|
||||||
|
|
||||||
|
// Machinery to request the correct addresses from main memory
|
||||||
always_comb begin
|
always_comb begin
|
||||||
assign InstrReadF = FetchState;
|
assign InstrReadF = FetchState;
|
||||||
assign LineAlignedPCPF = {UpperPCPF, LowerPCF[11:OFFSETWIDTH], {OFFSETWIDTH{1'b0}}};
|
assign LineAlignedPCPF = {UpperPCPF, LowerPCF[11:OFFSETWIDTH], {OFFSETWIDTH{1'b0}}};
|
||||||
assign InstrPAdrF = LineAlignedPCPF + i*`XLEN;
|
assign InstrPAdrF = LineAlignedPCPF + FetchWordNum*`XLEN;
|
||||||
|
assign NextFetchWordNum = FetchState ? FetchWordNum+1 : {LOGWPL+1{1'b0}};
|
||||||
|
end
|
||||||
|
|
||||||
|
// Write to cache memory when we have the line here
|
||||||
|
always_comb begin
|
||||||
|
assign BeginFetchState = 1'b0;
|
||||||
|
assign EndFetchState = FetchWordNum == {1'b1, {LOGWPL{1'b0}}};
|
||||||
|
end
|
||||||
|
|
||||||
|
// Stall the pipeline while loading a new line from memory
|
||||||
|
always_comb begin
|
||||||
|
assign ICacheStallF = FetchState | ~ICacheMemReadValid;
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user