diff --git a/DRAMSys/library/src/common/AddressDecoder.cpp b/DRAMSys/library/src/common/AddressDecoder.cpp index 6855b87f..e97ead26 100644 --- a/DRAMSys/library/src/common/AddressDecoder.cpp +++ b/DRAMSys/library/src/common/AddressDecoder.cpp @@ -106,8 +106,8 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) for (tinyxml2::XMLElement *pXor = pNode->FirstChildElement("XOR"); pXor != nullptr; pXor = pXor->NextSiblingElement("XOR")) { - vXor.push_back(XOR(getUnsignedAttrFromXMLNode(pXor, "BANK"), - getUnsignedAttrFromXMLNode(pXor, "ROW"))); + vXor.push_back(std::pair(getUnsignedAttrFromXMLNode(pXor, "FIRST"), + getUnsignedAttrFromXMLNode(pXor, "SECOND"))); } unsigned counter = 0; @@ -179,7 +179,8 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) bankgroupsPerRank = amount.bankgroup; amount.bankgroup = bankgroupsPerRank * amount.rank; - maximumAddress = amount.bytes * amount.column * amount.row * banksPerGroup * bankgroupsPerRank * amount.rank * amount.channel - 1; + maximumAddress = amount.bytes * amount.column * amount.row * + banksPerGroup * bankgroupsPerRank * amount.rank * amount.channel - 1; Configuration &config = Configuration::getInstance(); MemSpec *memSpec = config.memSpec; @@ -193,19 +194,19 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) DecodedAddress AddressDecoder::decodeAddress(uint64_t encAddr) { - if (encAddr > maximumAddress) - SC_REPORT_WARNING("AddressDecoder", ("Address " + std::to_string(encAddr) + " out of range (maximum address is " + std::to_string(maximumAddress) + ")").c_str()); +// if (encAddr > maximumAddress) +// SC_REPORT_WARNING("AddressDecoder", ("Address " + std::to_string(encAddr) + " out of range (maximum address is " + std::to_string(maximumAddress) + ")").c_str()); // Apply XOR // For each used xor: // Get the bank bit and row bit. Apply a bitwise xor operator and save it back to the bank bit. for (auto it = vXor.begin(); it != vXor.end(); it++) { - unsigned new_bank_bit; + unsigned xoredBit; // Bank Row - new_bank_bit = (((encAddr >> it->nBank) & 1) ^ ((encAddr >> it->nRow) & 1)); - encAddr &= ~(1 << it->nBank); - encAddr |= new_bank_bit << it->nBank; + xoredBit = (((encAddr >> it->first) & 1) ^ ((encAddr >> it->second) & 1)); + encAddr &= ~(1 << it->first); + encAddr |= xoredBit << it->first; } DecodedAddress decAddr; @@ -273,10 +274,10 @@ uint64_t AddressDecoder::encodeAddress(DecodedAddress decAddr) // Get the bank bit and row bit. Apply a bitwise xor operator and save it back to the bank bit. for (auto it = vXor.begin(); it != vXor.end(); it++) { - unsigned new_bank_bit; - new_bank_bit = (((encAddr >> it->nBank) & 1) ^ ((encAddr >> it->nRow) & 1)); - encAddr &= ~(1 << it->nBank); - encAddr |= new_bank_bit << it->nBank; + unsigned xoredBit; + xoredBit = (((encAddr >> it->first) & 1) ^ ((encAddr >> it->second) & 1)); + encAddr &= ~(1 << it->first); + encAddr |= xoredBit << it->first; } return encAddr; diff --git a/DRAMSys/library/src/common/AddressDecoder.h b/DRAMSys/library/src/common/AddressDecoder.h index e29d8dd6..1c0a6cf1 100644 --- a/DRAMSys/library/src/common/AddressDecoder.h +++ b/DRAMSys/library/src/common/AddressDecoder.h @@ -94,16 +94,8 @@ private: uint64_t maximumAddress; - struct XOR - { - unsigned nBank; - unsigned nRow; - XOR() {} - XOR(unsigned bank, unsigned row) : nBank(bank), nRow(row) {} - }; - // This container stores for each used xor gate a pair which consists of "First/Number of an address bit which corresponds to a bank" and "Second/Number of an address bit which corresponds to a row" - std::vector vXor; + std::vector> vXor; std::vector> vChannelBits; std::vector> vRankBits; std::vector> vBankGroupBits;