Fixed a bug in the XOR mapping

This commit is contained in:
Johannes Feldmann
2018-04-10 16:36:57 +02:00
parent 23648c6f60
commit 7a715d171f

View File

@@ -146,8 +146,11 @@ DecodedAddress JSONAddressDecoder::decodeAddress(sc_dt::uint64 addr)
// Get the bank bit and row bit. Apply a bitwise xor operator and save it back to the bank bit.
for(auto it = m_vXor.begin(); it != m_vXor.end(); it++)
{
unsigned new_bank_bit;
// Bank Row
new_bank_bit = (((addr >> it->first) & 1) ^ ((addr >> it->second) & 1));
addr &= ~(1 << it->first);
addr |= (((addr >> it->first) & 1) ^ ((addr >> it->second) & 1)) << it->first;
addr |= new_bank_bit << it->first;
}
// Unsed
@@ -234,8 +237,10 @@ sc_dt::uint64 JSONAddressDecoder::encodeAddress(DecodedAddress n)
// Get the bank bit and row bit. Apply a bitwise xor operator and save it back to the bank bit.
for(auto it = m_vXor.begin(); it != m_vXor.end(); it++)
{
address &= ~(1 << it->first);
address |= (((address >> it->first) & 1) ^ ((address >> it->second) & 1)) << it->first;
unsigned new_bank_bit;
new_bank_bit = (((address >> it->first) & 1) ^ ((address >> it->second) & 1));
address &= ~(1 << it->first);
address |= new_bank_bit << it->first;
}
return address;