sim: labels and comments are now shown
[calu.git] / 1_isacmp / arm.tex
index 419a95b01d40d11b80aaba0d00d30b317e9479b4..13214bdaee0a218929c4e9903fd083d77c25d221 100644 (file)
@@ -1 +1,142 @@
 \section{ARM}
+
+ARM wurde anfangs von der Firma ACORN entwickelt und steht f\"ur Advanced Risc Machine. Es existieren
+mehrere verschiedene Versionen des Instruktionssatzes, diese Ausarbeitung gibt aber lediglich einen \"Uberblick
+\"uber die prinzipiellen Konzepte der Architektur.
+
+\subsection{Einsatzgebiet}
+
+Im allgemeinen wird bei ARM eine Instruktionsl\"ange von 32 Bits verwendet. Die gek\"urzte Thumb-Version verwendet lediglich 16 Bit. 
+Es existieren 31 general-purpose Register, 16 davon k\"onnen direkt \"uber die Registeradressen in den Instruktionen adressiert werden. 
+Die anderen Register werden verwendet um die Fehlerbehandlung zu beschleunigen. Aus diesem Grund beschreibt die ARM Architektur 
+eine Registermaschine mit einer RISC Architektur.
+
+Die Register \texttt{R13}, \texttt{R14} und \texttt{R15} finden besondere Verwendung. \texttt{R13} ist der Stack-Pointer, \texttt{R14} das Link Register und \texttt{R15} der Program-Counter. 
+Diese Register k\"onnen allerdings auch \"uber normale Instruktionen beschrieben werden. Das Link-Register beinhaltet die R\"ucksprungadresse
+im Falle eines Subroutinen-Calls.
+
+ARM bietet eine breite Varianz an Kernen f\"ur den Einsatz in verschiedenen Gebieten.
+Beispielsweise ist die ARM710 Familie designed um in Hand-Helds und anderen Multimediabereichen Anwendung zu finden. 
+Die leistungsf\"ahigere ARM10 Familie bietet eine Vector-Floating-Point Einheit. Der Cortex A8, welcher den ARMv7 Instruktionssatz
+verwendet, betreibt das IPhone 3GS, der Nintendo DS wird auch von einem ARM angetrieben. Diverse Linux-Distributionen laufen auf leistungsf\"ahigeren ARM-Prozessoren.
+Einem Bericht aus 2007 zufolge verwenden zirka 98 Prozent der verkauften Mobiltelefone einen ARM Prozessor (Wikipedia).
+
+%\subsection{Where are processors that implement the ISA deployed? In embedded systems (microcontrollers,
+%communication, multimedia), in servers, in desktop computers?}
+
+%ARM offers a big variety of cores for usage in different areas. 
+%The ARM710 family is designed for usage in hand-helds and multimedia. The more stronger ARM10 family is providing a Vector Floating Point unit.
+%The Cortex A8, which uses the ARMv7 ISA, powers the IPhone 3GS. Many Linux distributions work on stronger ARM processors. 
+%Nintendo DS uses an ARM core.
+%As of 2007, about 98 percent of the more than one billion mobile phones sold each year use at least one ARM processor (Wikipedia).
+
+
+%\subsection{Does the ISA describe an accumulator, a register, or a stack machine and does it describe a CISC or RISC architecture?}
+
+%Except from the Thumb-Version, the instructions have a fixed length of 32 bit and can address one destination and two
+%operand registers at once. ARM offers 31 general-purpose registers, where at any time 16 of them can be addressed by the 
+%register specifiers in the instructions. The other registers are used to speed up the exception processing. 
+%So this describes a register machine with a RISC architecture. 
+
+%Registers R13, R14 and R15 are used as the Stack Pointer (R13), the Link Register (R14) and the Program Counter (R15), 
+%but they can be addressed via the normal instruction set. The Link Register contains the return address in case of a 
+%sub routine call. 
+
+\subsection{Conditional Instructions and Jumps}
+
+Im Vergleich zu \"alteren RISC Architekturen kommt ARM ohne die Verwendung von Branch-Delay-Slots aus, somit sind Latenzen 
+nicht am Software-Level sichtbar. Des weiteren gibt es Predicated Instructions, welche erlauben, dass die Instruktion nur 
+im Falle eines gesetzten Pr\"adikats ausgef\"uhrt wird. ARM verwendet f\"ur nahezu jede Instruktion 4 Bits an Pr\"adikaten. Somit 
+k\"onnen theoretisch 16 verschiedene Ausf\"uhrungsm\"oglichkeiten abgeleitet werden, es werden 15 gen\"utzt.
+Nach dem Testen einer Bedingung (\texttt{CMP}) wird dieses Ergebnis im
+Statusregister vermerkt (zum Beispiel \texttt{CMP R1, R2}).
+Nun kann beispielsweise \texttt{ADDEQ R0, R2, R3} und \texttt{ADDNE R7, R2, R3} folgen, was folgenden Code abbildet:
+\begin{lstlisting}[caption=Beispiel]{}
+if R1 = R2
+       R0 = R2 + R3
+else
+       R7 = R2 + R3
+\end{lstlisting}
+Somit k\"onnen kleine if-Bl\"ocke auf sequenzielle Statements ohne Sprung abgebildet werden.
+Sollte f\"ur eine Instruktion die Kondition nicht erf\"ullt sein wird diese einfach durch ein \texttt{NOP} ersetzt.
+
+Ein m\"ogliches Pr\"adikat ist auch Always, somit wird keine Bedingung im Statusregister gepr\"uft.
+
+%\subsection{Are latencies handled by the hardware or are they visible at the ISA level? For example,
+%branch delay slots expose the latencies of branches at the ISA level.}
+
+%Instead of older RISC Systems ARM doesn't have a branch delay slot, so latencies are not visible at the software level.
+%Conditional instructions allow to implement small if-blocks in a fast and code-decimating way.
+
+%\subsection{Are conditional branches (compute condition and jump) performed in a single step, or
+%are testing and branching unbundled?}
+
+%Every ARM Instruction as a 4-bit condition field at the beginning. The predicated instruction is only executed, when the condition
+%fits to the bits set in the state register. In example the bit vector $(0000)_2$ means equal, $(0001)_2$ means non equal and $(11110)_2$ means always.
+%In case the condition doesn't fit, the instruction is replaced by one NOP.
+%To update the state register a compare instruction is needed. So you first have to test the condition and afterwards
+%you can place as many conditional statements as needed.
+
+\subsection{Ziele}
+
+Da diese Architektur immer h\"aufiger in mobilen Multimediager\"aten eingesetzt wird liegen die Ziele in
+den folgenden Bereichen: Performance, Die Area, Energy Efficiency und Code Size. Die Liste k\"onnte noch weiter
+fortgesetzt werden, dies sind aber die wichtigsten Punkte.
+Energieeffizient ist wichtig f\"ur lange Batterielebenszeiten bzw. das nicht vorhanden sein von diversen K\"uhleinrichtungen. 
+Die Codesize wird durch das Verwenden von Predicated Statements und der Destination + 2 Operanden Register Adressierung pro Befehl
+realisiert. Dieser Punkt wirkt sich auch positiv auf die Performance des Prozessors aus. Allerdings m\"ussen durch die 
+Load/Store Architektur Variablen immer zuerst in Register geladen werden.
+
+%\subsection{What are the goals of the architecture? Performance, die area, energy efficiency, code
+%size, . . .  and how are these goals reflected in the ISA?}
+
+%Because of the extensive use in mobile and multi media devices, the goals are all of the mentioned parts. 
+%Energy efficiency plays a huge role as far as you don't have the posibility to add a cooling device to your smartphone.
+%Code size is reflected in the ISA by using predicated instructions. The code gets much smaller when you don't need to 
+%add a branch for every small if-else-block. The opportunity of accessing 2 operand registers in a computation instruction
+%and the load multiple instruction are increasing the performance of the system.
+
+\subsection{Gut gel\"ost bzw. Verbesserungsw\"urdig}
+
+Das Verwenden von Predicated Statements ist meiner Meinung nach sehr intelligent verwirklicht, da man 
+das Ausf\"uhren eines Befehls von einer breiten Varianz an Bedingungen abh\"angig machen kann. Außerdem 
+ist es durch Verwendung von konditionierten Instruktionen m\"oglich eine konstante Ausf\"uhrungszeit eines Algorithmus zu erzielen.
+
+Ein negativer Aspekt ist das Fehlen von Shift- bzw. Rotate Instruktionen. Diese werden direkt in den einzelnen Befehlen 
+implementiert, man kann solches Verhalten auf einen Operanden einer Anweisung anwenden. Dies hat aber nat\"urlich auch seine Vorteile.
+
+%\subsection{Which features of the ISA do you like, which features would you change?}
+
+%The usage of the predicated statements is very genious, because this firstly smalls the code size and secondly is a very important
+%feature for WCET. It allows you to implement algorithms having a constant execution time, what is very necessary in safety-critical and fault
+%tolerant real time systems. 
+%Barrel shifter (shift as part of an instruction) is great, but a single shift operation is missing.
+
+\subsection{Implementierung des Beispielcodes}
+
+\begin{lstlisting}[caption=ARM Code]{ARM-Code}
+       ; r0 = len
+       ; r1 = ptr to arr
+       ; wenn len=0 return 0
+       cmp r0, #0
+       moveq r0, 0
+       bxeq lr;
+       add r0, r1, r0, LSL#2
+       mov r2, r1
+loop:
+       ldr r3, [r1], #4
+       add r2,r2,r3
+       cmp r1, r0
+       bne loop;
+       mov r0,r2
+       bx lr
+\end{lstlisting}
+Jeder Schleifendurchlauf f\"uhrt ein Load, ein Add, ein Compare und ein Branch-Equal aus.
+Implementiert auf einem ARM7TDMI, dieser verwendet eine dreistufige Pipeline, erhalten wir folgende
+Aussagen \"uber die Clockcycles:
+
+\texttt{ldr} 3, \texttt{add} 1, \texttt{cmp} 1, \texttt{bne} 3, was bedeutet, dass ein Schleifendurchlauf acht Zyklen ben\"otigt (Informationen aus dem Manual des Prozessors entnommen).
+
+Die Anzahl der Instruktionen in der Schleife ist vier, da auch der Sprung zum 
+Schleifenbeginn mitgez\"ahlt wird. Die Codesize der Schleife betr\"agt 16 Byte,
+da jede Instruktion eine L\"ange von 32 Bit hat.