InOrderCPU: Clean up Constructors to initialize variables correctly (i.e. in a way...
authorKorey Sewell <ksewell@umich.edu>
Thu, 5 Mar 2009 03:37:45 +0000 (22:37 -0500)
committerKorey Sewell <ksewell@umich.edu>
Thu, 5 Mar 2009 03:37:45 +0000 (22:37 -0500)
src/cpu/inorder/cpu.cc
src/cpu/inorder/first_stage.cc
src/cpu/inorder/inorder_dyn_inst.cc
src/cpu/inorder/pipeline_stage.cc
src/cpu/inorder/pipeline_stage.hh
src/cpu/inorder/resources/cache_unit.cc
src/cpu/inorder/resources/fetch_seq_unit.cc
src/cpu/inorder/resources/graduation_unit.cc
src/cpu/inorder/resources/mult_div_unit.cc
src/cpu/inorder/resources/mult_div_unit.hh
src/cpu/inorder/thread_context.hh

index 7dafd826f6ab7bfdf1cd8648c12932823e30f7b0..70877aae4b218ec7b75ae76263e29c6203a9988e 100644 (file)
@@ -147,6 +147,8 @@ InOrderCPU::CPUEvent::unscheduleEvent()
 InOrderCPU::InOrderCPU(Params *params)
     : BaseCPU(params),
       cpu_id(params->cpu_id),
+      coreType("default"),
+      _status(Idle),
       tickEvent(this),
       miscRegFile(this),
       timeBuffer(2 , 2),
@@ -162,10 +164,6 @@ InOrderCPU::InOrderCPU(Params *params)
 
     resPool = new ResourcePool(this, params);
 
-    coreType = "default"; // eventually get this from params
-
-    _status = Idle;
-
     // Resize for Multithreading CPUs
     thread.resize(numThreads);
 
index be4431a030f9128efd6aaf823bc0e6e2e9bb8762..5e389b256b5a59c5cc78cb2cb5bc7e9ed6e8e90d 100644 (file)
@@ -40,15 +40,12 @@ using namespace std;
 using namespace ThePipeline;
 
 FirstStage::FirstStage(Params *params, unsigned stage_num)
-    : PipelineStage(params, stage_num)
+    : PipelineStage(params, stage_num), numFetchingThreads(1),
+      fetchPolicy(FirstStage::RoundRobin)
 {
     for(int tid=0; tid < this->numThreads; tid++) {
         stageStatus[tid] = Running;
     }
-
-    numFetchingThreads = 1;
-
-    fetchPolicy = RoundRobin;
 }
 
 void
index d292d72f014886c90e7d7c59f8adb7cb21935bce..ceb3cbe516cc0e8572537e65dd6fbc574edf01da 100644 (file)
@@ -76,16 +76,14 @@ InOrderDynInst::InOrderDynInst(InOrderCPU *cpu,
 }
 
 InOrderDynInst::InOrderDynInst(StaticInstPtr &_staticInst)
-    : staticInst(_staticInst), traceData(NULL)
+    : seqNum(0), staticInst(_staticInst), traceData(NULL)
 {
-    seqNum = 0;
     initVars();
 }
 
 InOrderDynInst::InOrderDynInst()
-    : traceData(NULL), cpu(cpu)
+    : seqNum(0), traceData(NULL), cpu(cpu)
 {
-    seqNum = 0;
     initVars();
 }
 
index ab7328f4a92018c0ca0d52664cafe86a143fe179..cb69464b0aee663aac295b9c034ce349394ad7f8 100644 (file)
@@ -38,24 +38,17 @@ using namespace std;
 using namespace ThePipeline;
 
 PipelineStage::PipelineStage(Params *params, unsigned stage_num)
+    : stageNum(stage_num), stageWidth(ThePipeline::StageWidth),
+      numThreads(ThePipeline::MaxThreads), _status(Inactive),
+      stageBufferMax(ThePipeline::interStageBuffSize[stage_num]),
+      prevStageValid(false), nextStageValid(false)
 {
-    init(params, stage_num);
+    init(params);
 }
 
 void
-PipelineStage::init(Params *params, unsigned stage_num)
+PipelineStage::init(Params *params)
 {
-    stageNum = stage_num;
-    stageWidth = ThePipeline::StageWidth;
-
-    _status = Inactive;
-
-    numThreads = ThePipeline::MaxThreads;
-
-    prevStageValid = false;
-    nextStageValid = false;
-
-    // Init. structures
     for(int tid=0; tid < numThreads; tid++) {
         stageStatus[tid] = Idle;
 
@@ -69,8 +62,6 @@ PipelineStage::init(Params *params, unsigned stage_num)
         else
             lastStallingStage[tid] = NumStages - 1;
     }
-
-    stageBufferMax = ThePipeline::interStageBuffSize[stage_num];
 }
 
 
index 19bf8154f454b0bd128470f5e246f7c8c8a95db2..2fd8f2215fc95115b224ea309404e68567463281 100644 (file)
@@ -97,7 +97,7 @@ class PipelineStage
     virtual ~PipelineStage() { }
 
     /** PipelineStage initialization. */
-    void init(Params *params, unsigned stage_num);
+    void init(Params *params);
 
     /** Returns the name of stage. */
     std::string name() const;
index 6fd7ae36cbf50fff011f1e6bd801285c49f94782..57bcb10ef6be648a011c295894ce5fc3f6f0b8fd 100644 (file)
@@ -81,14 +81,9 @@ CacheUnit::CachePort::recvRetry()
 CacheUnit::CacheUnit(string res_name, int res_id, int res_width,
         int res_latency, InOrderCPU *_cpu, ThePipeline::Params *params)
     : Resource(res_name, res_id, res_width, res_latency, _cpu),
-      retryPkt(NULL), retrySlot(-1)
+      retryPkt(NULL), retrySlot(-1), cacheBlocked(false)
 {
-    //cacheData.resize(res_width);
-    //slotStatus = new CachePortStatus[width];
-    //fetchPC = new Addr[width];
     cachePort = new CachePort(this);
-
-    cacheBlocked = false;
 }
 
 Port *
index 36cf714c92999d81d03c976563ec3f6f3cb2b81d..444252e1b339a7eb58e5d98a95bc6d77aa8f1a13 100644 (file)
@@ -38,10 +38,9 @@ using namespace ThePipeline;
 
 FetchSeqUnit::FetchSeqUnit(std::string res_name, int res_id, int res_width,
                        int res_latency, InOrderCPU *_cpu, ThePipeline::Params *params)
-    : Resource(res_name, res_id, res_width, res_latency, _cpu)
+    : Resource(res_name, res_id, res_width, res_latency, _cpu),
+      instSize(sizeof(MachInst))
 {
-    instSize = sizeof(MachInst);
-
     for (int tid = 0; tid < ThePipeline::MaxThreads; tid++) {
         delaySlotInfo[tid].numInsts = 0;
         delaySlotInfo[tid].targetReady = false;
index 701da5996277c7b45d157fc4e40d481dc4226ea0..569401e4fd8189b0bf7a0a544b5d941d9fe62c34 100644 (file)
@@ -35,11 +35,10 @@ using namespace ThePipeline;
 
 GraduationUnit::GraduationUnit(std::string res_name, int res_id, int res_width,
                        int res_latency, InOrderCPU *_cpu, ThePipeline::Params *params)
-    : Resource(res_name, res_id, res_width, res_latency, _cpu)
+    : Resource(res_name, res_id, res_width, res_latency, _cpu),
+      lastCycleGrad(0), numCycleGrad(0)
+      
 {
-    lastCycleGrad = 0;
-    numCycleGrad = 0;
-
     for (int tid = 0; tid < ThePipeline::MaxThreads; tid++) {
         nonSpecInstActive[tid] = &cpu->nonSpecInstActive[tid];
         nonSpecSeqNum[tid] = &cpu->nonSpecSeqNum[tid];
index e98e97be7270f8b99a410afcfc9653f6b7d0ea66..b31d60ad51b2e9c9f48c6fd80b6e302a5387c0ad 100644 (file)
@@ -41,25 +41,14 @@ using namespace ThePipeline;
 
 MultDivUnit::MultDivUnit(string res_name, int res_id, int res_width,
                          int res_latency, InOrderCPU *_cpu, ThePipeline::Params *params)
-    : Resource(res_name, res_id, res_width, res_latency, _cpu)
-{
-    multRepeatRate = params->multRepeatRate;
-    multLatency = params->multLatency;
-
-    div8RepeatRate = params->div8RepeatRate;
-    div8Latency = params->div8Latency;
-
-    div16RepeatRate = params->div16RepeatRate;
-    div16Latency = params->div16Latency;
-
-    div24RepeatRate = params->div24RepeatRate;
-    div24Latency = params->div24Latency;
-
-    div32RepeatRate = params->div32RepeatRate;
-    div32Latency = params->div32Latency;    
-
-    lastMDUCycle = 0;
-}
+    : Resource(res_name, res_id, res_width, res_latency, _cpu),
+      multRepeatRate(params->multRepeatRate), multLatency(params->multLatency), 
+      div8RepeatRate(params->div8RepeatRate), div8Latency(params->div8Latency), 
+      div16RepeatRate(params->div16RepeatRate), div16Latency(params->div16Latency), 
+      div24RepeatRate(params->div24RepeatRate), div24Latency(params->div24Latency), 
+      div32RepeatRate(params->div32RepeatRate), div32Latency(params->div32Latency), 
+      lastMDUCycle(0)
+{ }
 
 void
 MultDivUnit::regStats()
index 762442c4bb7a74c3eacf609859d2b803012e49ce..003f6fbb173f08f807233803401da7b94b00b6af 100644 (file)
@@ -84,24 +84,24 @@ class MultDivUnit : public Resource {
 
   protected:
     /** Latency & Repeat Rate for Multiply Insts */
-    unsigned multLatency;
     unsigned multRepeatRate;
+    unsigned multLatency;
 
     /** Latency & Repeat Rate for 8-bit Divide Insts */
-    unsigned div8Latency;
     unsigned div8RepeatRate;
+    unsigned div8Latency;
 
     /** Latency & Repeat Rate for 16-bit Divide Insts */
-    unsigned div16Latency;
     unsigned div16RepeatRate;
+    unsigned div16Latency;
 
     /** Latency & Repeat Rate for 24-bit Divide Insts */
-    unsigned div24Latency;
     unsigned div24RepeatRate;
+    unsigned div24Latency;
 
     /** Latency & Repeat Rate for 32-bit Divide Insts */
-    unsigned div32Latency;
     unsigned div32RepeatRate;
+    unsigned div32Latency;
 
     /** Last cycle that MDU was used */
     Tick lastMDUCycle;
index 8b3b472904a973b48e0236b4e89f1350be2aac38..2fb2ed85fd43b145698824efc4322bc569800096 100644 (file)
@@ -132,6 +132,7 @@ class InOrderThreadContext : public ThreadContext
 
     /** Serializes state. */
     virtual void serialize(std::ostream &os);
+
     /** Unserializes state. */
     virtual void unserialize(Checkpoint *cp, const std::string &section);