Assertions added.

For memory modules:
- The least significant bits of the physical address are the byte offset of
  the N-byte-wide memory module.
- A single data word has N bytes.
- N = 2^(# bits for byte offset).

Assert that the number of bytes per burst match the burst length times the
data word size in bytes.
This commit is contained in:
Éder F. Zulian
2016-11-09 19:19:09 +01:00
parent 803c2845c2
commit dddac71f49

View File

@@ -253,6 +253,7 @@ unsigned int Configuration::getSimMemSizeInBytes()
unsigned int Configuration::getDataBusWidth()
{
unsigned int dataBusWidth = memSpec.bitWidth * NumberOfDevicesOnDIMM;
assert(dataBusWidth > 0);
return dataBusWidth;
}
@@ -262,6 +263,15 @@ unsigned int Configuration::getBytesPerBurst()
// First multiply to get the number of bits in a burst, then divide by 8 to get the value in bytes. The order is important. Think on a single x4 device.
unsigned int bytesPerBurst = (memSpec.BurstLength * getDataBusWidth()) / 8;
assert(bytesPerBurst > 0);
if (NumberOfDevicesOnDIMM > 1) {
// The least significant bits of the physical address are the byte
// offset of the N-byte-wide memory module (a single data word has N
// bytes. N = 2^(# bits for byte offset)).
unsigned int dataWordSizeInBytes = xmlAddressDecoder::getInstance().amount["bytes"];
assert(bytesPerBurst == (dataWordSizeInBytes * memSpec.BurstLength));
}
return bytesPerBurst;
}