This sample task is provided for illustration only. The scores may not reflect a model's overall performance on this benchmark.
You are working in a checked-out RTL workspace at /code.
Use the shell to read the existing sources, write your solution, and check your
work with the installed tools (iverilog, verilator, yosys).
Write your solution to exactly these files, creating them if they do not exist:
/code/rtl/pseudo_lru_nmru_policy.svDo not modify the harness or add test files — your work is graded by a hidden cocotb testbench run against these paths after you finish.
Complete the given partial SystemVerilog code for the pseudo_lru_nmru_policy module. This module should implement a pseudo-LRU (Least Recently Used) and NMRU (Not Most Recently Used) hybrid policy for cache replacement in a set-associative cache. Use a recency bit array to track access patterns for cache ways.
pseudo_lru_nmru_policy| Port Name | Direction | Size | Description |
|---|---|---|---|
clock | Input | 1 bit | Clock signal |
reset | Input | 1 bit | Asynchronous reset signal, active high |
index | Input | ceil(log2(NINDEXES)) bits | Index to select the cache set |
way_select | Input | ceil(log2(NWAYS)) bits | Cache way selected for access |
access | Input | 1 bit | Signal indicating a cache access |
hit | Input | 1 bit | Signal indicating a cache hit |
way_replace | Output | ceil(log2(NWAYS)) bits | Way selected for replacement |
recency array tracks access recency for each cache way for all indexes.recency are initialized to zero.recency bit is zero.recency bit is set to one.recency bit is zero, it behaves as an LRU policy, selecting that way for replacement. The selected bit is then set to one, and all others are reset to zero.Complete the given partial SystemVerilog code for the pseudo_lru_nmru_policy module. This module tracks the recency of access for cache ways and determines the way to replace based on the pseudo-LRU and NMRU policy.
module pseudo_lru_nmru_policy #(
NWAYS = 4,
NINDEXES = 32
) (
input clock,
input reset,
input [$clog2(NINDEXES)-1:0] index,
input [$clog2(NWAYS)-1:0] way_select,
input access,
input hit,
output [$clog2(NWAYS)-1:0] way_replace
);
reg [NWAYS-1:0] recency [NINDEXES-1:0];
integer reset_counter;
always_ff @ (posedge clock or posedge reset) begin
if (reset) begin
for (reset_counter = 0; reset_counter < NINDEXES; reset_counter = reset_counter + 1) begin
recency[reset_counter] <= {NWAYS{1'b0}};
end
end else begin
end
end
endmodule : pseudo_lru_nmru_policy
recency array upon hits (hit signal).way_replace signal based on the recency bits.recency array.APEX NEWSLETTER
New benchmarks, leaderboard shifts, and research from the APEX team.