diff --git a/DRAMSys/library/src/common/AddressDecoder.cpp b/DRAMSys/library/src/common/AddressDecoder.cpp index d54352a4..6855b87f 100644 --- a/DRAMSys/library/src/common/AddressDecoder.cpp +++ b/DRAMSys/library/src/common/AddressDecoder.cpp @@ -43,7 +43,7 @@ tinyxml2::XMLElement *AddressDecoder::getXMLNode(tinyxml2::XMLElement { tinyxml2::XMLElement *pNode = pRoot->FirstChildElement(strName.c_str()); if (pNode == nullptr) { - reportFatal("ConGenAddressDecorder", + reportFatal("AddressDecorder", "XML File corrupted. Missing node " + strName + "."); } return pNode; @@ -56,7 +56,7 @@ unsigned int AddressDecoder::getUnsignedTextFromXMLNode( if (str.empty() || std::find_if(str.begin(), str.end(), [](char c) { return !std::isdigit(c); }) != str.end()) { - reportFatal("ConGenAddressDecoder", + reportFatal("AddressDecoder", "Node " + std::string(pRoot->Name()) + " is empty or not a number."); return (unsigned)(-1); } @@ -70,7 +70,7 @@ unsigned int AddressDecoder::getUnsignedAttrFromXMLNode( if (str.empty() || std::find_if(str.begin(), str.end(), [](char c) { return !std::isdigit(c); }) != str.end()) { - reportFatal("ConGenAddressDecoder", + reportFatal("AddressDecoder", "Attribute " + strName + " is empty or not a number."); return (unsigned)(-1); } @@ -85,7 +85,7 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) std::string xmlNodeName(pRoot->Name()); if (xmlNodeName != "CONGEN") - reportFatal("ConGenAddressDecorder", + reportFatal("AddressDecorder", "Root node name differs from \"CONGEN\". File format not supported."); // Load address mapping @@ -95,12 +95,11 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) pNode = pNode->NextSiblingElement("SOLUTION")) { if (getUnsignedAttrFromXMLNode(pNode, "ID") == 0) - break; // Correct mapping was found. + break; } - // If no mapping was found report error if (pNode == nullptr) - SC_REPORT_FATAL("ConGenAddressDecoder", "No mapping with ID 0 was found."); + SC_REPORT_FATAL("AddressDecoder", "No mapping with ID 0 was found."); // get XOR connections // An XOR connection needs two parameters: A bank bit and a Row bit. @@ -135,8 +134,6 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) vBankGroupBits.push_back(std::pair(counter++, nBankGroup)); } - // get all bank bits - // Each bank bit of the address will be stored with a counter value which assigns the bit position DecodedAddress struct. counter = 0; for (tinyxml2::XMLElement *pBank = pNode->FirstChildElement("BANK_BIT"); pBank != nullptr; pBank = pBank->NextSiblingElement("BANK_BIT")) @@ -145,8 +142,6 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) vBankBits.push_back(std::pair(counter++, nBank)); } - // get all row bits bits - // Each Row bit of the address will be stored with a counter value which assigns the bit position DecodedAddress struct. counter = 0; for (tinyxml2::XMLElement *pRow = pNode->FirstChildElement("ROW_BIT"); pRow != nullptr; pRow = pRow->NextSiblingElement("ROW_BIT")) { @@ -170,7 +165,6 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) vByteBits.push_back(std::pair(counter++, nByte)); } - // Fill the amount map. This is copied from xmlAddressDecoder without further investigation amount.channel = pow(2.0, vChannelBits.size()); amount.rank = pow(2.0, vRankBits.size()); amount.bankgroup = pow(2.0, vBankGroupBits.size()); @@ -194,13 +188,13 @@ AddressDecoder::AddressDecoder(std::string pathToAddressMapping) || memSpec->numberOfBankGroups != amount.bankgroup || memSpec->numberOfBanks != amount.bank || memSpec->numberOfRows != amount.row || memSpec->numberOfColumns != amount.column || config.numberOfDevicesOnDIMM * memSpec->bitWidth != amount.bytes * 8) - SC_REPORT_FATAL("CongenAddressDecoder", "Memspec and addressmapping do not match"); + SC_REPORT_FATAL("AddressDecoder", "Memspec and address mapping do not match"); } DecodedAddress AddressDecoder::decodeAddress(uint64_t encAddr) { -// if (encAddr > maximumAddress) -// SC_REPORT_WARNING("CongenAddressDecoder", ("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: @@ -228,29 +222,14 @@ DecodedAddress AddressDecoder::decodeAddress(uint64_t encAddr) for (auto it = vBankGroupBits.begin(); it != vBankGroupBits.end(); it++) decAddr.bankgroup |= ((encAddr >> it->second) & 1) << it->first; - // Bank - // it->second: position of the target bit in the address - // it->first: target position of the bit in the variable - // For each bank bit: - // shift address bit to position 0. Clear all other bits. shift it the right bank bit. Add it to the set of bank bits. decAddr.bank = 0; for (auto it = vBankBits.begin(); it != vBankBits.end(); it++) decAddr.bank |= ((encAddr >> it->second) & 1) << it->first; - // Row - // it->second: position of the target bit in the address - // it->first: target position of the bit in the variable - // For each row bit: - // shift address bit to position 0. Clear all other bits. shift it the right row bit. Add it to the set of row bits. decAddr.row = 0; for (auto it = vRowBits.begin(); it != vRowBits.end(); it++) decAddr.row |= ((encAddr >> it->second) & 1) << it->first; - // Column - // it->second: position of the target bit in the address - // it->first: target position of the bit in the variable - // For each column bit: - // shift address bit to position 0. Clear all other bits. shift it the right column bit. Add it to the set of column bits. decAddr.column = 0; for (auto it = vColumnBits.begin(); it != vColumnBits.end(); it++) decAddr.column |= ((encAddr >> it->second) & 1) << it->first; @@ -277,27 +256,12 @@ uint64_t AddressDecoder::encodeAddress(DecodedAddress decAddr) for (auto it = vBankGroupBits.begin(); it != vBankGroupBits.end(); it++) encAddr |= ((decAddr.bankgroup >> it->first) & 1) << it->second; - // Bank - // it->first: position of the target bit in the DecodedAddress struct field - // it->second: target position of the bit in the address - // For each bank bit: - // shift bank bit to position 0. Clear all other bits. shift it the right address bit. Add it to the set of address bits. for (auto it = vBankBits.begin(); it != vBankBits.end(); it++) encAddr |= ((decAddr.bank >> it->first) & 1) << it->second; - // Row - // it->first: position of the target bit in the DecodedAddress struct field - // it->second: target position of the bit in the address - // For each row bit: - // shift row bit to position 0. Clear all other bits. shift it the right address bit. Add it to the set of address bits. for (auto it = vRowBits.begin(); it != vRowBits.end(); it++) encAddr |= ((decAddr.row >> it->first) & 1) << it->second; - // Column - // it->first: position of the target bit in the DecodedAddress struct field - // it->second: target position of the bit in the address - // For each column bit: - // shift column bit to position 0. Clear all other bits. shift it the right address bit. Add it to the set of address bits. for (auto it = vColumnBits.begin(); it != vColumnBits.end(); it++) encAddr |= ((decAddr.column >> it->first) & 1) << it->second; diff --git a/DRAMSys/library/src/simulation/Arbiter.cpp b/DRAMSys/library/src/simulation/Arbiter.cpp index d13737ab..73810df7 100644 --- a/DRAMSys/library/src/simulation/Arbiter.cpp +++ b/DRAMSys/library/src/simulation/Arbiter.cpp @@ -217,33 +217,10 @@ void Arbiter::appendDramExtension(int socketId, tlm_generic_payload &payload) unsigned int burstlength = payload.get_streaming_width(); DecodedAddress decodedAddress = addressDecoder->decodeAddress(payload.get_address()); - // Check the valid range of decodedAddress - if (addressIsValid(decodedAddress)) { - DramExtension *extension = new DramExtension(Thread(socketId), - Channel(decodedAddress.channel), Rank(decodedAddress.rank), - BankGroup(decodedAddress.bankgroup), Bank(decodedAddress.bank), - Row(decodedAddress.row), Column(decodedAddress.column), - burstlength, nextPayloadID[decodedAddress.channel]++); - payload.set_auto_extension(extension); - } else { - SC_REPORT_FATAL("Arbiter", "Decoded Address is not inside the valid range"); - } -} - -//TODO: this part should be checked inside the address decoder! -bool Arbiter::addressIsValid(DecodedAddress &decodedAddress) -{ - if (decodedAddress.channel >= addressDecoder->amount.channel) - return false; - if (decodedAddress.rank >= addressDecoder->amount.rank) - return false; - if (decodedAddress.bankgroup >= addressDecoder->amount.bankgroup) - return false; - if (decodedAddress.bank >= addressDecoder->amount.bank) - return false; - if (decodedAddress.row >= addressDecoder->amount.row) - return false; - if (decodedAddress.column >= addressDecoder->amount.column) - return false; - return true; + DramExtension *extension = new DramExtension(Thread(socketId), + Channel(decodedAddress.channel), Rank(decodedAddress.rank), + BankGroup(decodedAddress.bankgroup), Bank(decodedAddress.bank), + Row(decodedAddress.row), Column(decodedAddress.column), + burstlength, nextPayloadID[decodedAddress.channel]++); + payload.set_auto_extension(extension); } diff --git a/DRAMSys/library/src/simulation/Arbiter.h b/DRAMSys/library/src/simulation/Arbiter.h index 4a129b46..2e0ab39d 100644 --- a/DRAMSys/library/src/simulation/Arbiter.h +++ b/DRAMSys/library/src/simulation/Arbiter.h @@ -95,8 +95,6 @@ private: void appendDramExtension(int socketId, tlm::tlm_generic_payload &payload); std::vector nextPayloadID; - - bool addressIsValid(DecodedAddress &decodedAddress); }; #endif // ARBITER_H