Compare commits

..

No commits in common. "correction" and "master" have entirely different histories.

1 changed files with 24 additions and 29 deletions

View File

@ -139,52 +139,47 @@ 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];
// 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 // loop through all Ages
for (int current_age = 0; current_age < 4; current_age++) { for (auto associativity_map : current_set.Associativity) {
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_age_blocklist) { for (auto block : current_associativity_blocklist) {
// look through ALL incoming_set.Blocklists for occurrences // look through ALL incoming_set.Associativities.Entry.Blocklists for
// occurrences
for (auto incoming_associativity : incoming_set.Associativity) { for (auto incoming_associativity : incoming_set.Associativity) {
int age = incoming_associativity.first; auto 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 != if (ret != entry.Blocks.end()) {
entry.Blocks.end()) { // if current block found amongst incoming
// compare the ages and take the maximum age // take the maximum age
new_age = std::max(current_age, age); auto new_age = std::max(current_associativity_age, age);
new_block_list.push_front((unsigned int)*ret); // 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));
} }
} }
// update the temporary
temp_set.Associativity[new_age].Blocks.merge(new_block_list);
Sets[Index] = temp_set;
} }
// print_block_list(associativity_age, associativity_block_list);
Sets[Index] = temp_set;
} }
// Here should be Sets[Index] = temp_set;
} }
} }