changeset 28cb3b80435c in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=28cb3b80435c
description:
        style: cleanup the Ruby Tester

diffstat:

6 files changed, 564 insertions(+), 659 deletions(-)
src/cpu/rubytest/Check.cc      |  547 ++++++++++++++++++----------------------
src/cpu/rubytest/Check.hh      |   98 ++-----
src/cpu/rubytest/CheckTable.cc |  139 +++++-----
src/cpu/rubytest/CheckTable.hh |   74 ++---
src/cpu/rubytest/RubyTester.cc |  181 ++++++-------
src/cpu/rubytest/RubyTester.hh |  184 ++++++-------

diffs (truncated from 1527 to 300 lines):

diff -r 6531ddc70176 -r 28cb3b80435c src/cpu/rubytest/Check.cc
--- a/src/cpu/rubytest/Check.cc Sat Mar 27 02:23:00 2010 -0400
+++ b/src/cpu/rubytest/Check.cc Mon Mar 29 20:39:02 2010 -0400
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
  * Copyright (c) 2009 Advanced Micro Devices, Inc.
@@ -28,370 +27,330 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
 #include "cpu/rubytest/Check.hh"
+#include "mem/ruby/common/SubBlock.hh"
 #include "mem/ruby/system/Sequencer.hh"
 #include "mem/ruby/system/System.hh"
-#include "mem/ruby/common/SubBlock.hh"
 
-Check::Check(const Address& address, 
-             const Address& pc,
-             int _num_cpu_sequencers,
-             RubyTester* _tester)
-  : m_num_cpu_sequencers(_num_cpu_sequencers), m_tester_ptr(_tester)
+typedef RubyTester::SenderState SenderState;
+
+Check::Check(const Address& address, const Address& pc,
+             int _num_cpu_sequencers, RubyTester* _tester)
+    : m_num_cpu_sequencers(_num_cpu_sequencers), m_tester_ptr(_tester)
 {
-  m_status = TesterStatus_Idle;
+    m_status = TesterStatus_Idle;
 
-  pickValue();
-  pickInitiatingNode();
-  changeAddress(address);
-  m_pc = pc;
-  m_access_mode = AccessModeType(random() % AccessModeType_NUM);
-  m_store_count = 0;
+    pickValue();
+    pickInitiatingNode();
+    changeAddress(address);
+    m_pc = pc;
+    m_access_mode = AccessModeType(random() % AccessModeType_NUM);
+    m_store_count = 0;
 }
 
-void Check::initiate()
+void
+Check::initiate()
 {
-  DPRINTF(RubyTest, "initiating\n");
-  debugPrint();
+    DPRINTF(RubyTest, "initiating\n");
+    debugPrint();
 
-  //
-  // currently no protocols support prefetches
-  //
-  if (false && (random() & 0xf) == 0) {
-    initiatePrefetch(); // Prefetch from random processor
-  }
+    // currently no protocols support prefetches
+    if (false && (random() & 0xf) == 0) {
+        initiatePrefetch(); // Prefetch from random processor
+    }
 
-  if(m_status == TesterStatus_Idle) {
-    initiateAction();
-  } else if(m_status == TesterStatus_Ready) {
-    initiateCheck();
-  } else {
-    // Pending - do nothing
-    DPRINTF(RubyTest, "initiating action/check - failed: action/check is 
pending\n");
-  }
+    if (m_status == TesterStatus_Idle) {
+        initiateAction();
+    } else if (m_status == TesterStatus_Ready) {
+        initiateCheck();
+    } else {
+        // Pending - do nothing
+        DPRINTF(RubyTest,
+                "initiating action/check - failed: action/check is pending\n");
+    }
 }
 
-void Check::initiatePrefetch()
+void
+Check::initiatePrefetch()
 {
-  DPRINTF(RubyTest, "initiating prefetch\n");
+    DPRINTF(RubyTest, "initiating prefetch\n");
 
-  RubyTester::CpuPort* port 
-    = safe_cast<RubyTester::CpuPort*> \
-    (m_tester_ptr->getCpuPort(random() % m_num_cpu_sequencers));
+    int index = random() % m_num_cpu_sequencers;
+    RubyTester::CpuPort* port =
+        safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getCpuPort(index));
 
-  Request::Flags flags;
-  flags.set(Request::PREFETCH);
+    Request::Flags flags;
+    flags.set(Request::PREFETCH);
 
-  //
-  // Prefetches are assumed to be 0 sized
-  //
-  Request *req = new Request(m_address.getAddress(),
-                             0,
-                             flags,
-                             curTick,
-                             m_pc.getAddress());
+    // Prefetches are assumed to be 0 sized
+    Request *req = new Request(m_address.getAddress(), 0, flags, curTick,
+                               m_pc.getAddress());
 
-  Packet::Command cmd;
+    Packet::Command cmd;
 
-  //
-  // 1 in 8 chance this will be an exclusive prefetch
-  //
-  if ((random() & 0x7) != 0) {
-    cmd = MemCmd::ReadReq;
-    //
-    // 50% chance that the request will be an instruction fetch
-    //
-    if ((random() & 0x1) == 0) { 
-      flags.set(Request::INST_FETCH);
+    // 1 in 8 chance this will be an exclusive prefetch
+    if ((random() & 0x7) != 0) {
+        cmd = MemCmd::ReadReq;
+
+        // 50% chance that the request will be an instruction fetch
+        if ((random() & 0x1) == 0) {
+            flags.set(Request::INST_FETCH);
+        }
+    } else {
+        cmd = MemCmd::WriteReq;
+        flags.set(Request::PF_EXCLUSIVE);
     }
-  } else {
-    cmd = MemCmd::WriteReq;
-    flags.set(Request::PF_EXCLUSIVE);
-  }
 
-  PacketPtr pkt = new Packet(req, cmd, port->idx);
+    PacketPtr pkt = new Packet(req, cmd, port->idx);
 
-  //
-  // push the subblock onto the sender state.  The sequencer will update the
-  // subblock on the return
-  //
-  pkt->senderState = new RubyTester::SenderState(m_address, 
-                                                 req->getSize(),
-                                                 pkt->senderState);
+    // push the subblock onto the sender state.  The sequencer will
+    // update the subblock on the return
+    pkt->senderState =
+        new SenderState(m_address, req->getSize(), pkt->senderState);
 
-  if (port->sendTiming(pkt)) {
-    DPRINTF(RubyTest, "successfully initiated prefetch.\n");
-  } else {
-    //
-    // If the packet did not issue, must delete
-    //
-    RubyTester::SenderState* senderState = 
-        safe_cast<RubyTester::SenderState*>(pkt->senderState);
-    pkt->senderState = senderState->saved;
-    delete senderState;
-    delete pkt->req;
-    delete pkt;
+    if (port->sendTiming(pkt)) {
+        DPRINTF(RubyTest, "successfully initiated prefetch.\n");
+    } else {
+        // If the packet did not issue, must delete
+        SenderState* senderState =  safe_cast<SenderState*>(pkt->senderState);
+        pkt->senderState = senderState->saved;
+        delete senderState;
+        delete pkt->req;
+        delete pkt;
 
-    DPRINTF(RubyTest, "prefetch initiation failed because Port was busy.\n");
-  }
+        DPRINTF(RubyTest,
+                "prefetch initiation failed because Port was busy.\n");
+    }
 }
 
-void Check::initiateAction()
+void
+Check::initiateAction()
 {
-  DPRINTF(RubyTest, "initiating Action\n");
-  assert(m_status == TesterStatus_Idle);
-  
-  RubyTester::CpuPort* port
-    = safe_cast<RubyTester::CpuPort*> \
-    (m_tester_ptr->getCpuPort(random() % m_num_cpu_sequencers));
+    DPRINTF(RubyTest, "initiating Action\n");
+    assert(m_status == TesterStatus_Idle);
 
-  Request::Flags flags;
+    int index = random() % m_num_cpu_sequencers;
+    RubyTester::CpuPort* port =
+        safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getCpuPort(index));
 
-  //
-  // Create the particular address for the next byte to be written
-  //
-  Address writeAddr(m_address.getAddress() + m_store_count);
+    Request::Flags flags;
 
-  //
-  // Stores are assumed to be 1 byte-sized
-  //
-  Request *req = new Request(writeAddr.getAddress(),
-                             1,
-                             flags,
-                             curTick,
-                             m_pc.getAddress());
+    // Create the particular address for the next byte to be written
+    Address writeAddr(m_address.getAddress() + m_store_count);
 
-  Packet::Command cmd;
+    // Stores are assumed to be 1 byte-sized
+    Request *req = new Request(writeAddr.getAddress(), 1, flags, curTick,
+                               m_pc.getAddress());
 
-  //
-  // 1 out of 8 chance, issue an atomic rather than a write
-  //
-//   if ((random() & 0x7) == 0) {
-//     cmd = MemCmd::SwapReq;
-//   } else {
+    Packet::Command cmd;
+
+    // 1 out of 8 chance, issue an atomic rather than a write
+    // if ((random() & 0x7) == 0) {
+    //     cmd = MemCmd::SwapReq;
+    // } else {
     cmd = MemCmd::WriteReq;
-//   }
+    // }
 
-  PacketPtr pkt = new Packet(req, cmd, port->idx);
-  uint8_t* writeData = new uint8_t;
-  *writeData = m_value + m_store_count;
-  pkt->dataDynamic(writeData);
+    PacketPtr pkt = new Packet(req, cmd, port->idx);
+    uint8_t* writeData = new uint8_t;
+    *writeData = m_value + m_store_count;
+    pkt->dataDynamic(writeData);
 
-  DPRINTF(RubyTest, 
-          "data 0x%x check 0x%x\n",
-          *(pkt->getPtr<uint8_t>()),
-          *writeData);
+    DPRINTF(RubyTest, "data 0x%x check 0x%x\n",
+            *(pkt->getPtr<uint8_t>()), *writeData);
 
-  //
-  // push the subblock onto the sender state.  The sequencer will update the
-  // subblock on the return
-  //
-  pkt->senderState = new RubyTester::SenderState(writeAddr, 
-                                                 req->getSize(),
-                                                 pkt->senderState);
+    // push the subblock onto the sender state.  The sequencer will
+    // update the subblock on the return
+    pkt->senderState =
+        new SenderState(writeAddr, req->getSize(), pkt->senderState);
 
-  if (port->sendTiming(pkt)) {
-    DPRINTF(RubyTest, "initiating action - successful\n");
-    DPRINTF(RubyTest, 
-            "status before action update: %s\n",
+    if (port->sendTiming(pkt)) {
+        DPRINTF(RubyTest, "initiating action - successful\n");
+        DPRINTF(RubyTest, "status before action update: %s\n",
+                (TesterStatus_to_string(m_status)).c_str());
+        m_status = TesterStatus_Action_Pending;
+    } else {
+        // If the packet did not issue, must delete
+        // Note: No need to delete the data, the packet destructor
+        // will delete it
+        SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
+        pkt->senderState = senderState->saved;
+        delete senderState;
+        delete pkt->req;
+        delete pkt;
+
+        DPRINTF(RubyTest, "failed to initiate action - sequencer not ready\n");
+    }
+
+    DPRINTF(RubyTest, "status after action update: %s\n",
             (TesterStatus_to_string(m_status)).c_str());
-    m_status = TesterStatus_Action_Pending;
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to