From 45581d3d376e8deed84952cb838ae330549e5241 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 12 May 2009 23:18:17 +0200 Subject: my cpu design --- ue3/mycpu/ccpu.h | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 ue3/mycpu/ccpu.h (limited to 'ue3/mycpu/ccpu.h') 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 @@ +/** + * @module ccpu + * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) + * @brief TODO + * @date 10.05.2009 + */ + +#ifndef CCPU_H +#define CCPU_H 1 + +#include +#include +#include "cdat.h" +#include "cmem.h" +#include "cprogram.h" + +/** + * @class CCPU + * + * TODO + */ +class CCPU +{ + public: + /** + * @method CCPU + * @brief Default ctor + * @param cnt number of registers to allocate for this cpu + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + CCPU(const unsigned cnt); + + /** + * @method ~CCPU + * @brief Default dtor + * @param - + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + ~CCPU(); + + /** + * @method getRegisterCount + * @brief get number of registers + * @param - + * @return number of registers + * @globalvars none + * @exception none + * @conditions none + */ + const unsigned getRegisterCount() + { + return m_regcnt; + } + + /** + * @method getRegisters + * @brief get pointer to registers array + * @param - + * @return pointer to registers array + * @globalvars none + * @exception none + * @conditions none + */ + CDat *getRegisters() + { + return m_registers; + } + + /** + * @method setMemory + * @brief set memory of cpu + * @param memory pointer to memory + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + void setMemory(const CMem *memory) + { + m_memory = memory; + } + + /** + * @method getMemory + * @brief get pointer to memory + * @param - + * @return pointer to memory + * @globalvars none + * @exception none + * @conditions none + */ + const CMem *getMemory() + { + return m_memory; + } + + /** + * @method setProgram + * @brief set program to execute + * @param memory pointer to program + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + void setProgram(const CProgram *program) + { + m_program = program; + } + + /** + * @method getProgram + * @brief get pointer to program + * @param - + * @return pointer to program + * @globalvars none + * @exception none + * @conditions none + */ + const CProgram *getProgram() + { + return m_program; + } + + /** + * @method run + * @brief execute current program + * @param - + * @return - + * @globalvars none + * @exception runtime_error + * @conditions none + */ + void run(); + +#if DEBUG + /** + * @method dumpRegisters + * @brief dump content of registers to outputstream + * @param out outputstream to write to + * @return void + * @globalvars none + * @exception none + * @conditions none + */ + void dumpRegisters(std::ostream& out); +#endif + + private: + /* members */ + CDat *m_registers; + unsigned m_regcnt; + const CMem *m_memory; + const CProgram *m_program; + bool m_flagzero; + bool m_flagsign; +}; + +#endif + +/* vim: set et sw=2 ts=2: */ -- cgit v1.2.3