Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some optimisation

  • Loading branch information...
commit 4a912608f460d80df97fa84099c131d07c700fcf 1 parent 4691547
@pksunkara authored
Showing with 2 additions and 23 deletions.
  1. +1 −14 Access.cpp
  2. +1 −8 Cache.cpp
  3. +0 −1  Cache.h
View
15 Access.cpp
@@ -34,20 +34,7 @@ void Access::write(int value) {
int Access::get(int addr) {
this->accesses++;
-
- //int misses = this->cache->get_misses();
- int word = this->cache->get_cached(addr);
- /*if(word==-1 && this->cache->get_misses()==misses+1) {
- Block* buf = this->memory->read(addr);
- this->cache->insert_block(addr, buf);
- //cout << " inserted" << endl;
- return buf->get_word_by_addr(addr);
- } else {
- //cout << " cached" << endl;
- return word;
- }*/
-
- return word;
+ return this->cache->get_cached(addr);
}
Access::~Access(void) {
View
9 Cache.cpp
@@ -96,7 +96,7 @@ int Cache::get_cached(int address) {
this->misses[0]++;
Block* cur_block = this->memory->read(address);
- this->insert_block(address, cur_block);
+ cur_set->insert_block(tag_num, cur_block);
if(cur_set->get_dirty()==false) {
this->misses[1]++;
cur_set->set_dirty();
@@ -107,13 +107,6 @@ int Cache::get_cached(int address) {
return cur_block->get_word(address % this->num_words);
}
-void Cache::insert_block(int address, Block* new_block) {
- int set_num = (this->set_mul & address)/pow(2, this->word_bits);
- int tag_num = (this->tag_mul & address)/pow(2, this->word_bits + this->set_bits);
-
- this->data[set_num]->insert_block(tag_num, new_block);
-}
-
Cache::~Cache(void) {
for(int i=0; i<this->num_sets; i++)
delete this->data[i];
View
1  Cache.h
@@ -34,7 +34,6 @@ class Cache {
int get_cached(int address);
void restart(void);
- void insert_block(int address, Block* new_block);
~Cache(void);
Please sign in to comment.
Something went wrong with that request. Please try again.