PoC.sort.lru_cacheΒΆ

This is an optimized implementation of sort_lru_list to be used for caches. Only keys are stored within this list, and these keys are the index of the cache lines. The list initially contains all indizes from 0 to ELEMENTS-1. The least-recently used index KeyOut is always valid.

The first outputed least-recently used index will be ELEMENTS-1.

The inputs Insert, Free, KeyIn, and Reset are synchronous to the rising-edge of the clock clock. All control signals are high-active.

Supported operations:
  • Insert: Mark index KeyIn as recently used, e.g., when a cache-line was accessed.
  • Free: Mark index KeyIn as least-recently used. Apply this operation, when a cache-line gets invalidated.

Entity Declaration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
entity sort_lru_cache is
  generic (
    ELEMENTS       : positive         := 32
  );
  port (
    Clock   : in std_logic;
    Reset   : in std_logic;

    Insert  : in  std_logic;
    Free    : in  std_logic;
    KeyIn   : in  std_logic_vector(log2ceilnz(ELEMENTS) - 1 downto 0);

    KeyOut  : out std_logic_vector(log2ceilnz(ELEMENTS) - 1 downto 0)
  );
end entity;