-
Notifications
You must be signed in to change notification settings - Fork 137
Cache model
Daniel Kofanov edited this page Mar 21, 2020
·
6 revisions
Class CacheTagArray implements the concepts of a real tag array in a CPU cache. As you know, the cache tag array (unlike cache data array) does not store any real data (bytes of instructions, variables, arrays, etc). It is only responsible for generation hit signal, i.e. it can say whether a particular block is contained by the cache or not, but cannot provide the block data itself.
Implementation provides at least these interfaces:
class CacheTagArray
{
public:
/**
* Constructor params:
*
* 1) size_in_bytes is a number of data bytes that can be stored in the cache,
* i.e. if the block size is 16 Bytes then the number of data blocks in the cache is size_in_bytes/16.
*
* 2) ways is a number of associative ways in a set, i.e. how many blocks are referred by the same index.
*
* 3) block_size_in_bytes is a number of Bytes in a data block
*
* 4) addr_size_in_bit is a number of bits in the physical address.
*/
CacheTagArray( uint32 size_in_bytes,
uint32 ways,
uint32 block_size_in_bytes,
uint32 addr_size_in_bits);
/**
* Return true and way if the byte with the given address is stored in the cache,
* otherwise, return false.
*
* Note that this method updates the LRU information.
*/
std::pair<bool, uint32> read( Addr addr);
/**
* Return true and way if the byte with the given address is stored in the cache,
* otherwise, return false.
*
* Note that this method does not update the LRU information.
*/
std::pair<bool, uint32> read_no_lru( Addr addr) const;
/**
* Mark that the block containing the byte with the given address
* is stored in the cache.
*
* Note: in order to put the given address inside the tags it is needed
* to select a way where it will be written in.
* This selection is being done according to LRU (Least Recently Used)
* policy.
*
* Returns # of updated way
*/
uint32 write( Addr addr);
};You are free to add as many additional methods and classes as you want, but you cannot change these interfaces.
MIPT-V / MIPT-MIPS — Cycle-accurate pre-silicon simulation.