Arm Processor Fundamentals
Arm Processor Fundamentals
ARM PROCESSOR 2
FUNDAMENTALS
Data
Instruction
decoder
Sign extend
Write Read
rl5 Rd
Register file
10-r15 Result
pc
RnA Rn B
ABAcc
Barrel shilter
MAC
ALU
Address register
Incrementer
Address
instructions copy data from registers to memory. There are no data processing instructions
that directly manipulate data in memory. Thus, data processing is carried out solely in
registers.
Data items are placed in the register file-a storage bank made up of 32-bit registers.
Since the ARM core is a 32-bit processor, most instructions treat the registers as holding
signed or unsigned 32-bit values. The sign extend hardware converts signed 8-bit and 16-bit
numbers to 32-bit values as they are read from memory and placed in aregister.
ARM instructions typically have two source registers, Rn and Rm, anda single result or
destination register, Rd. Source operands are read from the register file using the internal
buses Aand B, respectively.
The ALU (arithmetic logic unit) or MACc (multiply-accumulate unit) takes the regis
ter values Rn and Rm from the Aand Bbuses and computes a result. Data processing
instructions write the result in Rd directly to the register file. Load and store instructions
use the ALU to generate an address to be held in the address register and broadcast on the
Address bus.
2.1 Registers 2l
One important feature of the ARM is that register Rm alternatively can be preprocessed
in the barel shifter before it enters the addresses.
ALU. Together the barrel shifter and ALU Can
calculate a wide range of expressions and reista.
After passing through the functional units, the result in Rdis written back to the acdree
fle using the Result bus. For load and store instructions the incrementer updates the
rerister beforethe core reads or writes the next register value from or to the next sequential
until an exception er
memory location. The processor continues executing instructions
flow.
interrupt changes the normal execution take a more detailed look
Now that you have an overview of the processor core we'll current program status
the registers, the
at some of the key components of the processor:
register (cpsr), and the pipeline.
2.1 REGISTERS
either data or an address. They are identified with the
General-purpose registers hold
number. For example, register 4 is given the label r4.
letter r prefixed to the register
registers available in user mode-a protected
mode normally
Figure 2.2 shows the active
rl
r2
r3
r4
r5
r7
r8
r9
rl0
rll
rl2
rl3 sp
rl4 lr
rl5pc
cpsr
Depending upon the context, registers rl3 and rl4 can also be used as general-purpose
registers, which can be particularly useful since these registers are banked during a processor
mode change. However, it is dangerous to use r13 as a general register when the processor
r13
is running any form of operating system because operating systems often assume that
always points to a valid stack frame.
In ARM state the registers ro to rl3 are orthogona -any instruction that you can apply
instructions
to rOyou can equally well apply to any of theother registers. However, there are
that treat rl4 and rl5 in a special way.
In addition to the 16 data registers, there are two program status registers: cpsr and spsr
(the current and saved program status registers, respectively).
The register file contains all the registers available to a programmer. Which registers are
visible to the programmer depend upon the current mode of the processor.
Mode
Nzlc|v|
User and
System
rl
r2
r3
Fast
r5
r
interrupt
request
r7
r8 r&_fig
r9fiq
rlo rl0_fiqg
Interrupt Abort
rl! rll_fiq request Supervisor Undefined
r12 |r12_fiq r13_undef r13_abt
rl3_irg rl3_svc
rl3 sp r13_fiq rl4_undef rl4 abt
rl4 lr rl4_fig rl4_irq |rl4_svc
rl5 pc
cpsT spsr_abt
spsr_fig| spsr_irq |spsr_svc| spsr_undef
User mode
rl
r2
3
r4
r5
r8
r10 Interrupt
rll request
mode
rl2
rl3 sp rl3_irq
rl4 lr rl4_irg
rl5pc
cpsr
spsr_irq
an exception or interrupt. The following exceptions and interrupts cause a mode change:
reset, interrupt request, fast interrupt request, software interrupt, data abort, prefetch abort,
and undefined instruction. Exceptions and interrupts suspend the normal execution of
sequential instructions and jump to a specific location.
Figure 2.5 illustrates what happens when an interrupt forces a mode change. The figure
shows the core changing from user mode to interrupt request mode, which happens when an
interrupt request occurs due to an external device raising an interrupt to the processor core.
This change causes user registers rl3 and rl4 to be banked. The user registers are replaced
with registers rl3_irq and rl4_irq, respectively. Note rl4_irq contains the return address
and r13_irq contains the stack pointer for interrupt request mode.
Figure 2.5 also shows anew register appearing in interrupt request mode: the saved
program status register (spsr), which stores the previous mode's cpsr. You can see in the
diagram the cpsr being copied into spsr_iq. To return back to user mode, a special return
instruction is used that instructs the core to restore the original cpsr from the spsr_irq and
bank in the user registers r13 and rl4. Note that the spsr can only be modifed and read in a
privileged mode. There is no spsr available in user mode.
Processor Fundamentals
26 Chapter2 ARM
whena
feature to note is that the cpsr is not copied into the spsr
Another important directly to the cpsr. The saving of the
psr
due to a program writing
mode change is forced
or interrupt is raised.
only occurs when an exception active processor mode occupies the five least significant
Figure 2.3 shows that the current which is
power is applied to the core, it starts in supervisor mode, access
bits of the cpsr. When mode is useful since initialization code can
use full
privileged. Starting in a privileged modes.
the stacks for each of the other of
associated binary patterns. The last column
to the çpSr to set up
the various modes and the
Table 2.1 lists of the processor modes in the çpsr.
bit patterns that represent each
the table gives the
SETS
2.2.3 STATE AND INSTRUCTION
three
determines which instruction set is being executed. There are
The state of the core is only active when
instruction sets: ARM, Thumb, and Jazelle. The ARM instruction set when
in ARM state. Similarly the Thumb instruction set is only active
the processor is executing purely
processor is in Thumb, state. Once in Thumb state the processor is
the intermingle sequential ARM, Thumb, and Jazelle
Thumb l6-bit instructions. You cannot
instructions. both
Jazelle J and Thumb Tbits in the cpsr reflect the state of the processor. When the
The instructions. This is
ARM state and executes ARM
Jand Tbits are 0, the processor is in the T bit is 1, then the processor is in
applied to the processor. When
case when power is executes a specialized branch instruction. Table 2.2
Thumb state. To change states the core
set features.
comparesthe ARM and Thumb instruction
instruction set called Jazelle. Jazelle executes
The ARM designers introduced a third
and hardware designed to speed up the
8-bit instructions and is a hybrid mix of software
execution of Java bytecodes. modified
technology plus a specially
To execute Java bytecodes, you require the Jazelleto note that the hardware portion of
version of the Java virtual machine. It is important
bytecodes; the rest are emulated in software.
Jazelle only supports a subset of the Java
2.2
Current Program Status
Register 27
Table 2.2 ARM and Thumb instruction set features.
The Jazelle instruction set is a closed instruction set and is not openly available. Table 2.3
gives the Jazelle instruction set features.
Condition flags are updated by comparisons and the result of ALU operations that specify
the Sinstruction suffix. For example, ifa SUBS Subtract instruction results in aregister value
of zero, then the Zflag in the cpsr is set. This particular subtract instruction speciñcaly
updates the cpsr.
Processor Fundamentals
28 Chapter 2 ARM
31 30 29 28 27 24 76 5 4 0
nzCvq j iF t SVC
Mnemonic Name
Condition flags
EQ equal Z
NE not equal
559z| CS HS
3CC LO
carry set/unsigned higher or same
carry clear/unsigned lower C
C
MI minus/negative N
PlL plus/positive or zero
VS overflow
no overflow
unsigned higher zC
LS unsigned lower or same Zor c
GE signed greater than or equal NVor ny
signed less than Nv or nV
LT
GT signed greater than NzVor nzv
LE signed less than or equal Zor Ny ornV
AL always (unconditional) ignored
can see from the figure the processor is in supervisor (SVC) mode since the mode(4:0] is
equal to binary 10011.
2.3 PIPELINE
Apipeline is the mechanism a RISC processor uses to execute instructions. Using a pipeline
speeds up execution by fetching the next instruction while other instructions are being
decoded and executed. One way to view the pipeline is to think of it as an automobile
assembly line, with each stage carrying out aparticular task to manufacture the vehicle.