mem: Fix DRAMSim2 cycle check when restoring from checkpoint
authorAndreas Hansson <andreas.hansson@arm.com>
Tue, 26 Aug 2014 14:14:38 +0000 (10:14 -0400)
committerAndreas Hansson <andreas.hansson@arm.com>
Tue, 26 Aug 2014 14:14:38 +0000 (10:14 -0400)
This patch ensures the cycle check is still valid even restoring from
a checkpoint. In this case the DRAMSim2 cycle count is relative to the
startTick rather than 0.

src/mem/dramsim2.cc
src/mem/dramsim2.hh

index cbba2767efcc1a583f2e482cbcf246f7571ba2e1..27dc3697651b49a598145d6949f2b0249277c18f 100644 (file)
@@ -50,7 +50,7 @@ DRAMSim2::DRAMSim2(const Params* p) :
     port(name() + ".port", *this),
     wrapper(p->deviceConfigFile, p->systemConfigFile, p->filePath,
             p->traceFile, p->range.size() / 1024 / 1024, p->enableDebug),
-    retryReq(false), retryResp(false),
+    retryReq(false), retryResp(false), startTick(0),
     nbrOutstandingReads(0), nbrOutstandingWrites(0),
     drainManager(NULL),
     sendResponseEvent(this), tickEvent(this)
@@ -91,6 +91,8 @@ DRAMSim2::init()
 void
 DRAMSim2::startup()
 {
+    startTick = curTick();
+
     // kick off the clock ticks
     schedule(tickEvent, clockEdge());
 }
@@ -287,7 +289,7 @@ DRAMSim2::accessAndRespond(PacketPtr pkt)
 
 void DRAMSim2::readComplete(unsigned id, uint64_t addr, uint64_t cycle)
 {
-    assert(cycle == divCeil(curTick(),
+    assert(cycle == divCeil(curTick() - startTick,
                             wrapper.clockPeriod() * SimClock::Int::ns));
 
     DPRINTF(DRAMSim2, "Read to address %lld complete\n", addr);
@@ -315,7 +317,7 @@ void DRAMSim2::readComplete(unsigned id, uint64_t addr, uint64_t cycle)
 
 void DRAMSim2::writeComplete(unsigned id, uint64_t addr, uint64_t cycle)
 {
-    assert(cycle == divCeil(curTick(),
+    assert(cycle == divCeil(curTick() - startTick,
                             wrapper.clockPeriod() * SimClock::Int::ns));
 
     DPRINTF(DRAMSim2, "Write to address %lld complete\n", addr);
index c61b84cbe0044bd553cb569a1b958ad940a6fd70..7153f3f848e240b1169ef21dd5c9696c66ca9df8 100644 (file)
@@ -103,6 +103,11 @@ class DRAMSim2 : public AbstractMemory
      */
     bool retryResp;
 
+    /**
+     * Keep track of when the wrapper is started.
+     */
+    Tick startTick;
+
     /**
      * Keep track of what packets are outstanding per
      * address, and do so separately for reads and writes. This is