37 lines
642 B
C++
37 lines
642 B
C++
#include "block.h"
|
|
using CacheSim::Block;
|
|
|
|
Block::Block(short tagSize) {
|
|
this->valid = false;
|
|
this->tag.assign(tagSize, 0);
|
|
this->tagSize = tagSize;
|
|
this->recentlyAccess = 0;
|
|
}
|
|
|
|
bool Block::getValid(){
|
|
return this->valid;
|
|
}
|
|
|
|
vector<bool> Block::getTag(){
|
|
return this->tag;
|
|
}
|
|
|
|
void Block::update(vector<bool> tag){
|
|
this->valid = true;
|
|
this->tag.clear();
|
|
this->tag.assign(tag.begin(), tag.end());
|
|
}
|
|
|
|
void Block::countAccess(){
|
|
if(this->valid){
|
|
this->recentlyAccess++;
|
|
}
|
|
}
|
|
|
|
void Block::access(){
|
|
this->recentlyAccess = 0;
|
|
}
|
|
|
|
short Block::getAccessTime(){
|
|
return this->recentlyAccess;
|
|
} |