sim: instrs can have different effect on perf count
[calu.git] / 3b_sim / ccpu.cpp
index 5f533ce42c546860fd22e9f99d63ae77d371f2b8..6bfb65481fd61162ddcb9afd2ec3a9f14f102de1 100644 (file)
@@ -17,13 +17,14 @@ void CCpu::tick()
        if(instr == NULL) {
                throw string("Out of Instructions!");
        }
-       this->incPerf();
        if(this->conditionMet(instr->getCondition())) {
                cout << "Executing: " << instr->toString() << endl;
                instr->execInstr();
+               this->incPerfBy(instr->getClockCount());
        }
        else {
                cout << "Didn't Execute " << instr->toString() << "; condition wasn't met" << endl;
+               this->incPerf();
        }
 
 }
@@ -206,6 +207,11 @@ void CCpu::incPerf()
        this->m_perf++;
 }
 
+void CCpu::incPerfBy(short inc)
+{
+       this->m_perf += inc;
+}
+
 
 CCpu::CCpu(int regs, int ram, int prog) : m_Z(false), m_S(false), m_C(false), m_O(false), m_pc(0), m_pc_next(0), m_perf(0), m_reg(regs), m_ram(ram), m_prog(prog), m_stack(0)
 {