sim: added performance counter
[calu.git] / 3b_sim / ccpu.cpp
index abeeafd607c912e01402a9d889871895fe6bee49..5f533ce42c546860fd22e9f99d63ae77d371f2b8 100644 (file)
@@ -17,6 +17,7 @@ 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();
@@ -190,7 +191,23 @@ void CCpu::setStack(const int val)
        this->m_stack = val;
 }
 
-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_reg(regs), m_ram(ram), m_prog(prog), m_stack(0)
+CDat CCpu::getPerf() const
+{
+       return this->m_perf;
+}
+
+void CCpu::setPerf(CDat val)
+{
+       this->m_perf = val;
+}
+
+void CCpu::incPerf()
+{
+       this->m_perf++;
+}
+
+
+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)
 {
 }