Otawa
0.10
|
This
class contains the configuration of a level of cache of processor.
More...
#include <otawa/hard/Cache.h>
Classes | |
struct | info_t |
Public Types | |
enum | replace_policy_t { NONE = 0, OTHER = 1, LRU = 2, RANDOM = 3, FIFO = 4, PLRU = 5 } |
enum | write_policy_t { WRITE_THROUGH = 0, WRITE_BACK = 1 } |
typedef enum otawa::hard::Cache::replace_policy_t | replace_policy_t |
typedef enum otawa::hard::Cache::write_policy_t | write_policity_t |
typedef struct otawa::hard::Cache::info_t | info_t |
typedef t::uint32 | block_t |
typedef t::uint32 | set_t |
typedef t::uint32 | tag_t |
typedef t::uint32 | offset_t |
Public Member Functions | |
Cache (void) | |
Cache (const Cache &cache, const Cache *next=0) | |
Build a cache by cloning an existing cache and setting it in new cache configuration. More... | |
virtual | ~Cache (void) |
const Cache * | nextLevel (void) const |
Get the next level of cache. More... | |
ot::size | cacheSize (void) const |
Get the cache size. More... | |
ot::size | blockSize (void) const |
Get the block size. More... | |
int | wayCount (void) const |
Get the count of ways for associatives caches. More... | |
int | setCount (void) const |
int | blockCount (void) const |
replace_policy_t | replacementPolicy (void) const |
Get the replacement policy. More... | |
write_policy_t | writePolicy (void) const |
Get the write policy. More... | |
bool | doesWriteAllocate (void) const |
Set the behaviour about write allocation. More... | |
int | missPenalty (void) const |
Return the time penaly of a missed access to memory. More... | |
int | writeBufferSize (void) const |
Get the write buffer size of this cache (0 for no write buffer). More... | |
int | readPortSize (void) const |
Get the read port size of this cache (default to 1, must be non-null). More... | |
int | writePortSize (void) const |
Get the write port size of this cache (default to 1 for data cache). More... | |
int | blockBits (void) const |
Required bits count for a byte address in the block. More... | |
int | setBits (void) const |
int | tagBits (void) const |
Required bits count in the tag part of the address. More... | |
int | wayBits (void) const |
Get the number of bits to count the ways in set associative cache. More... | |
ot::mask | blockMask (void) const |
Mask for selecting the address of a byte in a block in a memory address. More... | |
ot::mask | setMask (void) const |
ot::mask | tagMask (void) const |
Mask for selecting the tag in a memory address. More... | |
offset_t | offset (Address addr) const |
Compute the offset of the accessed byte in the block from the memory address. More... | |
set_t | set (Address addr) const |
tag_t | tag (Address addr) const |
Compute the tag from the memory address. More... | |
block_t | block (Address addr) const |
Return the bits used for identifying uniquely a block, that is, tag and line number. More... | |
Address | round (Address addr) const |
Round the given address to the address of the container cache block. More... | |
void | setAccessTime (int access_time) |
Set the access time. More... | |
void | setMissPenalty (int miss_penalty) |
Set the miss penaly time. More... | |
void | setBlockBits (int block_bits) |
void | setRowBits (int set_bits) |
Set the row count as a number of bits. More... | |
void | setWayBits (int way_bits) |
Set the way count as a number of bits. More... | |
void | setReplacePolicy (replace_policy_t replace) |
Set the replace policy of the cache. More... | |
void | setWritePolicy (write_policy_t write) |
Set the write policy of the cache. More... | |
void | setAllocate (bool allocate) |
Set the allocation state. More... | |
void | setWriteBufferSize (int write_buffer_size) |
Set the write buffer size (0 for no write buffer). More... | |
void | setReadPortSize (int read_port_size) |
Set the read port size (at least 1). More... | |
void | setWritePortSize (int write_port_size) |
Set the write port size (at least 1). More... | |
int | rowBits (void) const |
Required bits count for a row index. More... | |
ot::mask | lineMask (void) const |
Mask for selecting the line number in a memory address. More... | |
ot::mask | rowMask (void) const |
ot::mask | line (const Address &addr) const |
Compute the line number from the memory address. More... | |
int | rowCount (void) const |
Get the count of rows. More... | |
Private Member Functions | |
SERIALIZABLE (Cache, field("access_time", _info.access_time, 1)&field("miss_penalty", _info.miss_penalty, 10)&field("block_bits", _info.block_bits, 4)&field("row_bits", _info.row_bits, 12)&field("way_bits", _info.way_bits, 0)&field("allocate", _info.allocate, false)&field("next", _next,(const Cache *) 0)&field("replace", _info.replace, LRU)&field("write_buffer_size", _info.write_buffer_size, 0)&field("read_port_size", _info.read_port_size, 1)&field("write_port_size", _info.write_port_size, 1)&field("write", _info.write, WRITE_THROUGH)) | |
Private Attributes | |
info_t | _info |
const Cache * | _next |
This
class contains the configuration of a level of cache of processor.
It
may represents direct-mapped or associative cache (with any associatvity level) using bits as block/line boundaries. Supported management policies (when they apply) are only LRU, FIFO, RANDOM and PLRU. Once
built, a cache object is viewed as a read-only database.
typedef t::uint32 otawa::hard::Cache::block_t |
typedef struct otawa::hard::Cache::info_t otawa::hard::Cache::info_t |
typedef t::uint32 otawa::hard::Cache::set_t |
typedef t::uint32 otawa::hard::Cache::tag_t |
otawa::hard::Cache::Cache | ( | void | ) |
Build a cache by cloning an existing cache and setting it in new cache configuration.
next | Next level of cache (null if there is no more cache). |
|
virtual |
|
inline |
Return the bits used for identifying uniquely a block, that is, tag and line number.
addr | Address to take block from. |
References blockBits(), and otawa::Address::offset().
Referenced by otawa::ccg::LBlockBuilder::addLBlock(), otawa::LBlockBuilder::addLBlock(), otawa::dcache::CLPBlockBuilder::processBB(), and otawa::ccg::Builder::processLBlockSet().
|
inline |
Required bits count for a byte address in the block.
References _info, and otawa::hard::Cache::info_t::block_bits.
Referenced by block(), blockSize(), cacheSize(), line(), lineMask(), otawa::ipet::TrivialInstCacheManager::processBB(), otawa::ccg::LBlockBuilder::processBB(), otawa::LBlockBuilder::processBB(), otawa::cat::CATBuilder::processLBlockSet(), otawa::ccg::ConstraintBuilder::processLBlockSet(), rowMask(), set(), setMask(), tag(), and tagBits().
|
inline |
References _info, otawa::hard::Cache::info_t::row_bits, and otawa::hard::Cache::info_t::way_bits.
|
inline |
Mask for selecting the address of a byte in a block in a memory address.
References blockSize().
Referenced by otawa::ccg::LBlockBuilder::addLBlock(), otawa::LBlockBuilder::addLBlock(), offset(), otawa::ccg::LBlockBuilder::processBB(), otawa::LBlockBuilder::processBB(), otawa::dcache::BlockBuilder::processBB(), and tagMask().
|
inline |
Get the block size.
References blockBits().
Referenced by blockMask(), otawa::ets::ACSComputation::initialization(), otawa::ParExeGraph::ParExeGraph(), otawa::dcache::CLPBlockBuilder::processBB(), and round().
|
inline |
Get the cache size.
References blockBits(), rowBits(), and wayBits().
Referenced by otawa::dcache::BlockBuilder::processBB().
|
inline |
Set the behaviour about write allocation.
References _info, and otawa::hard::Cache::info_t::allocate.
|
inline |
Compute the line number from the memory address.
addr | Memory address to compute from. |
References blockBits(), lineMask(), and otawa::Address::offset().
Referenced by otawa::sim::AbstractCacheDriver::access(), otawa::ets::ACSComputation::initialization(), otawa::dcache::BlockBuilder::processBB(), and otawa::FirstLastBuilder::processCFG().
|
inline |
Mask for selecting the line number in a memory address.
References blockBits(), and rowCount().
|
inline |
Return the time penaly of a missed access to memory.
References _info, and otawa::hard::Cache::info_t::miss_penalty.
Referenced by otawa::ipet::TrivialDataCacheManager::configure(), otawa::ipet::TrivialInstCacheManager::processBB(), otawa::cat::CATConstraintBuilder::processLBlockSet(), otawa::ccg::ConstraintBuilder::processLBlockSet(), otawa::EdgeCAT2ConstraintBuilder::processWorkSpace(), and otawa::CAT2ConstraintBuilder::processWorkSpace().
|
inline |
Get the next level of cache.
References _next.
Referenced by otawa::hard::CacheConfiguration::cacheName().
|
inline |
Compute the offset of the accessed byte in the block from the memory address.
addr | Memory address to compute from. |
References blockMask(), and otawa::Address::offset().
Referenced by otawa::ipet::TrivialInstCacheManager::processBB(), and otawa::dcache::CLPBlockBuilder::processBB().
|
inline |
Get the read port size of this cache (default to 1, must be non-null).
References _info, and otawa::hard::Cache::info_t::read_port_size.
|
inline |
Get the replacement policy.
References _info, and otawa::hard::Cache::info_t::replace.
Referenced by otawa::sim::AbstractCacheDriver::lookup(), otawa::dcache::CLPBlockBuilder::setup(), and otawa::dcache::BlockBuilder::setup().
Round the given address to the address of the container cache block.
addr | Address to round. |
References blockSize(), otawa::Address::isNull(), otawa::Address::offset(), and otawa::Address::page().
Referenced by otawa::ccg::LBlockBuilder::addLBlock(), otawa::LBlockBuilder::addLBlock(), and otawa::dcache::CLPBlockBuilder::processBB().
|
inline |
Required bits count for a row index.
References _info, and otawa::hard::Cache::info_t::row_bits.
Referenced by cacheSize(), rowCount(), setCount(), tag(), and tagBits().
|
inline |
Get the count of rows.
References rowBits().
Referenced by otawa::ccg::LBlockBuilder::cleanup(), otawa::LBlockBuilder::cleanup(), otawa::sim::FIFOCacheDriver::FIFOCacheDriver(), lineMask(), otawa::dcache::CLPBlockBuilder::processBB(), otawa::CAT2Builder::processCFG(), otawa::EdgeCAT2Builder::processCFG(), otawa::FirstLastBuilder::processCFG(), otawa::ccg::Builder::processLBlockSet(), otawa::LBlockProcessor::processWorkSpace(), otawa::EdgeCAT2ConstraintBuilder::processWorkSpace(), otawa::CAT2OnlyConstraintBuilder::processWorkSpace(), otawa::dcache::CATBuilder::processWorkSpace(), otawa::ACSMayBuilder::processWorkSpace(), otawa::LinkedBlocksDetector::processWorkSpace(), otawa::ets::ACSComputation::processWorkSpace(), otawa::ACSBuilder::processWorkSpace(), otawa::cat::CATConstraintBuilder::processWorkSpace(), otawa::cat::CATBuilder::processWorkSpace(), otawa::CAT2ConstraintBuilder::processWorkSpace(), otawa::ccg::ConstraintBuilder::processWorkSpace(), otawa::EdgeACSBuilder::processWorkSpace(), otawa::ccg::Builder::processWorkSpace(), otawa::dcache::ACSMayBuilder::processWorkSpace(), otawa::dcache::ACSBuilder::processWorkSpace(), rowMask(), setMask(), otawa::dcache::CLPBlockBuilder::setup(), otawa::LBlockBuilder::setup(), otawa::ccg::LBlockBuilder::setup(), and otawa::dcache::BlockBuilder::setup().
|
inline |
References blockBits(), and rowCount().
|
private |
References blockBits(), lineMask(), and otawa::Address::offset().
Referenced by otawa::ccg::LBlockBuilder::addLBlock(), otawa::LBlockBuilder::addLBlock(), otawa::dcache::BlockAccess::inSet(), otawa::LBlockBuilder::processBB(), otawa::ccg::LBlockBuilder::processBB(), and otawa::dcache::CLPBlockBuilder::processBB().
void otawa::hard::Cache::setAccessTime | ( | int | access_time | ) |
Set the access time.
access_time | Access time in processor cycles. |
References _info, and otawa::hard::Cache::info_t::access_time.
void otawa::hard::Cache::setAllocate | ( | bool | allocate | ) |
Set the allocation state.
If true, the write operation also allocate a block. If false, no allocation arise.
allocate | Allocate state. |
References _info, and otawa::hard::Cache::info_t::allocate.
|
inline |
References _info, and otawa::hard::Cache::info_t::row_bits.
void otawa::hard::Cache::setBlockBits | ( | int | block_bits | ) |
References _info, and otawa::hard::Cache::info_t::block_bits.
|
inline |
References rowBits().
Referenced by otawa::dcache::BlockAccess::inSet().
|
inline |
References blockBits(), and rowCount().
void otawa::hard::Cache::setMissPenalty | ( | int | miss_penalty | ) |
Set the miss penaly time.
miss_penaly | Miss penalty time in processor cycles. |
References _info, and otawa::hard::Cache::info_t::miss_penalty.
void otawa::hard::Cache::setReadPortSize | ( | int | read_port_size | ) |
Set the read port size (at least 1).
read_port_size | Read port size. |
References _info, and otawa::hard::Cache::info_t::read_port_size.
void otawa::hard::Cache::setReplacePolicy | ( | replace_policy_t | replace | ) |
Set the replace policy of the cache.
replace | Replace policy, one of OTHER, LRU, RANDOM, FIFO, PLRU. |
References _info, OTHER, PLRU, and otawa::hard::Cache::info_t::replace.
void otawa::hard::Cache::setRowBits | ( | int | row_bits | ) |
Set the row count as a number of bits.
The actual row count is 1 << row_bits.
row_bits | Row count in bits. |
References _info, and otawa::hard::Cache::info_t::row_bits.
void otawa::hard::Cache::setWayBits | ( | int | way_bits | ) |
Set the way count as a number of bits.
The actual way count is 1 << way_bits.
way_bits | Way count in bits. |
References _info, and otawa::hard::Cache::info_t::way_bits.
void otawa::hard::Cache::setWriteBufferSize | ( | int | write_buffer_size | ) |
Set the write buffer size (0 for no write buffer).
write_buffer_size | Write buffer size. |
References _info, and otawa::hard::Cache::info_t::write_buffer_size.
void otawa::hard::Cache::setWritePolicy | ( | write_policy_t | write | ) |
Set the write policy of the cache.
write | Write policy, one of WRITE_THROUGH or WRITE_BACK. |
References _info, otawa::hard::Cache::info_t::write, WRITE_BACK, and WRITE_THROUGH.
void otawa::hard::Cache::setWritePortSize | ( | int | write_port_size | ) |
Set the write port size (at least 1).
read_write_size | Write port size. |
References _info, and otawa::hard::Cache::info_t::write_port_size.
|
inline |
Compute the tag from the memory address.
addr | Memory address to compute from. |
References blockBits(), otawa::Address::offset(), and rowBits().
Referenced by otawa::sim::AbstractCacheDriver::access(), and otawa::dcache::BlockAccess::inSet().
|
inline |
Required bits count in the tag part of the address.
References blockBits(), and rowBits().
|
inline |
Mask for selecting the tag in a memory address.
References blockMask(), and lineMask().
|
inline |
Get the number of bits to count the ways in set associative cache.
This value is 1 for direct-mapped cache.
References _info, and otawa::hard::Cache::info_t::way_bits.
Referenced by cacheSize(), and wayCount().
|
inline |
Get the count of ways for associatives caches.
References wayBits().
Referenced by otawa::sim::AbstractCacheDriver::access(), otawa::sim::DirectMappedCacheDriver::DirectMappedCacheDriver(), otawa::sim::AbstractCacheDriver::lookup(), otawa::ets::ACSComputation::processAST(), otawa::dcache::ACSMayBuilder::processLBlockSet(), and otawa::sim::FIFOCacheDriver::replace().
|
inline |
Get the write buffer size of this cache (0 for no write buffer).
References _info, and otawa::hard::Cache::info_t::write_buffer_size.
|
inline |
|
inline |
Get the write port size of this cache (default to 1 for data cache).
References _info, and otawa::hard::Cache::info_t::write_port_size.
|
private |
Referenced by blockBits(), blockCount(), doesWriteAllocate(), missPenalty(), readPortSize(), replacementPolicy(), rowBits(), setAccessTime(), setAllocate(), setBits(), setBlockBits(), setMissPenalty(), setReadPortSize(), setReplacePolicy(), setRowBits(), setWayBits(), setWriteBufferSize(), setWritePolicy(), setWritePortSize(), wayBits(), writeBufferSize(), writePolicy(), and writePortSize().
|
private |
Referenced by nextLevel().