diff --git a/src/configuration/DRAMSys/config/AddressMapping.h b/src/configuration/DRAMSys/config/AddressMapping.h index cf97ae0d..6cef8ee9 100644 --- a/src/configuration/DRAMSys/config/AddressMapping.h +++ b/src/configuration/DRAMSys/config/AddressMapping.h @@ -59,37 +59,6 @@ struct AddressMapping std::optional> STACK_BIT; std::optional> PSEUDOCHANNEL_BIT; std::optional> CHANNEL_BIT; - - unsigned int getHighestBit() const { - unsigned int highestBit = std::numeric_limits::min(); - bool found = false; - - auto checkAndUpdate = [&](const std::optional>& bits) { - if (bits) { - for (const auto& vector : *bits) { - for (const auto& bit : vector) { - if (bit > highestBit) { - highestBit = bit; - found = true; - } - } - } - } - }; - - checkAndUpdate(BYTE_BIT); - checkAndUpdate(COLUMN_BIT); - checkAndUpdate(ROW_BIT); - checkAndUpdate(BANK_BIT); - checkAndUpdate(BANKGROUP_BIT); - checkAndUpdate(RANK_BIT); - checkAndUpdate(STACK_BIT); - checkAndUpdate(PSEUDOCHANNEL_BIT); - checkAndUpdate(CHANNEL_BIT); - - return found ? highestBit : std::numeric_limits::min(); // Rückgabe des höchsten Wertes oder des minimalen Wertes - } - }; NLOHMANN_JSONIFY_ALL_THINGS(AddressMapping, diff --git a/src/libdramsys/DRAMSys/simulation/AddressDecoder.cpp b/src/libdramsys/DRAMSys/simulation/AddressDecoder.cpp index 5f111be7..e9bc9928 100644 --- a/src/libdramsys/DRAMSys/simulation/AddressDecoder.cpp +++ b/src/libdramsys/DRAMSys/simulation/AddressDecoder.cpp @@ -111,8 +111,8 @@ uint64_t AddressDecoder::gf2Multiplication(const uint64_t& inputVec, const std:: /* AddressDecoder Functions */ /****************************/ -AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMapping) : - highestBitValue(addressMapping.getHighestBit()) +AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMapping) : + highestBitValue(getHighestBit(addressMapping)) { mappingMatrix = std::vector>(highestBitValue + 1); upperBoundAddress = std::pow(2, highestBitValue + 1) - 1; @@ -148,7 +148,6 @@ AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMap banksPerGroup = std::lround(std::pow(2, bankBits.length)); } - void AddressDecoder::plausibilityCheck(const MemSpec& memSpec) { (*this).memSpec = &memSpec; @@ -493,4 +492,44 @@ void AddressDecoder::print() const printBits(pseudochannelBits); printBits(channelBits); } + +unsigned int AddressDecoder::getHighestBit(Config::AddressMapping const& addressMapping) +{ + unsigned int highestBit = std::numeric_limits::min(); + bool found = false; + + auto checkAndUpdate = + [&](const std::optional>& bits) + { + if (bits) + { + for (const auto& vector : *bits) + { + for (const auto& bit : vector) + { + if (bit > highestBit) + { + highestBit = bit; + found = true; + } + } + } + } + }; + + checkAndUpdate(addressMapping.BYTE_BIT); + checkAndUpdate(addressMapping.COLUMN_BIT); + checkAndUpdate(addressMapping.ROW_BIT); + checkAndUpdate(addressMapping.BANK_BIT); + checkAndUpdate(addressMapping.BANKGROUP_BIT); + checkAndUpdate(addressMapping.RANK_BIT); + checkAndUpdate(addressMapping.STACK_BIT); + checkAndUpdate(addressMapping.PSEUDOCHANNEL_BIT); + checkAndUpdate(addressMapping.CHANNEL_BIT); + + return found ? highestBit + : std::numeric_limits::min(); // Rückgabe des höchsten Wertes oder + // des minimalen Wertes +} + } // namespace DRAMSys diff --git a/src/libdramsys/DRAMSys/simulation/AddressDecoder.h b/src/libdramsys/DRAMSys/simulation/AddressDecoder.h index 5ed9959c..9e964ae3 100644 --- a/src/libdramsys/DRAMSys/simulation/AddressDecoder.h +++ b/src/libdramsys/DRAMSys/simulation/AddressDecoder.h @@ -155,6 +155,8 @@ private: bool np2Flag = false; + static unsigned int getHighestBit(Config::AddressMapping const& addressMapping); + /** * @brief Transposes a matrix of 64-bit bitsets. *