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
cf964e30fb
commit
9b2236b2a0
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;
|
logic [NUMWAYS-2:0] cEn;
|
||||||
|
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
|
||||||
// proposed generic solution
|
// proposed generic solution
|
||||||
|
/* -----\/----- EXCLUDED -----\/-----
|
||||||
binencoder #(NUMWAYS) encoder(HitWay, HitWayEnc);
|
binencoder #(NUMWAYS) encoder(HitWay, HitWayEnc);
|
||||||
|
|
||||||
// bit duplication
|
// bit duplication
|
||||||
@ -70,11 +69,7 @@ module cachereplacementpolicy
|
|||||||
assign HitWayExpand[StartIndex : EndIndex] = {{DuplicationFactor}{HitWayEnc[row]}};
|
assign HitWayExpand[StartIndex : EndIndex] = {{DuplicationFactor}{HitWayEnc[row]}};
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
genvar r, a,s;
|
genvar r, a,s;
|
||||||
//localparam s = NUMWAYS-2;
|
|
||||||
|
|
||||||
|
|
||||||
assign cEn[NUMWAYS-2] = '1;
|
assign cEn[NUMWAYS-2] = '1;
|
||||||
for(s = NUMWAYS-2; s >= NUMWAYS/2; s--) begin : enables
|
for(s = NUMWAYS-2; s >= NUMWAYS/2; s--) begin : enables
|
||||||
localparam p = NUMWAYS - s;
|
localparam p = NUMWAYS - s;
|
||||||
@ -86,75 +81,44 @@ module cachereplacementpolicy
|
|||||||
assign cEn[t1] = cEn[s] & HitWayEnc[r];
|
assign cEn[t1] = cEn[s] & HitWayEnc[r];
|
||||||
end
|
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[0] = ~LineReplacementBits[2] & ~LineReplacementBits[0];
|
||||||
assign VictimWay[1] = ~LineReplacementBits[2] & LineReplacementBits[0];
|
assign VictimWay[1] = ~LineReplacementBits[2] & LineReplacementBits[0];
|
||||||
assign VictimWay[2] = LineReplacementBits[2] & ~LineReplacementBits[1];
|
assign VictimWay[2] = LineReplacementBits[2] & ~LineReplacementBits[1];
|
||||||
assign VictimWay[3] = 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 -----/\----- */
|
||||||
|
|
||||||
/* -----\/----- 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
|
// *** high priority to clean up
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
|
||||||
initial begin
|
initial begin
|
||||||
assert (NUMWAYS == 2 || NUMWAYS == 4) else $error("Only 2 or 4 ways supported");
|
assert (NUMWAYS == 2 || NUMWAYS == 4) else $error("Only 2 or 4 ways supported");
|
||||||
end
|
end
|
||||||
-----/\----- EXCLUDED -----/\----- */
|
|
||||||
|
|
||||||
// Replacement Bits: Register file
|
// Replacement Bits: Register file
|
||||||
// Needs to be resettable for simulation, but could omit reset for synthesis ***
|
// Needs to be resettable for simulation, but could omit reset for synthesis ***
|
||||||
|
Loading…
Reference in New Issue
Block a user