mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Progress on the cache replacement policy implementation.
This commit is contained in:
parent
0796cd92fc
commit
22ad49eef2
82
pipelined/src/cache/cachereplacementpolicy.sv
vendored
82
pipelined/src/cache/cachereplacementpolicy.sv
vendored
@ -56,9 +56,8 @@ module cachereplacementpolicy
|
||||
|
||||
logic [NUMWAYS-2:0] cEn;
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
// proposed generic solution
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
binencoder #(NUMWAYS) encoder(HitWay, HitWayEnc);
|
||||
|
||||
// bit duplication
|
||||
@ -70,11 +69,7 @@ module cachereplacementpolicy
|
||||
assign HitWayExpand[StartIndex : EndIndex] = {{DuplicationFactor}{HitWayEnc[row]}};
|
||||
end
|
||||
|
||||
|
||||
genvar r, a,s;
|
||||
//localparam s = NUMWAYS-2;
|
||||
|
||||
|
||||
assign cEn[NUMWAYS-2] = '1;
|
||||
for(s = NUMWAYS-2; s >= NUMWAYS/2; s--) begin : enables
|
||||
localparam p = NUMWAYS - s;
|
||||
@ -86,75 +81,44 @@ module cachereplacementpolicy
|
||||
assign cEn[t1] = cEn[s] & HitWayEnc[r];
|
||||
end
|
||||
|
||||
mux2 #(1) LRUMuxes[NUMWAYS-2:0](LineReplacementBits, HitWayExpand, cEn, NewReplacement);
|
||||
mux2 #(1) LRUMuxes[NUMWAYS-2:0](LineReplacementBits, ~HitWayExpand, cEn, NewReplacement);
|
||||
|
||||
always_ff @(posedge clk) begin
|
||||
if (reset) for (int set = 0; set < NUMLINES; set++) ReplacementBits[set] <= '0;
|
||||
if(ce) begin
|
||||
if (LRUWriteEn) begin
|
||||
ReplacementBits[RAdr] <= NewReplacement;
|
||||
LineReplacementBits <= #1 NewReplacement;
|
||||
end else begin
|
||||
LineReplacementBits <= #1 ReplacementBits[RAdr];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
localparam HalfPoint = (2**$clog2(NUMWAYS)) / 2;
|
||||
logic [NUMWAYS-2:0] ivec;
|
||||
|
||||
|
||||
assign ivec[HalfPoint-1:0] = LineReplacementBits[HalfPoint-1:0];
|
||||
for(r = NUMWAYS-2; r >= HalfPoint; r--) begin
|
||||
|
||||
end
|
||||
|
||||
assign VictimWay[0] = ~LineReplacementBits[2] & ~LineReplacementBits[0];
|
||||
assign VictimWay[1] = ~LineReplacementBits[2] & LineReplacementBits[0];
|
||||
assign VictimWay[2] = LineReplacementBits[2] & ~LineReplacementBits[1];
|
||||
assign VictimWay[3] = LineReplacementBits[2] & LineReplacementBits[1];
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
// logic [NUMWAYS/2-1:0] rawEn [LOGNUMWAYS-1:0];
|
||||
for(r = LOGNUMWAYS-1; r >= 0; r--) begin
|
||||
localparam integer g = 2**(LOGNUMWAYS-r-1);
|
||||
for(a = g-1; a > 0; a--) begin
|
||||
localparam t0 = s - 2**(g-1);
|
||||
localparam t1 = t0 - 1;
|
||||
localparam s = s - 1;
|
||||
assign cEn[t0] = cEn[s] & ~HitWayEnc[r];
|
||||
assign cEn[t1] = cEn[s] & HitWayEnc[r];
|
||||
end
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
for(a = g-1; a > 0; a--) begin
|
||||
localparam t0 = s - 2**(g-1);
|
||||
localparam t1 = t0 - 1;
|
||||
s = s - 1;
|
||||
end
|
||||
end
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
always_comb begin
|
||||
for(r = LOGNUMWAYS-1; r > 0; r--) begin
|
||||
localparam g = 2**(LOGNUMWAYS-r-1);
|
||||
for(a = g-1; a > 0; a--) begin
|
||||
localparam t0 = s - 2**(g-1);
|
||||
localparam t1 = t0 - 1;
|
||||
s = s - 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
|
||||
genvar row2;
|
||||
logic [LOGNUMWAYS-1:0] indices [LOGNUMWAYS-1:0];
|
||||
integer jindex;
|
||||
always_comb begin
|
||||
rawEn[LOGNUMWAYS-1] = 1;
|
||||
for(jindex = 0; jindex < LOGNUMWAYS-1; jindex++) begin
|
||||
rawEn[jindex] = 0;
|
||||
rawEn[jindex][~(HitWayEnc>>(jindex+1))] = 1;
|
||||
|
||||
//cEn[2**(LOGNUMWAYS-jindex)-1+jindex:0] = rawEn[jindex][2**(LOGNUMWAYS-jindex)-1:0];
|
||||
|
||||
end
|
||||
end
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
|
||||
|
||||
// *** high priority to clean up
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
initial begin
|
||||
assert (NUMWAYS == 2 || NUMWAYS == 4) else $error("Only 2 or 4 ways supported");
|
||||
end
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
// Replacement Bits: Register file
|
||||
// Needs to be resettable for simulation, but could omit reset for synthesis ***
|
||||
|
Loading…
Reference in New Issue
Block a user