Implements a least recently used (LRU) cache.
uvm_lru_cache(KEY_T,DATA_T) | |
Implements a least recently used (LRU) cache. | |
Methods | |
new | Constructor, initializes the cache. |
size | Returns the current number of elements in the cache. |
exists | Returns true if key exists in the cache, otherwise returns false. |
get | Returns data associated with key. |
put | Puts data in cache at index key. |
evict | Removes the data at key from the cache. |
evict_to_max | Implementation of uvm_cache#(KEY_T,DATA_T)::evict_to_max hook. |
keys | Returns a queue of all keys currently in the cache. |
function new( string name = "unnamed-uvm_lru_cache", size_t max_size = 256 )
Constructor, initializes the cache.
The max_size argument defines the initial maximum size of the cache. The default max_size shall be 256.
A max_size of 0 indicates that the cache is unsized, and will not evict any keys.
virtual function bit exists( KEY_T key )
Returns true if key exists in the cache, otherwise returns false.
virtual function optional_data get( KEY_T key )
Returns data associated with key.
If key exists within the cache, then the data is returned via <optional_data>.
If key does not existing within the cache, then this operation shall have no effect on the cache, and shall return empty <optional_data>.
virtual function void put( KEY_T key, DATA_T data )
Puts data in cache at index key.
If key exists within the cache, then the data associated data is updated. If key does not exists within the cache, then a new data value is added at key.
If putting the key in the cache causes the number of stored keys to exceed <get_max_size>, then the least recently used key shall be evicted via evict.
virtual function optional_data evict( KEY_T key )
Removes the data at key from the cache.
If key exists within the cache, then the data is returned via <optional_data>.
If key does not exist within the cache, then this operation shall have no effect on the cache, and shall return empty optional data.
protected virtual function void evict_to_max()
Implementation of uvm_cache#(KEY_T,DATA_T)::evict_to_max hook.
Evicts least recently used keys until size is less than or equal to max size.
Constructor, initializes the cache.
function new( string name = "unnamed-uvm_lru_cache", size_t max_size = 256 )
Returns the current number of elements in the cache.
virtual function size_t size()
Returns true if key exists in the cache, otherwise returns false.
virtual function bit exists( KEY_T key )
Returns data associated with key.
virtual function optional_data get( KEY_T key )
Puts data in cache at index key.
virtual function void put( KEY_T key, DATA_T data )
Removes the data at key from the cache.
virtual function optional_data evict( KEY_T key )
Implementation of uvm_cache#(KEY_T,DATA_T)::evict_to_max hook.
protected virtual function void evict_to_max()
Returns a queue of all keys currently in the cache.
virtual function optional_keys keys()