forked from nils.hoelscher/RTSA-lab01-CacheAnalysis
Compare commits
1 Commits
master
...
correction
Author | SHA1 | Date |
---|---|---|
Mukendi Mputu | e1b1f13797 |
|
@ -139,48 +139,53 @@ public: // everything is public, because IDGAF
|
||||||
// Loop through all 16 sets
|
// Loop through all 16 sets
|
||||||
for (int Index = 0; Index < 16; Index++) {
|
for (int Index = 0; Index < 16; Index++) {
|
||||||
|
|
||||||
// create a temporary set of associativity
|
|
||||||
struct Set temp_set;
|
|
||||||
struct Set current_set = Sets[Index];
|
struct Set current_set = Sets[Index];
|
||||||
struct Set incoming_set = In.Sets[Index];
|
struct Set incoming_set = In.Sets[Index];
|
||||||
|
|
||||||
// loop through all Ages
|
// create a temporary set of associativity
|
||||||
for (auto associativity_map : current_set.Associativity) {
|
struct Set temp_set;
|
||||||
|
temp_set.Associativity = {{(unsigned int)0, {{}}},
|
||||||
|
{(unsigned int)1, {{}}},
|
||||||
|
{(unsigned int)2, {{}}},
|
||||||
|
{(unsigned int)3, {{}}}};
|
||||||
|
|
||||||
|
int new_age = 0;
|
||||||
|
|
||||||
|
// loop through all Ages
|
||||||
|
for (int current_age = 0; current_age < 4; current_age++) {
|
||||||
|
|
||||||
|
std::list<unsigned int> new_block_list;
|
||||||
|
|
||||||
|
auto current_age_entry = current_set.Associativity[current_age];
|
||||||
|
std::list<unsigned int> current_age_blocklist =
|
||||||
|
current_age_entry.Blocks;
|
||||||
|
|
||||||
auto current_associativity_age = associativity_map.first;
|
|
||||||
std::list<unsigned int> current_associativity_blocklist =
|
|
||||||
associativity_map.second.Blocks;
|
|
||||||
// for every element of associativity_block_list
|
// for every element of associativity_block_list
|
||||||
for (auto block : current_associativity_blocklist) {
|
for (auto block : current_age_blocklist) {
|
||||||
// look through ALL incoming_set.Associativities.Entry.Blocklists for
|
// look through ALL incoming_set.Blocklists for occurrences
|
||||||
// occurrences
|
|
||||||
for (auto incoming_associativity : incoming_set.Associativity) {
|
for (auto incoming_associativity : incoming_set.Associativity) {
|
||||||
auto age = incoming_associativity.first;
|
int age = incoming_associativity.first;
|
||||||
struct Entry entry = incoming_associativity.second;
|
struct Entry entry = incoming_associativity.second;
|
||||||
|
|
||||||
auto ret =
|
auto ret =
|
||||||
std::find(entry.Blocks.begin(), entry.Blocks.end(), block);
|
std::find(entry.Blocks.begin(), entry.Blocks.end(), block);
|
||||||
if (ret != entry.Blocks.end()) {
|
if (ret !=
|
||||||
|
entry.Blocks.end()) { // if current block found amongst incoming
|
||||||
|
|
||||||
// take the maximum age
|
// compare the ages and take the maximum age
|
||||||
auto new_age = std::max(current_associativity_age, age);
|
new_age = std::max(current_age, age);
|
||||||
|
|
||||||
// create a new entry at the maximum age and
|
new_block_list.push_front((unsigned int)*ret);
|
||||||
std::list<unsigned int> new_block_list;
|
|
||||||
new_block_list.push_back((unsigned int) *ret);
|
|
||||||
struct Entry new_entry = {new_block_list};
|
|
||||||
|
|
||||||
// add it to temporary set
|
|
||||||
temp_set.Associativity.insert(
|
|
||||||
std::pair<unsigned int, struct Entry>(new_age, new_entry));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// update the temporary
|
||||||
// print_block_list(associativity_age, associativity_block_list);
|
temp_set.Associativity[new_age].Blocks.merge(new_block_list);
|
||||||
|
|
||||||
Sets[Index] = temp_set;
|
Sets[Index] = temp_set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Here should be Sets[Index] = temp_set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in New Issue