config: Expose the DRAM ranks as a command-line option
authorAndreas Hansson <andreas.hansson@arm.com>
Tue, 23 Dec 2014 14:31:18 +0000 (09:31 -0500)
committerAndreas Hansson <andreas.hansson@arm.com>
Tue, 23 Dec 2014 14:31:18 +0000 (09:31 -0500)
This patch gives the user direct influence over the number of DRAM
ranks to make it easier to tune the memory density without affecting
the bandwidth (previously the only means of scaling the device count
was through the number of channels).

The patch also adds some basic sanity checks to ensure that the number
of ranks is a power of two (since we rely on bit slices in the address
decoding).

configs/common/MemConfig.py
configs/common/Options.py
src/mem/dram_ctrl.cc

index 57066426f3b05b5e3c9aa101f7ecb50cb0011b99..4692c2d0e361bbcca06653b356bd7173fb4863a0 100644 (file)
@@ -197,9 +197,15 @@ def config_mem(options, system):
     # address mapping in the case of a DRAM
     for r in system.mem_ranges:
         for i in xrange(nbr_mem_ctrls):
-            mem_ctrls.append(create_mem_ctrl(cls, r, i, nbr_mem_ctrls,
-                                             intlv_bits,
-                                             system.cache_line_size.value))
+            mem_ctrl = create_mem_ctrl(cls, r, i, nbr_mem_ctrls, intlv_bits,
+                                       system.cache_line_size.value)
+            # Set the number of ranks based on the command-line
+            # options if it was explicitly set
+            if issubclass(cls, m5.objects.DRAMCtrl) and \
+                    options.mem_ranks:
+                mem_ctrl.ranks_per_channel = options.mem_ranks
+
+            mem_ctrls.append(mem_ctrl)
 
     system.mem_ctrls = mem_ctrls
 
index f81e69a61aa6a1769df3df443bbba9cbbe2e17b1..ea3de8691bf67e07ecf9d67639c3e77bc6479acb 100644 (file)
@@ -90,6 +90,8 @@ def addCommonOptions(parser):
                       help = "type of memory to use")
     parser.add_option("--mem-channels", type="int", default=1,
                       help = "number of memory channels")
+    parser.add_option("--mem-ranks", type="int", default=None,
+                      help = "number of memory ranks per channel")
     parser.add_option("--mem-size", action="store", type="string",
                       default="512MB",
                       help="Specify the physical memory size (single memory)")
index 42abc63a8d2e300b92cbfc473b159cfcdafb3fb3..44ac3d5125832f38c6b898a64eb48e32900e433b 100644 (file)
@@ -92,6 +92,11 @@ DRAMCtrl::DRAMCtrl(const DRAMCtrlParams* p) :
     busBusyUntil(0), prevArrival(0),
     nextReqTime(0), activeRank(0), timeStampOffset(0)
 {
+    // sanity check the ranks since we rely on bit slicing for the
+    // address decoding
+    fatal_if(!isPowerOf2(ranksPerChannel), "DRAM rank count of %d is not "
+             "allowed, must be a power of two\n", ranksPerChannel);
+
     for (int i = 0; i < ranksPerChannel; i++) {
         Rank* rank = new Rank(*this, p);
         ranks.push_back(rank);