Compare commits

..

1 Commits

Author SHA1 Message Date
Mukendi Mputu e1b1f13797 I did it!!! 😃 2022-06-02 21:08:36 +02:00
1 changed files with 30 additions and 25 deletions

View File

@ -139,48 +139,53 @@ public: // everything is public, because IDGAF
// Loop through all 16 sets
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 incoming_set = In.Sets[Index];
// loop through all Ages
for (auto associativity_map : current_set.Associativity) {
// create a temporary set of 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 (auto block : current_associativity_blocklist) {
// look through ALL incoming_set.Associativities.Entry.Blocklists for
// occurrences
for (auto block : current_age_blocklist) {
// look through ALL incoming_set.Blocklists for occurrences
for (auto incoming_associativity : incoming_set.Associativity) {
auto age = incoming_associativity.first;
int age = incoming_associativity.first;
struct Entry entry = incoming_associativity.second;
auto ret =
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
auto new_age = std::max(current_associativity_age, age);
// compare the ages and take the maximum age
new_age = std::max(current_age, age);
// create a new entry at the maximum age and
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));
new_block_list.push_front((unsigned int)*ret);
}
}
}
// print_block_list(associativity_age, associativity_block_list);
// update the temporary
temp_set.Associativity[new_age].Blocks.merge(new_block_list);
Sets[Index] = temp_set;
}
}
// Here should be Sets[Index] = temp_set;
}
}
/**