ARM up2date
authorStefan Rebernig <stefan.rebernig@gmail.com>
Mon, 18 Oct 2010 13:21:11 +0000 (15:21 +0200)
committerStefan Rebernig <stefan.rebernig@gmail.com>
Mon, 18 Oct 2010 13:23:45 +0000 (15:23 +0200)
1_isacmp/arm.tex

index 419a95b01d40d11b80aaba0d00d30b317e9479b4..267b28adb1cc2ce480099d498640b9dcaada4179 100644 (file)
@@ -1 +1,146 @@
 \section{ARM}
+
+ARM wurde anfangs von der Firma ACORN entwickelt und steht für Advanced Risc Machine. Es existieren
+mehrere verschiedene Versionen des Instruktionssatzes, diese Ausarbeitung gibt aber lediglich einen Überblick
+über die prizipiellen Konzepte der Architektur. 
+
+\subsection{Einsatzgebiet}
+
+Im allgemeinen wird bei ARM eine Instruktionslänge von 32 Bits verwendet. Die gekürzte Thumb-Version verwendet lediglich 16 Bit. 
+Es existieren 31 general-purpose Register, 16 davon können direkt über 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 R13, R14 und R15 finden besondere Verwendung. R13 ist der Stack-Pointer, R14 das Link Register und R15 der Program-Counter. 
+Diese Register können allerdings auch über normale Instruktionen beschrieben werden. Das Link-Register beinhaltet die Rücksprungadresse
+im Falle eines Subroutinen-Calls.
+
+ARM bietet eine breite Varianz an Kernen für den Einsatz in verschiedenen Gebieten.
+Beispielsweise ist die ARM710 Familie designed um in Hand-Helds und anderen Multimediabereichen Anwendung zu finden. 
+Die leistungsfähigere 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ähigeren ARM-Prozessoren.
+Einem Bericht aus 2007 zufolge verwenden ca 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 älteren 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ädikats ausgeführt wird. ARM verwendet für nahezu jede Instruktion 4 Bits an Prädikaten. Somit 
+können theoretisch 16 verschiedene Ausführungsmöglichkeiten abgeleitet werden, es werden 15 genützt. 
+Nach dem Testen einer Bedingung (CMP) wird dieses Ergebnis im Statusregister vermerkt (zb CMP R1, R2). 
+Nun kann beispielsweise ADDEQ R0, R2, R3 und ADDNE R7, R2, R3 folgen, was folgenden Code abbildet: 
+
+\begin{lstlisting}[caption=Beispiel]{}
+
+if R1 = R2 then
+       R0 = R2 + R3
+else
+       R7 = R2 + R3
+end if
+
+\end{lstlisting}
+
+Somit können kleine if-Blöcke auf sequenzielle Statements ohne Sprung abgebildet werden.
+Sollte für eine Instruktion die Kondition nicht erfüllt sein wird diese einfach durch ein NOP ersetzt.
+
+Ein mögliches Prädikat ist auch Always, somit wird keine Bedingung im Statusregister geprüft.
+
+%\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äufiger in mobilen Multimediageräten eingesetzt wird liegen die Ziele in
+den folgenden Bereichen: Performance, Die Area, Energy Efficiency und Code Size. Die Liste könnte noch weiter
+fortgesetzt werden, dies sind aber die wichtigsten Punkte. 
+Energieeffizient ist wichtig für lange Batterielebenszeiten bzw. das nicht vorhanden sein von diversen Kühleinrichtungen. 
+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üssen 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öst bzw. Verbesserungswürdig}
+
+Das Verwenden von Predicated Statements ist meiner Meinung nach sehr intelligent verwirklicht, da man 
+das Ausführen eines Befehls von einer breiten Varianz an Bedingungen abhängig machen kann. Außerdem 
+ist es durch Verwendung von konditionierten Instruktionen möglich eine konstante Ausführungszeit 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ürlich 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ührt ein Load, ein Add, ein Compare und ein Branch-Equal aus. 
+
+Implementiert auf einem ARM7TDMI, dieser verwendet eine 3-Stufige Pipeline, erhalten wir folgende
+Aussagen über die Clockcycles:
+
+ldr 3, add 1, cmp 1, bne 3, was bedeutet, dass ein Schleifendurchlauf 8 Zyklen benötigt (Informationen aus dem Manual des Prozessors entnommen).