Function to get the number of bytes in a burst

This commit is contained in:
Éder F. Zulian
2016-11-09 18:10:42 +01:00
parent 478ce8d79f
commit 803c2845c2
5 changed files with 15 additions and 8 deletions

View File

@@ -36,6 +36,8 @@
* Felipe S. Prado
*/
#include <cassert>
#include "Configuration.h"
#include "ConfigurationLoader.h"
#include "boost/lexical_cast.hpp"
@@ -240,7 +242,7 @@ unsigned int Configuration::getSimMemSizeInBytes()
unsigned int chipSize = chipBitSize / 8;
// 4. Total memory size in Bytes of one DIMM (with only support of 1 rank on a DIMM)
unsigned int memorySize = chipSize * NumberOfDevicesOnDIMM;
assert(memorySize > 0);
return memorySize;
}
@@ -254,3 +256,12 @@ unsigned int Configuration::getDataBusWidth()
return dataBusWidth;
}
// Returns the number of bytes in a burst
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);
return bytesPerBurst;
}

View File

@@ -102,6 +102,7 @@ struct Configuration
unsigned int getSimMemSizeInBytes();
unsigned int getDataBusWidth();
unsigned int getBytesPerBurst();
private:
Configuration();

View File

@@ -65,10 +65,7 @@ using namespace Data;
struct Dram : sc_module
{
unsigned int burstLength = Configuration::getInstance().memSpec.BurstLength;
unsigned int dataBusWidth = Configuration::getInstance().getDataBusWidth();
// 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 = (burstLength * dataBusWidth) / 8;
unsigned int bytesPerBurst = Configuration::getInstance().getBytesPerBurst();
// TLM Related:
tlm_utils::simple_target_socket<Dram> tSocket;

View File

@@ -46,8 +46,7 @@ StlPlayer::StlPlayer(sc_module_name, string pathToTrace, sc_time playerClk, Trac
this->playerClk = playerClk;
this->burstlength = Configuration::getInstance().memSpec.BurstLength;
this->bytesPerColumn = xmlAddressDecoder::getInstance().amount["bytes"];
this->dataLength = bytesPerColumn * burstlength;
this->dataLength = Configuration::getInstance().getBytesPerBurst();
this->lineCnt = 0;
}

View File

@@ -58,7 +58,6 @@ private:
unsigned int lineCnt;
unsigned int burstlength;
unsigned int bytesPerColumn;
unsigned int dataLength;
sc_time playerClk; // May be different from from the memory clock!
};