Generalized XOR from bank and row to first and second.
This commit is contained in:
@@ -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<unsigned, unsigned>(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;
|
||||
|
||||
@@ -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<XOR> vXor;
|
||||
std::vector<std::pair<unsigned, unsigned>> vXor;
|
||||
std::vector<std::pair<unsigned, unsigned>> vChannelBits;
|
||||
std::vector<std::pair<unsigned, unsigned>> vRankBits;
|
||||
std::vector<std::pair<unsigned, unsigned>> vBankGroupBits;
|
||||
|
||||
Reference in New Issue
Block a user