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 From 89e202f49b9857dcd3627fbc4e0262125d729bbc Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 13 May 2009 04:09:39 +0200 Subject: adding all instructions and displays --- ue3/mycpu/ccpu.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 6 deletions(-) (limited to 'ue3/mycpu/ccpu.h') diff --git a/ue3/mycpu/ccpu.h b/ue3/mycpu/ccpu.h index e28a7cc..1ef1923 100644 --- a/ue3/mycpu/ccpu.h +++ b/ue3/mycpu/ccpu.h @@ -8,11 +8,12 @@ #ifndef CCPU_H #define CCPU_H 1 -#include #include +#include #include "cdat.h" #include "cmem.h" #include "cprogram.h" +#include "cdisplay.h" /** * @class CCPU @@ -53,7 +54,7 @@ class CCPU * @exception none * @conditions none */ - const unsigned getRegisterCount() + const unsigned getRegisterCount() const { return m_regcnt; } @@ -67,7 +68,7 @@ class CCPU * @exception none * @conditions none */ - CDat *getRegisters() + CDat *getRegisters() const { return m_registers; } @@ -81,7 +82,7 @@ class CCPU * @exception none * @conditions none */ - void setMemory(const CMem *memory) + void setMemory(CMem *memory) { m_memory = memory; } @@ -95,7 +96,7 @@ class CCPU * @exception none * @conditions none */ - const CMem *getMemory() + CMem *getMemory() const { return m_memory; } @@ -128,6 +129,76 @@ class CCPU return m_program; } + /** + * @method getDisplays + * @brief get set of pointers to displays + * @param - + * @return reference to set of pointers to displays + * @globalvars none + * @exception none + * @conditions none + */ + const std::set& getDisplays() + { + return m_displays; + } + + /** + * @method setFlagZero + * @brief set zero flag + * @param value new value of zero flag + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + void setFlagZero(const bool value) + { + m_flagzero = value; + } + + /** + * @method getFlagZero + * @brief get value of zero flag + * @param - + * @return value of zero flag + * @globalvars none + * @exception none + * @conditions none + */ + const bool getFlagZero() + { + return m_flagzero; + } + + /** + * @method setFlagSign + * @brief set sign flag + * @param value new value of sign flag + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + void setFlagSign(const bool value) + { + m_flagsign = value; + } + + /** + * @method getFlagSign + * @brief get value of sign flag + * @param - + * @return value of sign flag + * @globalvars none + * @exception none + * @conditions none + */ + const bool getFlagSign() + { + return m_flagsign; + } + /** * @method run * @brief execute current program @@ -156,8 +227,9 @@ class CCPU /* members */ CDat *m_registers; unsigned m_regcnt; - const CMem *m_memory; + CMem *m_memory; const CProgram *m_program; + std::set m_displays; bool m_flagzero; bool m_flagsign; }; -- cgit v1.2.3 From 431bbac5a99abbccf33500e22aa353ec792eff94 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 13 May 2009 15:29:51 +0200 Subject: * adding -Wno-long-long to all Makefiles * adding execute operator to cinstruction * added labels map for better performance --- ue3/mycpu/ccpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ue3/mycpu/ccpu.h') diff --git a/ue3/mycpu/ccpu.h b/ue3/mycpu/ccpu.h index 1ef1923..01c897f 100644 --- a/ue3/mycpu/ccpu.h +++ b/ue3/mycpu/ccpu.h @@ -205,7 +205,7 @@ class CCPU * @param - * @return - * @globalvars none - * @exception runtime_error + * @exception std::runtime_error * @conditions none */ void run(); -- cgit v1.2.3 From 3c6f886d5a8bfd36c796b963d6e3178ad9577742 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 13 May 2009 16:55:17 +0200 Subject: * added documentation (no more TODOs) * added testsuite + testcase * used copyctor instead of assign operator more often --- ue3/mycpu/ccpu.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ue3/mycpu/ccpu.h') diff --git a/ue3/mycpu/ccpu.h b/ue3/mycpu/ccpu.h index 01c897f..05b5c03 100644 --- a/ue3/mycpu/ccpu.h +++ b/ue3/mycpu/ccpu.h @@ -1,7 +1,8 @@ /** * @module ccpu * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) - * @brief TODO + * @brief CPU implementation. Used as a container for memory and instructions. + * Implements a run method to execute the program (= the instructions). * @date 10.05.2009 */ @@ -18,7 +19,8 @@ /** * @class CCPU * - * TODO + * CPU implementation. Used as a container for memory and instructions. + * Implements a run method to execute the program (= the instructions). */ class CCPU { -- cgit v1.2.3 From 67e99a217bd88a289d997b73f3e7cae6019bc22f Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 13 May 2009 17:01:15 +0200 Subject: fixing doxygen documentation --- ue3/mycpu/ccpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ue3/mycpu/ccpu.h') diff --git a/ue3/mycpu/ccpu.h b/ue3/mycpu/ccpu.h index 05b5c03..6849623 100644 --- a/ue3/mycpu/ccpu.h +++ b/ue3/mycpu/ccpu.h @@ -106,7 +106,7 @@ class CCPU /** * @method setProgram * @brief set program to execute - * @param memory pointer to program + * @param program pointer to program * @return - * @globalvars none * @exception none -- cgit v1.2.3