cpu: Update DRAM traffic gen
[gem5.git] / src / cpu / inorder / resources / agen_unit.cc
index 44bf8c0ad3da58f50566eb90e9b16e6c01f00862..f978b2fa78816c67654a5f35c5a0ba41a6c5e8b7 100644 (file)
  */
 
 #include "cpu/inorder/resources/agen_unit.hh"
+#include "debug/InOrderAGEN.hh"
 
 AGENUnit::AGENUnit(std::string res_name, int res_id, int res_width,
-                   int res_latency, InOrderCPU *_cpu, ThePipeline::Params *params)
+                   Cycles res_latency, InOrderCPU *_cpu,
+                   ThePipeline::Params *params)
     : Resource(res_name, res_id, res_width, res_latency, _cpu)
 { }
 
+void
+AGENUnit::regStats()
+{
+    agens
+        .name(name() + ".agens")
+        .desc("Number of Address Generations");
+
+    Resource::regStats();
+}
+
 void
 AGENUnit::execute(int slot_num)
 {
-    ResourceRequest* agen_req = reqMap[slot_num];
-    DynInstPtr inst = reqMap[slot_num]->inst;
-    Fault fault = reqMap[slot_num]->fault;
+    ResourceRequest* agen_req = reqs[slot_num];
+    DynInstPtr inst = reqs[slot_num]->inst;
 #if TRACING_ON
     ThreadID tid = inst->readTid();
 #endif
-    int seq_num = inst->seqNum;
+    InstSeqNum seq_num = inst->seqNum;
 
-    agen_req->fault = NoFault;
+    if (inst->fault != NoFault) {
+        DPRINTF(InOrderAGEN,
+                "[tid:%i]: [sn:%i]: Detected %s fault @ %x. Forwarding to "
+                "next stage.\n", tid, inst->seqNum, inst->fault->name(),
+                inst->pcState());
+        agen_req->done();
+        return;
+    }
 
     switch (agen_req->cmd)
     {
@@ -59,19 +77,21 @@ AGENUnit::execute(int slot_num)
                         "[tid:%i] Generating Address for [sn:%i] (%s).\n",
                         tid, seq_num, inst->staticInst->getName());
 
-                fault = inst->calcEA();
+                inst->fault = inst->calcEA();
                 inst->setMemAddr(inst->getEA());
 
                 DPRINTF(InOrderAGEN,
                     "[tid:%i] [sn:%i] Effective address calculated as: %#x\n",
                     tid, seq_num, inst->getEA());
 
-                if (fault == NoFault) {
+                if (inst->fault == NoFault) {
                     agen_req->done();
                 } else {
-                    fatal("%s encountered while calculating address [sn:%i]",
-                          fault->name(), seq_num);
+                    fatal("%s encountered while calculating address [sn:%i] %s",
+                          inst->fault->name(), seq_num, inst->instName());
                 }
+
+                agens++;
             } else {
                 DPRINTF(InOrderAGEN,
                         "[tid:] Ignoring non-memory instruction [sn:%i]\n",