refactor: move helper function into AddressDecoder
This commit is contained in:
@@ -59,37 +59,6 @@ struct AddressMapping
|
||||
std::optional<std::vector<BitEntry>> STACK_BIT;
|
||||
std::optional<std::vector<BitEntry>> PSEUDOCHANNEL_BIT;
|
||||
std::optional<std::vector<BitEntry>> CHANNEL_BIT;
|
||||
|
||||
unsigned int getHighestBit() const {
|
||||
unsigned int highestBit = std::numeric_limits<unsigned int>::min();
|
||||
bool found = false;
|
||||
|
||||
auto checkAndUpdate = [&](const std::optional<std::vector<BitEntry>>& 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<unsigned int>::min(); // Rückgabe des höchsten Wertes oder des minimalen Wertes
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
NLOHMANN_JSONIFY_ALL_THINGS(AddressMapping,
|
||||
|
||||
@@ -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<std::bitset<ADDRESS_WIDTH>>(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<unsigned int>::min();
|
||||
bool found = false;
|
||||
|
||||
auto checkAndUpdate =
|
||||
[&](const std::optional<std::vector<Config::AddressMapping::BitEntry>>& 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<unsigned int>::min(); // Rückgabe des höchsten Wertes oder
|
||||
// des minimalen Wertes
|
||||
}
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -155,6 +155,8 @@ private:
|
||||
|
||||
bool np2Flag = false;
|
||||
|
||||
static unsigned int getHighestBit(Config::AddressMapping const& addressMapping);
|
||||
|
||||
/**
|
||||
* @brief Transposes a matrix of 64-bit bitsets.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user