Fix hardcoded memory size (issue #128)

Recalculate memory size using #Banks, #Rows, and #Columns from memory specs.
This commit is contained in:
Thanh Tran
2016-11-07 17:25:59 +01:00
parent 561a688b0f
commit c28c996271

View File

@@ -94,8 +94,11 @@ struct Dram : sc_module
SC_CTOR(Dram) : tSocket("socket")
{
// FIXME: memory size
unsigned int size = 1024 * 1024 * 1024;
// calculate memory size
unsigned int banks = Configuration::getInstance().memSpec.NumberOfBanks;
unsigned int rows = Configuration::getInstance().memSpec.NumberOfRows;
unsigned int columns = Configuration::getInstance().memSpec.NumberOfColumns;
unsigned int size = banks * rows * columns;
memory = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, -1, 0);
tSocket.register_nb_transport_fw(this, &Dram::nb_transport_fw);