sim: arith. fixes, optimized mem access
[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;
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 getCurPC() const;
38                 CDat getNextPC() const;
39                 void setNextPC(CDat);
40
41                 CDat getFlags() const;
42                 /* will only change zero and sign */
43                 void updateFlags(CDat);
44                 /* will change all flags */
45                 void updateFlags(CDatd, CDat, CDat);
46                 /* will change all flags */
47                 void updateFlags(bool z, bool o, bool c, bool s);
48         
49
50                 bool conditionMet(short);
51
52                 int getStack() const;
53                 void setStack(const int);
54
55                 CCpu(int,int,int);
56
57 };
58
59
60 #endif