inorder-mdu: multiplier latency fix
authorKorey Sewell <ksewell@umich.edu>
Thu, 17 Sep 2009 19:45:27 +0000 (15:45 -0400)
committerKorey Sewell <ksewell@umich.edu>
Thu, 17 Sep 2009 19:45:27 +0000 (15:45 -0400)
mdu was workign incorrectly for 4+ latency due to incorrectly assuming
multiply was finished the next stage

src/cpu/inorder/resources/mult_div_unit.cc
src/cpu/inorder/resources/mult_div_unit.hh

index 7592c02609a2e029d8a1951148fd46fc84f8656d..e7bd6750f897cd4286506b6e496ed446731b6371 100644 (file)
@@ -91,7 +91,32 @@ MultDivUnit::freeSlot(int slot_idx)
     Resource::freeSlot(slot_idx);    
 }
 
-
+//@TODO: Should we push this behavior into base-class to generically
+//       accomodate all multicyle resources?
+void
+MultDivUnit::requestAgain(DynInstPtr inst, bool &service_request)
+{
+    ResReqPtr mult_div_req = findRequest(inst);
+    assert(mult_div_req);
+
+    service_request = true;
+
+    // Check to see if this instruction is requesting the same command
+    // or a different one
+    if (mult_div_req->cmd != inst->resSched.top()->cmd) {
+        // If different, then update command in the request
+        mult_div_req->cmd = inst->resSched.top()->cmd;
+        DPRINTF(InOrderMDU,
+                "[tid:%i]: [sn:%i]: Updating the command for this instruction\n",
+                inst->readTid(), inst->seqNum);
+    } else {
+        // If same command, just check to see if memory access was completed
+        // but dont try to re-execute
+        DPRINTF(InOrderMDU,
+                "[tid:%i]: [sn:%i]: requesting this resource again\n",
+                inst->readTid(), inst->seqNum);
+    }
+}
 int
 MultDivUnit::getSlot(DynInstPtr inst)
 {
@@ -232,8 +257,13 @@ MultDivUnit::execute(int slot_num)
         //      counting down the time
         {
             DPRINTF(InOrderMDU, "End MDU called ...\n");    
-            if (mult_div_req->getInst()->isExecuted())
+            if (mult_div_req->getInst()->isExecuted()) {
+                DPRINTF(InOrderMDU, "Mult/Div finished.\n");                    
                 mult_div_req->done();            
+            } else {                
+                mult_div_req->setCompleted(false);
+            }
+            
         }
         break;
 
index 76180714c98efe21c1b52b05a44d76061b633a03..d3dd0260d434a2f25a4f7681f71ae4b7368666c4 100644 (file)
@@ -82,6 +82,8 @@ class MultDivUnit : public Resource {
     /** Register extra resource stats */
     virtual void regStats();
 
+    void requestAgain(DynInstPtr inst, bool &try_request);
+
   protected:
     /** Latency & Repeat Rate for Multiply Insts */
     unsigned multRepeatRate;