sim: added performance counter
[calu.git] / 3b_sim / ccpu.hpp
1 #ifndef __CPU__H__
2 #define __CPU__H__
3
4 #include "cdat.hpp"
5 #include "cmem.hpp"
6 #include "cpmem.hpp"
7
8 class Iinstr;
9
10 #include "Iinstr.hpp"
11
12
13 class CCpu {
14         private:
15
16                 bool m_Z, m_S, m_C, m_O;
17
18                 CDat m_pc, m_pc_next, m_perf;
19                 CMem<CDat> m_reg, m_ram;
20                 CPMem<Iinstr*> m_prog;
21
22                 CDat m_stack;
23
24         public:
25                 void registerExtension() {};
26                 void tick();
27
28                 CDat getRegister(const int) const;
29                 void setRegister(const int, CDat);
30
31                 CDat getRAM(const int) const;
32                 void setRAM(const int, CDat);
33
34                 Iinstr* getProg(const int) const;
35                 void setProg(const int, Iinstr*);
36
37                 CDat getPerf() const;
38                 void setPerf(CDat);
39                 void incPerf();
40
41                 CDat getCurPC() const;
42                 CDat getNextPC() const;
43                 void setNextPC(CDat);
44
45                 CDat getFlags() const;
46                 void setFlags(CDat);
47                 /* will only change zero and sign */
48                 void updateFlags(CDat);
49                 /* will change all flags */
50                 void updateFlags(CDatd, CDat, CDat);
51                 /* will change all flags */
52                 void updateFlags(bool z, bool o, bool c, bool s);
53                 /* will change carry */
54                 void updateCarry(bool c);
55
56                 bool getCarry();
57
58                 bool conditionMet(short);
59
60                 int getStack() const;
61                 void setStack(const int);
62
63                 CCpu(int,int,int);
64
65 };
66
67
68 #endif