public MemorySystem(uint id, uint megsOfMemory, ref Stream dramsim_log_) { dramsim_log = dramsim_log_; ReturnReadData = null; WriteDataDone = null; currentClockCycle = 0; if (Config.DEBUG_MEMORY) { DEBUG.WriteLine("===== MemorySystem " + systemID + " ====="); } UInt64 megsOfStoragePerRank = ((((UInt64)Config.dram_config.NUM_ROWS * (Config.dram_config.NUM_COLS * Config.dram_config.DEVICE_WIDTH) * Config.dram_config.NUM_BANKS) * ((UInt64)Config.dram_config.JEDEC_DATA_BUS_BITS / Config.dram_config.DEVICE_WIDTH)) / 8) >> 20; // If this is set, effectively override the number of ranks if (megsOfMemory != 0) { Config.dram_config.NUM_RANKS = (uint)(megsOfMemory / megsOfStoragePerRank); Config.dram_config.NUM_RANKS_LOG = Config.dram_config.log2(Config.dram_config.NUM_RANKS); if (Config.dram_config.NUM_RANKS == 0) { if (Config.DEBUG_MEMORY) { DEBUG.WriteLine("WARNING: Cannot create memory system with " + megsOfMemory + "MB, defaulting to minimum size of " + megsOfStoragePerRank + "MB"); } Config.dram_config.NUM_RANKS = 1; } } Config.dram_config.NUM_DEVICES = Config.dram_config.JEDEC_DATA_BUS_BITS / Config.dram_config.DEVICE_WIDTH; Config.dram_config.TOTAL_STORAGE = (Config.dram_config.NUM_RANKS * megsOfStoragePerRank); if (Config.DEBUG_MEMORY) { DEBUG.WriteLine("CH. " + systemID + " TOTAL_STORAGE : " + Config.dram_config.TOTAL_STORAGE + "MB | " + Config.dram_config.NUM_RANKS + " Ranks | " + Config.dram_config.NUM_DEVICES + " Devices per rank"); } memoryController = new MemoryController(this, dramsim_log); // TODO: change to other vector constructor? ranks = new List <Rank>(); for (int i = 0; i < Config.dram_config.NUM_RANKS; i++) { Rank r = new Rank(dramsim_log); r.setId(i); r.attachMemoryController(memoryController); ranks.Add(r); } memoryController.attachRanks(ranks); }