diff options
| author | Günther Neuwirth <e0626638@student.tuwien.ac.at> | 2009-05-29 19:43:29 +0200 |
|---|---|---|
| committer | Günther Neuwirth <e0626638@student.tuwien.ac.at> | 2009-05-29 19:43:29 +0200 |
| commit | 87a3b3b466ebc0859bee7ffe0f5b461ce49227d3 (patch) | |
| tree | 3fdb60bfc0ae26e55adeba3d202d192799426a76 | |
| parent | 0c146f50d4b1c4d986a21387e1804c4707d8fd6f (diff) | |
| download | ooprog-87a3b3b466ebc0859bee7ffe0f5b461ce49227d3.tar.gz ooprog-87a3b3b466ebc0859bee7ffe0f5b461ce49227d3.tar.bz2 ooprog-87a3b3b466ebc0859bee7ffe0f5b461ce49227d3.zip | |
Protocoll, conditions
| -rw-r--r-- | ue3/protokoll.pdf | bin | 406583 -> 406574 bytes | |||
| -rw-r--r-- | ue4/mycpu/cdatn.h | 2 | ||||
| -rw-r--r-- | ue4/mycpu/cdatset.h | 4 | ||||
| -rw-r--r-- | ue4/mycpu/mycpu.cpp | 4 | ||||
| -rw-r--r-- | ue4/protokoll.pdf | bin | 406583 -> 408803 bytes | |||
| -rw-r--r-- | ue4/protokoll/protokoll.tex | 103 |
6 files changed, 100 insertions, 13 deletions
diff --git a/ue3/protokoll.pdf b/ue3/protokoll.pdf index b7a0097..a973f42 100644 --- a/ue3/protokoll.pdf +++ b/ue3/protokoll.pdf | |||
| Binary files differ | |||
diff --git a/ue4/mycpu/cdatn.h b/ue4/mycpu/cdatn.h index 3d21369..c1ff1b7 100644 --- a/ue4/mycpu/cdatn.h +++ b/ue4/mycpu/cdatn.h | |||
| @@ -365,7 +365,7 @@ class CDatN | |||
| 365 | * @globalvars none | 365 | * @globalvars none |
| 366 | * @exception none | 366 | * @exception none |
| 367 | * @pre none | 367 | * @pre none |
| 368 | * @post none | 368 | * @post bit count of m_value trimed to width |
| 369 | */ | 369 | */ |
| 370 | inline void align() | 370 | inline void align() |
| 371 | { | 371 | { |
diff --git a/ue4/mycpu/cdatset.h b/ue4/mycpu/cdatset.h index 56a0630..5861379 100644 --- a/ue4/mycpu/cdatset.h +++ b/ue4/mycpu/cdatset.h | |||
| @@ -55,8 +55,8 @@ class CDatSet | |||
| 55 | * @return reference to inputstream | 55 | * @return reference to inputstream |
| 56 | * @globalvars none | 56 | * @globalvars none |
| 57 | * @exception none | 57 | * @exception none |
| 58 | * @pre none | 58 | * @pre stream != null |
| 59 | * @post none | 59 | * @post cdat.m_value = count of char 'o' |
| 60 | */ | 60 | */ |
| 61 | friend std::istream& operator>>(std::istream & stream, CDatSet& cdat) | 61 | friend std::istream& operator>>(std::istream & stream, CDatSet& cdat) |
| 62 | { | 62 | { |
diff --git a/ue4/mycpu/mycpu.cpp b/ue4/mycpu/mycpu.cpp index ac4498a..528537e 100644 --- a/ue4/mycpu/mycpu.cpp +++ b/ue4/mycpu/mycpu.cpp | |||
| @@ -114,8 +114,8 @@ void cpu_run(string& me, po::variables_map& vm, unsigned registers, T& datatype) | |||
| 114 | * @return 0 on success, not 0 otherwise | 114 | * @return 0 on success, not 0 otherwise |
| 115 | * @globalvars none | 115 | * @globalvars none |
| 116 | * @exception none | 116 | * @exception none |
| 117 | * @pre none | 117 | * @pre at least -c must be specified. |
| 118 | * @post none | 118 | * @post terminate with 0 if success else 1. |
| 119 | * | 119 | * |
| 120 | * parse commandline options, create and initialize memory, | 120 | * parse commandline options, create and initialize memory, |
| 121 | * create cprogram instance, which parses the programfile and | 121 | * create cprogram instance, which parses the programfile and |
diff --git a/ue4/protokoll.pdf b/ue4/protokoll.pdf index b7a0097..3e4a48c 100644 --- a/ue4/protokoll.pdf +++ b/ue4/protokoll.pdf | |||
| Binary files differ | |||
diff --git a/ue4/protokoll/protokoll.tex b/ue4/protokoll/protokoll.tex index 3db10b0..6131cdb 100644 --- a/ue4/protokoll/protokoll.tex +++ b/ue4/protokoll/protokoll.tex | |||
| @@ -37,7 +37,26 @@ Manuel Mausz, \matrnr 0728348\\ | |||
| 37 | 37 | ||
| 38 | Abbildung~\ref{fig:classdiagram1} zeigt das Klassendiagramm der Aufgabe. | 38 | Abbildung~\ref{fig:classdiagram1} zeigt das Klassendiagramm der Aufgabe. |
| 39 | 39 | ||
| 40 | TODO | 40 | Wie gefordert, wurden die zwei zusätzliche Datentypen, \mbox{CDatSet} und \mbox{CDatN}, implementiert und der Programmcode generisch gestaltet. |
| 41 | |||
| 42 | Dabei wurde \mbox{CDatSet} vom existierenden Typ \mbox{CDat} und boost::operators<\mbox{CDatSet}> mittels Mehrfachvererbung abgeleitet. | ||
| 43 | So war es möglich die Implemntierung, mittels Codewiederverwendung, auf das Überschreiben eines Kopierkonstruktors und des Operators \mbox{operator>>()} zu beschränken. | ||
| 44 | |||
| 45 | Da der Typ \mbox{CDatN} Werte variabler Bitlänge representiert, war es notwendig diesen vollständig neu zu implementieren. Es wurde von boost::operators<\mbox{CDatN}> abgeleitet und dabei eine zusätzliche | ||
| 46 | Methode \mbox{align()} definiert, die sicherstellt, dass der transportierte Wert immer auf die geforderte Bitanzahl konvertiert wird. | ||
| 47 | Weiters wurde ein Kopierkonstruktor definiert, der einen Integerwert und einen vorzeichenlosen Integerwert als Argument erwartet. | ||
| 48 | Letzterer ist mit dem Defaultwert 31 deklariert und repräsentiert die Bitanzahl, auf die ersterer konvertiert wird. Damit ist es möglich alle vorhandenen Datentypen einheitlich zu verarbeiten. | ||
| 49 | Der Defaultkonstruktor wurde wie gewünscht deaktiviert. | ||
| 50 | |||
| 51 | Um nun die Wahl des Datentyps zu ermöglichen, wurde die Synopsis des Programms mit \mbox{``-f''} erweitert. | ||
| 52 | Der Parameter dieser Option muß \mbox{``s''} oder ein Wert zwischen ``2'' und ``32'' sein. | ||
| 53 | Im Hauptprogramm wird nun anhand dieses Parameters der zuständige Datentyp instanziert und die template Methode | ||
| 54 | \mbox{cpu\_run()} aufgerufen, welche die Initialisierung und Abarbeitung des Programms anstößt. | ||
| 55 | |||
| 56 | Damit das Programm mit den verschiedenen Datentypen umgehen kann, wurden \mbox{CCPU}, \mbox{CMem}, \mbox{CProgram}, \mbox{CInstuction} und die abgeleiteten \mbox{Instructions} | ||
| 57 | zu Templates umgewandelt, die als Typparameter den, im Hauptprogramm, instanzierten Datentyp erhalten. | ||
| 58 | |||
| 59 | \newpage | ||
| 41 | 60 | ||
| 42 | %================================================================== | 61 | %================================================================== |
| 43 | \begin{center} | 62 | \begin{center} |
| @@ -49,23 +68,46 @@ TODO | |||
| 49 | \end{center} | 68 | \end{center} |
| 50 | %================================================================== | 69 | %================================================================== |
| 51 | 70 | ||
| 71 | \newpage | ||
| 52 | \subsection{Verwaltung der Ressourcen} | 72 | \subsection{Verwaltung der Ressourcen} |
| 53 | 73 | ||
| 54 | TODO | 74 | Die Register von \mbox{CCPU} werden nun, anstatt in einem Array, in einem Vector verwaltet. |
| 75 | Dieser wird mit der Anzahl der Register und dem, im Hauptprogramm, instanzierten Datentyp initialisiert. | ||
| 76 | Dadurch ist das Löschen der register im Destruktor nicht mehr notwendig. | ||
| 77 | |||
| 78 | Siehe auch Punkt~\ref{Probleme und Fallstricke}.\\ | ||
| 55 | 79 | ||
| 56 | \subsection{Fehlerbehandlung} | 80 | \subsection{Fehlerbehandlung} |
| 57 | 81 | ||
| 58 | TODO | 82 | Es wurden mehrere Exceptions, als Subklassen der jeweiligen Templateklassen, von Typ \mbox{std::invalid\_argument} abgeleitet. |
| 83 | Diese sind \mbox{CCPUError}, \mbox{CInstructionError}, \mbox{CMemError} und \mbox{CProgramError}. | ||
| 84 | |||
| 85 | Wird zB.: eine Exception von Typ \mbox{CInstructinError} geworfen, so wird sie in \mbox{CCPU} zu \mbox{CCPUError} umgewandelt und an das Hauptprogramm weitergereicht, | ||
| 86 | wo wider eine Umwandlung in \mbox{runtime\_error()} stattfindet. Das Fangen einer \mbox{runtime\_error()} Exeption bewirkt eine fehlerbeschreibende Ausgabe auf \mbox{std::cerr} | ||
| 87 | und den Programmabbruch mit Exitstatus 1. | ||
| 59 | 88 | ||
| 60 | \subsection{Implementierung} | 89 | \subsection{Implementierung} |
| 61 | 90 | ||
| 62 | TODO | 91 | Siehe Punkt~\ref{Design} und Abbildung~\ref{fig:classdiagram1} sowie |
| 92 | Punkt~\ref{Listings}.\\ | ||
| 93 | |||
| 94 | |||
| 63 | 95 | ||
| 64 | \section{Projektverlauf} | 96 | \section{Projektverlauf} |
| 65 | 97 | ||
| 66 | \subsection{Probleme und Fallstricke} | 98 | \subsection{Probleme und Fallstricke}\label{Probleme und Fallstricke} |
| 99 | |||
| 100 | \mbox{CDatN}: | ||
| 101 | |||
| 102 | Mit der, in der Angabe vorgeschlagenen Methode zur Begrenzung der Bitanzahl, ist es nur möglich positive Zahlen zu verarbeiten. | ||
| 103 | Somit entspricht -1 dem Maximum der, mit der Bitanzahl, darstellbaren positiven Zahl usw.. | ||
| 104 | |||
| 105 | Ein weiteres Problem besteht darin, dass die Anzahl der Instruktionen in CProgram, den maximal darstellbaren Wert übersteigt. | ||
| 106 | In diesen Fall ist das Programmverhalten undefiniert. | ||
| 67 | 107 | ||
| 68 | TODO | 108 | Auf Grund der Forderung, den Defaultkonstruktor von \mbox{CDatN} zu deaktivieren, wurden einige Probleme initiiert. |
| 109 | Es war nicht weiter möglich, die Register von \mbox{CCPU} in einem Array zu organisieren, da zur Deklaration ein Defaultkonstruktor notwendig ist. | ||
| 110 | Weiters musste eine Alternative zum, nicht mehr anwendbaren \mbox{boost::lexical\_cast} in \mbox{CMem} implementiert werden. | ||
| 69 | 111 | ||
| 70 | \subsection{Arbeitsaufwand} | 112 | \subsection{Arbeitsaufwand} |
| 71 | 113 | ||
| @@ -73,9 +115,14 @@ TODO | |||
| 73 | \toprule | 115 | \toprule |
| 74 | Entwicklungsschritt / Meilenstein & Arbeitsaufwand\\ | 116 | Entwicklungsschritt / Meilenstein & Arbeitsaufwand\\ |
| 75 | \midrule | 117 | \midrule |
| 76 | TODO & TODO\\ | 118 | Erstes Design & 1 Tage\\ |
| 77 | \hline | 119 | \hline |
| 78 | TODO & TODO\\ | 120 | Implementierung & 2 Tage\\ |
| 121 | \hline | ||
| 122 | Dokumentation (Doxygen) und Überprüfung aller\\ | ||
| 123 | Anforderungen gemäß der Programmierrichtlinien & 4 Stunden\\ | ||
| 124 | \hline | ||
| 125 | Erstellung des Protokolls & 2 Stunden\\ | ||
| 79 | \bottomrule | 126 | \bottomrule |
| 80 | \end{tabular} | 127 | \end{tabular} |
| 81 | 128 | ||
| @@ -88,5 +135,45 @@ TODO | |||
| 88 | \subsection{mycpu.cpp} | 135 | \subsection{mycpu.cpp} |
| 89 | \lstinputlisting{../mycpu/mycpu.cpp} | 136 | \lstinputlisting{../mycpu/mycpu.cpp} |
| 90 | 137 | ||
| 138 | \newpage | ||
| 139 | \subsection{cdat.h} | ||
| 140 | \lstinputlisting{../mycpu/cdat.h} | ||
| 141 | |||
| 142 | \newpage | ||
| 143 | \subsection{cdatset.h} | ||
| 144 | \lstinputlisting{../mycpu/cdatset.h} | ||
| 145 | |||
| 146 | \newpage | ||
| 147 | \subsection{cdatn.h} | ||
| 148 | \lstinputlisting{../mycpu/cdatn.h} | ||
| 149 | |||
| 150 | \newpage | ||
| 151 | \subsection{cmem.h} | ||
| 152 | \lstinputlisting{../mycpu/cmem.h} | ||
| 153 | |||
| 154 | \newpage | ||
| 155 | \subsection{cinstruction.h} | ||
| 156 | \lstinputlisting{../mycpu/cinstruction.h} | ||
| 157 | |||
| 158 | \newpage | ||
| 159 | \subsection{instructions.h} | ||
| 160 | \lstinputlisting{../mycpu/instructions.h} | ||
| 161 | |||
| 162 | \newpage | ||
| 163 | \subsection{cdisplay.h} | ||
| 164 | \lstinputlisting{../mycpu/cdisplay.h} | ||
| 165 | |||
| 166 | \newpage | ||
| 167 | \subsection{displays.h} | ||
| 168 | \lstinputlisting{../mycpu/displays.h} | ||
| 169 | |||
| 170 | \newpage | ||
| 171 | \subsection{cprogram.h} | ||
| 172 | \lstinputlisting{../mycpu/cprogram.h} | ||
| 173 | |||
| 174 | \newpage | ||
| 175 | \subsection{ccpu.h} | ||
| 176 | \lstinputlisting{../mycpu/ccpu.h} | ||
| 177 | |||
| 91 | \end{document} | 178 | \end{document} |
| 92 | 179 | ||
