sim: added extensionmodule support + progger
[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 class Iext;
12
13 #include "iext.hpp"
14 #include <boost/regex.hpp>
15 #include "Iinstr.hpp"
16
17
18 class CCpu {
19         private:
20
21                 bool m_Z, m_S, m_C, m_O;
22
23                 CDat m_pc, m_pc_next, m_perf;
24                 CMem<CDat> m_reg, m_ram;
25                 CPMem<Iinstr*> m_prog;
26
27                 vector<Iext*> m_exts;
28
29                 CDat m_stack;
30
31                 static const int EXT_MODEL_OFFSET = 0x2000;
32
33         public:
34                 void registerExtension() {};
35                 void tick();
36
37                 CDat getRegister(const int) const;
38                 void setRegister(const int, CDat);
39
40                 CDat getRAM(const int) const;
41                 void setRAM(const int, CDat);
42
43                 Iinstr* getProg(const int) const;
44                 void setProg(const int, Iinstr*);
45
46                 void registerExtension(Iext*);
47
48                 CDat getPerf() const;
49                 void setPerf(CDat);
50                 void incPerf();
51                 void incPerfBy(short);
52
53                 CDat getCurPC() const;
54                 CDat getNextPC() const;
55                 void setNextPC(CDat);
56
57                 CDat getFlags() const;
58                 void setFlags(CDat);
59                 /* will only change zero and sign */
60                 void updateFlags(CDat);
61                 /* will change all flags */
62                 void updateFlags(CDatd, CDat, CDat);
63                 /* will change all flags */
64                 void updateFlags(bool z, bool o, bool c, bool s);
65                 /* will change carry */
66                 void updateCarry(bool c);
67
68                 bool getCarry();
69
70                 bool conditionMet(short);
71
72                 int getStack() const;
73                 void setStack(const int);
74
75                 string colorifyInstr(string instr);
76
77                 CCpu(int,int,int);
78
79 };
80
81
82 #endif