diff options
Diffstat (limited to 'ue3/mycpu/ccpu.h')
| -rw-r--r-- | ue3/mycpu/ccpu.h | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/ue3/mycpu/ccpu.h b/ue3/mycpu/ccpu.h new file mode 100644 index 0000000..e28a7cc --- /dev/null +++ b/ue3/mycpu/ccpu.h | |||
| @@ -0,0 +1,167 @@ | |||
| 1 | /** | ||
| 2 | * @module ccpu | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief TODO | ||
| 5 | * @date 10.05.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef CCPU_H | ||
| 9 | #define CCPU_H 1 | ||
| 10 | |||
| 11 | #include <vector> | ||
| 12 | #include <iostream> | ||
| 13 | #include "cdat.h" | ||
| 14 | #include "cmem.h" | ||
| 15 | #include "cprogram.h" | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @class CCPU | ||
| 19 | * | ||
| 20 | * TODO | ||
| 21 | */ | ||
| 22 | class CCPU | ||
| 23 | { | ||
| 24 | public: | ||
| 25 | /** | ||
| 26 | * @method CCPU | ||
| 27 | * @brief Default ctor | ||
| 28 | * @param cnt number of registers to allocate for this cpu | ||
| 29 | * @return - | ||
| 30 | * @globalvars none | ||
| 31 | * @exception none | ||
| 32 | * @conditions none | ||
| 33 | */ | ||
| 34 | CCPU(const unsigned cnt); | ||
| 35 | |||
| 36 | /** | ||
| 37 | * @method ~CCPU | ||
| 38 | * @brief Default dtor | ||
| 39 | * @param - | ||
| 40 | * @return - | ||
| 41 | * @globalvars none | ||
| 42 | * @exception none | ||
| 43 | * @conditions none | ||
| 44 | */ | ||
| 45 | ~CCPU(); | ||
| 46 | |||
| 47 | /** | ||
| 48 | * @method getRegisterCount | ||
| 49 | * @brief get number of registers | ||
| 50 | * @param - | ||
| 51 | * @return number of registers | ||
| 52 | * @globalvars none | ||
| 53 | * @exception none | ||
| 54 | * @conditions none | ||
| 55 | */ | ||
| 56 | const unsigned getRegisterCount() | ||
| 57 | { | ||
| 58 | return m_regcnt; | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | ||
| 62 | * @method getRegisters | ||
| 63 | * @brief get pointer to registers array | ||
| 64 | * @param - | ||
| 65 | * @return pointer to registers array | ||
| 66 | * @globalvars none | ||
| 67 | * @exception none | ||
| 68 | * @conditions none | ||
| 69 | */ | ||
| 70 | CDat *getRegisters() | ||
| 71 | { | ||
| 72 | return m_registers; | ||
| 73 | } | ||
| 74 | |||
| 75 | /** | ||
| 76 | * @method setMemory | ||
| 77 | * @brief set memory of cpu | ||
| 78 | * @param memory pointer to memory | ||
| 79 | * @return - | ||
| 80 | * @globalvars none | ||
| 81 | * @exception none | ||
| 82 | * @conditions none | ||
| 83 | */ | ||
| 84 | void setMemory(const CMem *memory) | ||
| 85 | { | ||
| 86 | m_memory = memory; | ||
| 87 | } | ||
| 88 | |||
| 89 | /** | ||
| 90 | * @method getMemory | ||
| 91 | * @brief get pointer to memory | ||
| 92 | * @param - | ||
| 93 | * @return pointer to memory | ||
| 94 | * @globalvars none | ||
| 95 | * @exception none | ||
| 96 | * @conditions none | ||
| 97 | */ | ||
| 98 | const CMem *getMemory() | ||
| 99 | { | ||
| 100 | return m_memory; | ||
| 101 | } | ||
| 102 | |||
| 103 | /** | ||
| 104 | * @method setProgram | ||
| 105 | * @brief set program to execute | ||
| 106 | * @param memory pointer to program | ||
| 107 | * @return - | ||
| 108 | * @globalvars none | ||
| 109 | * @exception none | ||
| 110 | * @conditions none | ||
| 111 | */ | ||
| 112 | void setProgram(const CProgram *program) | ||
| 113 | { | ||
| 114 | m_program = program; | ||
| 115 | } | ||
| 116 | |||
| 117 | /** | ||
| 118 | * @method getProgram | ||
| 119 | * @brief get pointer to program | ||
| 120 | * @param - | ||
| 121 | * @return pointer to program | ||
| 122 | * @globalvars none | ||
| 123 | * @exception none | ||
| 124 | * @conditions none | ||
| 125 | */ | ||
| 126 | const CProgram *getProgram() | ||
| 127 | { | ||
| 128 | return m_program; | ||
| 129 | } | ||
| 130 | |||
| 131 | /** | ||
| 132 | * @method run | ||
| 133 | * @brief execute current program | ||
| 134 | * @param - | ||
| 135 | * @return - | ||
| 136 | * @globalvars none | ||
| 137 | * @exception runtime_error | ||
| 138 | * @conditions none | ||
| 139 | */ | ||
| 140 | void run(); | ||
| 141 | |||
| 142 | #if DEBUG | ||
| 143 | /** | ||
| 144 | * @method dumpRegisters | ||
| 145 | * @brief dump content of registers to outputstream | ||
| 146 | * @param out outputstream to write to | ||
| 147 | * @return void | ||
| 148 | * @globalvars none | ||
| 149 | * @exception none | ||
| 150 | * @conditions none | ||
| 151 | */ | ||
| 152 | void dumpRegisters(std::ostream& out); | ||
| 153 | #endif | ||
| 154 | |||
| 155 | private: | ||
| 156 | /* members */ | ||
| 157 | CDat *m_registers; | ||
| 158 | unsigned m_regcnt; | ||
| 159 | const CMem *m_memory; | ||
| 160 | const CProgram *m_program; | ||
| 161 | bool m_flagzero; | ||
| 162 | bool m_flagsign; | ||
| 163 | }; | ||
| 164 | |||
| 165 | #endif | ||
| 166 | |||
| 167 | /* vim: set et sw=2 ts=2: */ | ||
