ARM K
ARM K
ARM K
1
What Is ARM?
Advanced RISC Machine
2
ARM Powered Products
3
Features
Architectural simplicity
which allows
Very small implementations
which result in
Very low power consumption
4
The History of ARM
Developed at Acorn Computers Limited,
of Cambridge, England,
between 1983 and 1985
Problems with CISC:
Slower than memory parts
Clock cycles per instruction
5
ARM Architecture
Typical RISC architecture:
Large uniform register file
Load/store architecture
Simple addressing modes
Uniform and fixed-length instruction fields
6
ARM Architecture (2)
Enhancements:
Each instruction controls the ALU and shifter
Auto-increment
and auto-decrement addressing modes
Multiple Load/Store
Conditional execution
7
ARM Architecture (3)
Results:
High performance
Low code size
Low power consumption
Low silicon area
8
9
Pipeline Organization
Increases speed –
most instructions executed in single cycle
Versions:
3-stage (ARM7TDMI and earlier)
5-stage (ARMS, ARM9TDMI)
6-stage (ARM10TDMI)
10
Pipeline Organization (2)
3-stage pipeline: Fetch – Decode - Execute
Three-cycle latency,
one instruction per cycle throughput
i
n
s
t i Fetch Decode Execute
r
u Fetch Decode Execute
i+1
c
t
i i+2 Fetch Decode Execute
o cycle
n
t t+1 t+2 t+3 t+4 11
Pipeline Organization (3)
5-stage pipeline: Stages:
Reduces work per cycle =>
allows higher clock frequency Fetch
reduction of CPI
Decode
(average number
of clock Cycles Per Instruction) Execute
Buffer/data
Write-back
12
Pipeline Organization (4)
Pipeline flushed and refilled on branch,
causing execution to slow down
Special features in instruction set
eliminate small jumps in code
to obtain the best flow through pipeline
13
Operating Modes
Seven operating modes:
User
Privileged:
System (version 4 and above)
FIQ
IRQ
Abort exception modes
Undefined
Supervisor
14
Operating Modes (2)
User mode: Exception modes:
Normal program Entered
execution mode upon exception
System resources Full access
unavailable to system resources
Mode changed Mode changed freely
by exception only
15
ARM Registers
16
ARM Registers (2)
Special roles:
Hardware
R14 – Link Register (LR):
optionally holds return address
for branch instructions
R15 – Program Counter (PC)
Software
R13 - Stack Pointer (SP)
17
ARM Registers (3)
Current Program Status Register (CPSR)
Saved Program Status Register (SPSR)
On exception, entering mod mode:
CPSR SPSR_mod
R13, R14 replaced by R13_mod, R14_mod
In case of FIQ mode R7 – R12 also replaced
18
ARM Registers (4)
System & User FIQ Supervisor Abort IRQ Undefined
R0 R0 R0 R0 R0 R0
R1 R1 R1 R1 R1 R1
R2 R2 R2 R2 R2 R2
R3 R3 R3 R3 R3 R3
R4 R4 R4 R4 R4 R4
R5 R5 R5 R5 R5 R5
R6 R6 R6 R6 R6 R6
R7 R7_fiq R7 R7 R7 R7
R8 R8_fiq R8 R8 R8 R8
R9 R9_fiq R9 R9 R9 R9
R10 R10_fiq R10 R10 R10 R10
R11 R11_fiq R11 R11 R11 R11
R12 R12_fiq R12 R12 R12 R12
R13 R13_fiq R13_svc R13_abt R13_irq R13_und
R14 R14_fiq R14_svc R14_abt R14_irq R14_und
R15 (PC) R15 (PC) R15 (PC) R15 (PC) R15 (PC) R15 (PC)
CPSR CPSR CPSR CPSR CPSR CPSR
SPSR_fiq SPSR_svc SPSR_abt SPSR_irq SPSR_und
19
Instruction Set
Two instruction sets:
ARM
Standard 32-bit instruction set
THUMB
16-bit compressed form
Code density better than most CISC
Dynamic decompression in pipeline
20
ARM Instruction Set
Features:
Load/Store architecture
3-address data processing instructions
Conditional execution
Load/Store multiple registers
Shift & ALU operation in single clock cycle
21
ARM Instruction Set (3)
Data processing
instructions
Data transfer
instructions
Block transfer
instructions
Branching instructions
Multiply instructions
Software interrupt
instructions
22
Data Processing Instructions
Arithmetic and logical operations
3-address format:
Two 32-bit operands
(op1 is register, op2 is register or immediate)
32-bit result placed in a register
Barrel shifter for op2 allows full 32-bit shift
within instruction cycle
23
Data Processing Instructions (2)
Arithmetic operations:
ADD, ADDC, SUB, SUBC, RSB, RSC, MUL, MLA
logical operations:
AND, EOR, ORR, BIC, LSL, LSR, ASL, ASR, ROR,
RRX
Register movement operations:
MOV, MVN
Comparison operations:
TST, TEQ, CMP, CMN
24
Data Processing Instructions (3)
Conditional codes
+
Data processing instructions
+
Barrel shifter
=
Powerful tools for efficient coded programs
25
Data Processing Instructions (4)
Conditional execution:
Each data processing instruction
prefixed by condition code
Result – smooth flow of instructions through pipeline
16 condition codes:
unsigned signed greater
EQ equal MI negative HI GT
higher than
positive or unsigned lower signed less
NE not equal PL LS LE
zero or same than or equal
unsigned
signed greater
CS higher or VS overflow GE AL always
than or equal
same
unsigned signed less special
CC VC no overflow LT NV 26
lower than purpose
Data Processing Instructions (5)
e.g.:
if (z==1) R1=R2+(R3*4)
compiles to
( SINGLE INSTRUCTION ! )
27
Data Transfer Instructions
Load/store instructions
Used to move signed and unsigned
Word, Half Word and Byte to and from registers
Can be used to load PC
(if target address is beyond branch instruction range)
to selected GPR R7
CPSR MSR R8
MRS moves contents SPSR
from selected GPR R14
to CPSR/SPSR R15
Only in privileged
modes
30
Thumb Instruction Set
Compressed form of ARM
Instructions stored as 16-bit,
Decompressed into ARM instructions and
Executed
Lower performance (ARM 40% faster)
Higher density (THUMB saves 30% space)
Optimal – “interworking”
(combining two sets) – compiler
supported
31
The End
32