Skip to content

Commit

Permalink
running plru tb
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammad3mar committed Dec 26, 2024
1 parent c8dfa10 commit cf674b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
7 changes: 4 additions & 3 deletions source/ifu/ifu_cache.sv
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ module updatePLruTree (
logic [P_BITS - 1 : 0] index;

always_comb begin
index = 0;
//index = 0;
updatedTree = currentTree;
for (int level = P_BITS - 1 ; level >= 0; level--) begin
updatedTree[index] = (line >> level) & 1;
Expand All @@ -179,12 +179,13 @@ module getPLRUIndex (
);

always_comb begin
index = 0;
//index = 0;
while(index < NUM_LINES - 1) begin
// Updates the index to search in the next layer in the tree, tree[index] chooses the left or right node
index = (index << 1 ) | tree[index];
index = index & 4'b1111; // mod 16 to insure the index is always smaller than 16
index = index % 15 ; // mod 15 to insure the index is always smaller than 16
end
//index = index & ((1 << P_BITS) - 1);
end

endmodule
Expand Down
3 changes: 2 additions & 1 deletion verif/ifu/file_list/ifu_verif_list.f
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
+incdir+../../../source/common/
+incdir+../../../verif/ifu/tb/
../../../verif/ifu/tb/ifu_cache_tb.sv
../../../verif/ifu/tb/ifu_cache_tb.sv
../../../verif/ifu/tb/PLRU_tb.sv
37 changes: 14 additions & 23 deletions verif/ifu/tb/PLRU_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

module PLRU_tb;

// Parameters
parameter NUM_TAGS = 16; // Number of tags (cache lines)
parameter NUM_LINES = 16; // Number of lines
parameter TAG_WIDTH = 30; // Width of each tag
parameter LINE_WIDTH = 128; // Width of each cache line
parameter ADDR_WIDTH = 32; // Address width
parameter OFFSET_WIDTH = 4; // Offset bits in address

import ifu_pkg::*;

// Inputs
logic Clock;
logic Rst;
Expand All @@ -30,16 +24,13 @@ module PLRU_tb;
logic [TAG_WIDTH-1:0] debug_tagArray [NUM_TAGS];
logic [NUM_TAGS-1:0] debug_validArray;
logic [NUM_LINES-2:0] debug_plruTree;
logic hitStatusOut;
logic dataInsertion;
logic [NUM_LINES - 2 :0] plruTreeOut;

// Instantiate the DUT (Device Under Test)
ifu_cache #(
.NUM_TAGS(NUM_TAGS),
.NUM_LINES(NUM_LINES),
.TAG_WIDTH(TAG_WIDTH),
.LINE_WIDTH(LINE_WIDTH),
.ADDR_WIDTH(ADDR_WIDTH),
.OFFSET_WIDTH(OFFSET_WIDTH)
) dut (
ifu_cache
dut (
.Clock(Clock),
.Rst(Rst),
.cpu_reqAddrIn(cpu_reqAddrIn),
Expand All @@ -51,10 +42,10 @@ module PLRU_tb;
.mem_rspInsLineValidIn(mem_rspInsLineValidIn),
.mem_reqTagOut(mem_reqTagOut),
.mem_reqTagValidOut(mem_reqTagValidOut),
.debug_dataArray(debug_dataArray),
.debug_tagArray(debug_tagArray),
.debug_validArray(debug_validArray),
.debug_plruTree(debug_plruTree)
.dataInsertion(dataInsertion),
.hitStatusOut(hitStatusOut),
.plruTreeOut(plruTreeOut)
//.debug_plruTree(debug_plruTree)
);

// Clock generation
Expand All @@ -80,10 +71,10 @@ module PLRU_tb;
Rst = 0;
#10;
// Verify all entries are invalid and PLRU tree is reset
for (int i = 0; i < NUM_TAGS; i++) begin
/*for (int i = 0; i < NUM_TAGS; i++) begin
assert(dut.debug_validArray[i] == 0) else $fatal("Reset failed for validArray[%0d].", i);
end
assert(dut.debug_plruTree == 0) else $fatal("PLRU tree reset failed.");
end*/
// assert(dut.debug_plruTree == 0) else $fatal("PLRU tree reset failed.");

// 2. Basic Cache Miss
$display("Test %0d: Basic Cache Miss", ++test_counter);
Expand Down

0 comments on commit cf674b9

Please sign in to comment.