4c250b57570b97363655da1bbf9c8374e3013843
[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                 void incPerfBy(short);
41
42                 CDat getCurPC() const;
43                 CDat getNextPC() const;
44                 void setNextPC(CDat);
45
46                 CDat getFlags() const;
47                 void setFlags(CDat);
48                 /* will only change zero and sign */
49                 void updateFlags(CDat);
50                 /* will change all flags */
51                 void updateFlags(CDatd, CDat, CDat);
52                 /* will change all flags */
53                 void updateFlags(bool z, bool o, bool c, bool s);
54                 /* will change carry */
55                 void updateCarry(bool c);
56
57                 bool getCarry();
58
59                 bool conditionMet(short);
60
61                 int getStack() const;
62                 void setStack(const int);
63
64                 CCpu(int,int,int);
65
66 };
67
68
69 #endif