Arm Overview
Arm Overview
Arm Overview
T TM
R1 L
Agenda
Introduction to ARM Ltd Programmers Model Instruction Set System Design Development Tools
TM
ARM Ltd
Licenses ARM core designs to semiconductor partners who fabricate and sell to their customers.
Also develop technologies to assist with the design-in of the ARM architecture
Software tools, boards, debug hardware, application software, bus architectures, peripherals etc
TM
TM
TM
Intellectual Property
RTL and synthesis flows GDSII layout soft views include gate level netlists hard views are DSMs to protect ARM IP
TM
Agenda
TM
Byte means 8 bits Halfword means 16 bits (two bytes) Word means 32 bits (four bytes)
TM
Processor Modes
TM
FIQ
r8 r9 r10 r11 r12 r13 (sp) r14 (lr)
IRQ
SVC
Undef
Abort
spsr
spsr
spsr
spsr
spsr
TM
10
10
FIQ
IRQ
SVC
Undef
Abort
r15 (pc)
cpsr spsr spsr spsr spsr spsr
11
11
The Registers
1 dedicated program counter 1 dedicated current program status register 5 dedicated saved program status registers 30 general purpose registers
The current processor mode governs which of several banks is accessible. Each mode can access
a particular set of r0-r12 registers a particular r13 (the stack pointer, sp) and r14 (the link register, lr) the program counter, r15 (pc) the current program status register, cpsr
TM
12
12
N Z C V Q f
n s
e x
I F T c
mode
N = Negative result from ALU Z = Zero result from ALU C = ALU operation Carried out V = ALU operation oVerflowed
T Bit
Mode bits
J bit
TM
13
13
All instructions are 32 bits wide All instructions must be word aligned Therefore the pc value is stored in bits [31:2] with bits [1:0] undefined (as instruction cannot be halfword or byte aligned).
All instructions are 16 bits wide All instructions must be halfword aligned Therefore the pc value is stored in bits [31:1] with bit [0] undefined (as instruction cannot be byte aligned).
All instructions are 8 bits wide Processor performs a word access to read 4 instructions at once
TM
14
14
Exception Handling
Change to ARM state Change to exception mode Disable interrupts (if appropriate)
Stores the return address in LR_<mode> Sets PC to vector address Restore CPSR from SPSR_<mode> Restore PC from LR_<mode>
Reset
Vector Table
Vector table can be at 0xFFFF0000 on ARM720T and on ARM9/10 family devices
TM
15
15
4
SA-110 SA-1110
1 2 3
Early ARM architectures
5TE
Jazelle
5TEJ
ARM926EJ-S ARM1026EJ-S
4T
ARM9TDMI ARM940T
ARM1136EJ-S
TM
16
16
Agenda
TM
17
17
ARM instructions can be made to execute conditionally by postfixing them with the appropriate condition code field.
This improves code density and performance by reducing the number of forward branch instructions.
CMP BEQ ADD skip r3,#0 skip r0,r1,r2 CMP r3,#0 ADDNE r0,r1,r2
By default, data processing instructions do not affect the condition code flags but the flags can be optionally set by using S. CMP does not need S.
loop SUBS r1,r1,#1 BNE loop
TM
18
18
Condition Codes
EQ NE CS/HS CC/LO MI PL VS VC HI LS GE LT GT LE AL
39v10 The ARM Architecture
TM
19
19
TM
20
20
Branch instructions
31
28 27
25 24 23
Cond
1 0 1 L
Offset
Link bit
Condition field
The processor core shifts the offset field left by 2 positions, sign-extends it and adds it to the PC
TM
Consist of :
RSB
RSC
These instructions only work on registers, NOT memory. Syntax: <Operation>{<cond>}{S} Rd, Rn, Operand2
Comparisons set flags only - they do not specify Rd Data movement does not specify Rn
TM
22
22
Destination
Multiplication by a power of 2
Destination
Division by a power of 2
CF
23
23
Barrel Shifter
Immediate value
ALU
Result
39v10 The ARM Architecture
TM
24
24
The data processing instruction format has 12 bits available for operand2
11 rot x2 8 7 immed_8 0
Quick Quiz:
Shifter ROR
4 bit rotate value (0-15) is multiplied by two to give range 0-30 in steps of 2
Rule to remember is 8-bits shifted by an even number of bit positions.
TM
25
25
Examples:
31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
range 0-0x000000ff step 0x00000001 range 0-0xff000000 step 0x01000000 range 0-0x000003fc step 0x00000004
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
The assembler converts immediate values to the rotate form: MOV r0,#4096 ; uses 0x40 ror 26 ADD r1,r2,#0xFF0000 ; uses 0xFF ror 16
The bitwise complements can also be formed using MVN: MOV r0, #0xFFFFFFFF ; assembles to MVN r0,#0 Values that cannot be generated in this way will cause an error.
TM
26
26
To allow larger constants to be loaded, the assembler offers a pseudoinstruction: LDR rd, =const This will either: Produce a MOV or MVN instruction to generate the value (if possible). or
Generate a LDR instruction with a PC-relative address to read the constant from a literal pool (Constant data area embedded in the code).
=> =>
TM
27
27
Multiply
Syntax:
MUL{<cond>}{S} Rd, Rm, Rs MLA{<cond>}{S} Rd,Rm,Rs,Rn [U|S]MULL{<cond>}{S} RdLo, RdHi, Rm, Rs [U|S]MLAL{<cond>}{S} RdLo, RdHi, Rm, Rs
Cycle time
+1 cycle for ARM9TDMI (over ARM7TDMI) +1 cycle for accumulate (not on 9E though result delay is one cycle longer) +1 cycle for long
Above are general rules - refer to the TRM for the core you are using for the exact details
TM
28
28
Syntax:
e.g. LDREQB
TM
29
29
Address accessed
Address accessed by LDR/STR is specified by a base register plus an offset For word and unsigned byte accesses, offset can be
TM
30
30
r0 0x5 0x5
Base Register
0x200
0x200
r0 0x5
r1
0x200
0x200
0x5
TM
31
31
IA
LDMxx r10, {r0,r1,r4} STMxx r10, {r0,r1,r4}
Base Register (Rb) r10
r4 r1 r0
IB
r4 r1 r0
DA
DB
r4 r1 r0 r4 r1 r0
Increasing Address
TM
32
32
Cond
1 1 1 1
Condition Field
Causes an exception trap to the SWI hardware vector The SWI handler can examine the SWI number to decide what operation has been requested. By using the SWI mechanism, an operating system can implement a set of privileged operations which applications running in user mode can request. Syntax: SWI{<cond>} <SWI number>
TM
33
33
N Z C V Q f
n s
e x
I F T c
mode
MRS and MSR allow contents of CPSR / SPSR to be transferred to / from a general purpose register.
Syntax:
MRS{<cond>} Rd,<psr> ; Rd = <psr> MSR{<cond>} <psr[_fields]>,Rm ; <psr[_fields]> = Rm <psr> = CPSR or SPSR [_fields] = any combination of fsxc MSR{<cond>} <psr_fields>,#Immediate
where
In User Mode, all bits can be read but only the condition flags (_f) can be written.
TM
34
34
B <label>
PC relative. 32 Mbyte range. Stores return address in LR Returning implemented by restoring the PC from LR For non-leaf functions, LR will have to be stacked
BL <subroutine>
func1
: : BL func1 : :
func2
: : : :
STMFD sp!,{regs,lr}
: BL func2 : LDMFD sp!,{regs,pc}
:
MOV pc, lr
TM
35
35
Thumb
Optimised for code density from C code (~65% of ARM code size) Improved performance from narrow memory Subset of the functionality of the ARM instruction set Switch between ARM and Thumb using BX instruction
ADDS r2,r2,#1
0
31
Conditional execution is not used Source and destination registers identical Only Low registers used Constants are of limited size Inline barrel shifter not used
15
ADD r2,#1
36
36
Agenda
TM
37
37
16 bit RAM
32 bit RAM
Interrupt Controller
nIRQ nFIQ
Peripherals
I/O
8 bit ROM
ARM Core
TM
38
38
AMBA
Arbiter Reset
ARM
TIC Bridge External ROM External RAM Bus Interface Timer
Remap/ Pause
Decoder
Interrupt Controller
AMBA
ACT
ADK
PrimeCell
TM
39
39
Agenda
Development Tools
TM
40
40
Debug Tools
AXD (part of ADS) Trace Debug Tools Multi-ICE Multi-Trace
Platforms
ARMulator (part of ADS) Integrator Family
TM
41
41
EmbeddedICE Logic
JTAG port
Trace Port
Provides breakpoints and processor/system access Converts debugger commands to JTAG signals Compresses real-time instruction and data access trace Contains ICE features (trigger & filter logic) Captures trace in a deep buffer
TM
TAP controller
ETM
EmbeddedICE Logic
ARM core
42
42