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