SlideShare a Scribd company logo
ARMv6-M and ARMv7-M
Architecture Overview
& Programmer’s Model& Programmer’s Model
Agenda
The ARM Architecture
ARM® Cortex®-M Microcontrollers
ARMv7-M Programmer’s Model
2
AAME TechCon 2013
TC001v02
2
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
ARM Ltd
ARM founded in November 1990
– Advanced RISC Machines
Company headquarters in Cambridge, UK
– Processor design centers in Cambridge, Austin, and Sophia Antipolis
– Sales, support, and engineering offices all over the world
3
AAME TechCon 2013
TC001v02
3
Best known for its range of RISC processor cores designs
– Other products – fabric IP, software tools, models, cell libraries - to help partners
develop and ship ARM-based SoCs
ARM does not manufacture silicon
More information about ARM and our offices on our web site:
– http://www.arm.com/aboutarm/
ARM Offices Worldwide
4
AAME TechCon 2013
TC001v02
4
ARM Connected Community –
1000+
5
AAME TechCon 2013
TC001v02
5
More information our new Connected Community website -
http://community.arm.com
Embedded Processors
6
AAME TechCon 2013
TC001v02
6
Application Processors
Cortex-A53Cortex-A53
Cortex-A57Cortex-A57
7
AAME TechCon 2013
TC001v02
7
Example ARM Based System
ARM core deeply embedded within an
SoC
– External debug and trace via JTAG or CoreSight
interface
Design can have both external and
internal memories
– Varying width, speed and size – depending on system
requirements
Can include ARM licensed PrimeCell
ARM
Processor
core
AMBAAXI
External
Memory
Interface
DMA
Port
Clocks and
Reset Controller
DEBUG
FLASH
8
AAME TechCon 2013
TC001v02
8
On chip
memory
Can include ARM licensed PrimeCell
peripherals
– Interrupt controller, since core only has two interrupt
sources
– Other peripherals and interfaces
Can include on-chip memory from ARM
Artisan Physical IP Libraries
Elements connected using AMBA
(Advanced Microcontroller Bus
Architecture)
AMBAAXI
APB
Bridge
AMBAAPB
PrimeCell
Interrupt
Controller
Other
PrimeCell
Peripherals
DEBUG
nIRQ
nFIQ
SDRAM
ARM based
SoC
Custom
Peripherals
Development of the ARM Architecture
v4T
Halfword and
signed halfword
/ byte support
System mode
Improved
ARM/Thumb
Interworking
CLZ
v5TE v6
SIMD Instructions
Multi-processing
v6 Memory architecture
Unaligned data support
v7
Thumb-2
NEON™
TrustZone®
Virtualization
9
AAME TechCon 2013
TC001v02
9
System mode
Thumb
instruction set
CLZ
Saturated arithmetic
DSP multiply-
accumulate
instructions
Extensions
Thumb-2 (v6T2)
TrustZone (v6Z)
Multicore (v6K)
Thumb only (v6-M)
Note that implementations of the same architecture can be different:
ARM Cortex-A8 - architecture v7-A with a 13-stage pipeline
ARM Cortex-A9 - architecture v7-A with an 8-stage pipeline
Architecture Profiles
v7-A (Applications): NEON
v7-R (Real-time): Hardware divide
v7-M (Microcontroller): Hardware
divide, Thumb-only
ARM Architecture Profiles
Application profile (ARMv7-A)
– Memory management support (MMU)
– Highest performance at low power
– Influenced by multi-tasking OS system requirements
– TrustZone and Jazelle-RCT for a safe, extensible system
– e.g. ARM Cortex-A8, ARM Cortex-A9 processors
Real-time profile (ARMv7-R)
10
AAME TechCon 2013
TC001v02
10
Real-time profile (ARMv7-R)
– Protected memory (MPU)
– Low latency and predictability ‘real-time’ needs
– Evolutionary path for traditional embedded business
– e.g. Cortex-R4
Microcontroller profile (ARMv7-M, ARMv6-M)
– Lowest gate count entry point
– Deterministic and predictable behavior a key priority
– Deeply embedded use
– e.g. Cortex-M3
Agenda
The ARM Architecture
ARM Cortex-M Microcontrollers
ARMv7-M Programmer’s Model
11
AAME TechCon 2013
TC001v02
11
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
• ARM Cortex-A15 Processor
• v7-A architecture with extensions
• big.LITTLE™ companion to ARM Cortex-A7
• 600MHz – 1.2GHz @ 2.5DMIPS/MHz
• NEON, Virtualization, LPAE
• ARM Cortex-R7 Processor
• v7-R architecture
The ARM Cortex Processor Family
12
AAME TechCon 2013
TC001v02
12
• v7-R architecture
• High-performance real-time
• 1.6 DMIPS/MHz @ 400MHz
• ECC support, dual-core capable
• ARM Cortex-M0+ Processor
• v6-M architecture
• Embedded microcontroller, integrated NVIC
• 1.25DMIPS/MHz @ 135MHz
• Thumb-2 instruction set
• Programmable entirely in C
ARM Cortex-M Processors
13
AAME TechCon 2013
TC001v02
13
ARMv7-M Profile Overview
v7-M Cores are designed to support the microcontroller market
– Simpler to program – entire application can be programmed in C
– Fewer features needed than in application processors
Register and ISA changes from other ARM cores
– No ARM instruction set support
– Only one set of registers
– xPSR has different bits than CPSR
14
AAME TechCon 2013
TC001v02
14
– xPSR has different bits than CPSR
Different modes and exception models
– Only two modes: Thread mode and Handler mode
– Vector table is addresses, not instructions
– Exceptions automatically save state (r0-r3, r12, lr, xPSR, pc) on the stack
Different system control/memory layout
– Cores have a fixed memory map
– No coprocessor 15 – controlled through memory mapped control registers
Agenda
The ARM Architecture
ARM Cortex-M Microcontrollers
ARMv7-M Programmer’s Model
15
AAME TechCon 2013
TC001v02
15
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
ARMv7-M Register Set
Registers R0-R7
– Accessible to all instructions
Registers R8-R12
– Accessible to a few 16-bit instructions
– Accessible to all 32-bit instructions
R13 is the stack pointer (SP)
R0
R1
R2
R3
R4
R5
R6
R7
16
AAME TechCon 2013
TC001v02
16
R13 is the stack pointer (SP)
– V7-M cores have two banked versions
R14 is the link register (LR)
R15 is the program counter (PC)
xPSR (Program Status Register)
– Not explicitly accessible
– Saved to the stack on an exception
– Subsets available as APSR, IPSR, and EPSR
R8
R9
R10
R11
R12
R15 (PC)
PSR
R13 (SP)
R14 (LR)
R15 (PC)
Program Counter (PC)
The Program Counter (PC) points to the instruction in memory which is to be
loaded next
Changing the PC will change the flow of the program
17
AAME TechCon 2013
TC001v02
17
Link Register (LR)
The Link Register (LR) is used to enable returns from subroutines
void func0 (void)
{
:
func1();
func1func0
18
AAME TechCon 2013
TC001v02
18
Further usage of the LR
It has a special function for exception handling
:
}
<func0>LR
Stack Pointer (SP)
Usage of a stack is to save register contents in memory
– The content stored on a stack can be restored for later usage
The Stack Pointer (SP) points to a memory location – the stack
r13 (SP)r13 (SP)0xABCDABCD
0x12345678
register
0xABCDABCD
19
AAME TechCon 2013
TC001v02
19
0x12345678 r13 (SP)
register
0x12345678
Pop Operation
r13 (SP)
Push Operation 0x12345678 r13 (SP)
r13 (SP)
0xABCDABCD
Memory
xPSR – Program Status Register
APSR - Application Program Status Register
– Only ALU flags
IPSR - Interrupt Program Status Register
– Interrupt/Exception Number
IT/ICIIT
2731
N Z C V Q
28 7
ISR Number
1623 15 0242526 10
T
20
AAME TechCon 2013
TC001v02
20
– Interrupt/Exception Number
ESPR - Execution Program Status Register
– IT field – If/Then block information
– ICI field – Interruptible-Continuable Instruction information
– T bit ( s/b =1, to show core is in Thumb state)
xPSR
– Composite of the 3 PSRs
– Stored on the stack on exception entry
Modes Overview
ARM Processor
Application Code
Thread
Mode
Exception
Entry
Exception
Return
Reset
21
AAME TechCon 2013
TC001v02
21
Exception Code
Handler
Mode
Entry Return
Not shown: Handler mode can also be re-entered on exception return
Privilege, Modes and Stacks
Thread mode and handler mode
– Handler mode is for an exception or interrupt
– Thread mode is for normal application code execution
Privileged/non-privileged operation
– Handler mode is always privileged
22
AAME TechCon 2013
TC001v02
22
– Handler mode is always privileged
– Thread mode can be in privileged or non-privileged mode
Stacks - Main stack and Process stack
– Both stacks have their own stack pointer (r13) register
– Exceptions always use main stack in privileged mode
– Applications (thread mode) can use either main or process stack
Stacks
Two run-time models supported
– Single Stack Pointer – MSP for entire application
– Two Stack Pointers
– MSP for Handler Mode (Exception Handling)
– PSP for Thread Mode (Application Code)
Main Stack Pointer (MSP)
23
AAME TechCon 2013
TC001v02
23
Main Stack Pointer (MSP)
– Used by Thread Mode out of reset
– Initial MSP value is taken from first entry of Vector Table
– Always used by Handler Mode
Process Stack Pointer (PSP)
– Optionally used for Thread Mode
– PSP is enabled using CONTROL.SPSEL
– Must be initialized by user before being used
Agenda
The ARM Architecture
ARM Cortex-M Microcontrollers
ARMv7-M Programmer’s Model
24
AAME TechCon 2013
TC001v02
24
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
Exception Handling
Exception types
– Reset
– Non-maskable Interrupts (NMI)
– Faults
– PendSV
– SVCall
– External Interrupt
25
AAME TechCon 2013
TC001v02
25
– External Interrupt
– SysTick Interrupt
Exceptions processed in Handler mode
– Uses privileged mode
Interrupt handling
– Interrupts are a sub-class of exception
– Automatic save and restore of processor registers ({PC, xPSR, R0-R3, R12, R14)
– Allows handler to be written entirely in ‘C’
External Interrupts
One Non-Maskable Interrupt and up to 240 prioritizable, maskable
interrupts
Tightly integrated Interrupt Controller (NVIC)
Supports tail-chaining, pre-emption and late arrival
26
AAME TechCon 2013
TC001v02
26
Cortex-M3
Processor Core
INTNMI
NVIC
Cortex-M3
1-240 Interrupts
INTISR[239:0]
…
Agenda
The ARM Architecture
ARM Cortex-M Microcontrollers
ARMv7-M Programmer’s Model
27
AAME TechCon 2013
TC001v02
27
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
Instruction Set Support
ARMv7-M cores implement the Thumb Instruction Set with Thumb-2
technology
– Mix of 16-bit and 32-bit instructions – implements almost all of the ARM instruction set
functionality
– Superset of the complete 16-bit Thumb instruction set
– Load/Store instruction set; no direct manipulation of memory contents
– Instruction length can vary, depending on functionality
28
AAME TechCon 2013
TC001v02
28
Two optional architecture extensions are available:
– v7E-M adds DSP instructions
– Currently supported on Cortex-M4
– Single precision floating point instructions
– Currently supported on Cortex-M4 with FPU
(the processor formerly known as Cortex-M4F)
See the Technical Reference Manual (TRM) for the core for more detail
Binary Upwards Compatibility
ARMv7-M
Architecture
29
AAME TechCon 2013
TC001v02
29
ARMv6-M
Architecture
Instruction Set basics
The ARM Architecture is a Load/Store architecture
– Data must be loaded from memory into the CPU, modified, then written back out
– No direct manipulation of memory contents
Instructions consist of
– Opcode, destination register, first source operand, optional second source operand
OPCODE{<qualifier>}{<cond>} Rd, Rm, {Rn}
30
AAME TechCon 2013
TC001v02
30
Thumb Instruction Set
– Optimized for code density from C code (~65% of ARM code size)
– Does not include instructions for processor control (e.g., accessing special registers)
– Subset of the functionality of the full 32-bit ARM instruction set
– Restricted use of registers, constants
– Not intended for assembly coding
Thumb Instruction Set with Thumb-2
– Mix of 16- and 32-bit instructions
– Superset of the traditional Thumb instruction set
– Implements most of ARM instruction set functionality
Instruction Set Examples:
Data Processing:
MOV r2, r5 ; r2 = r5
ADD r5, #0x24 ; r5 = r5 + 36
ADD r2, r3, r4, LSL #2 ; r2 = r3 + (r4 * 4)
LSL r2, #3 ; r2 = r2 * 8
MOVT r9, #0x1234 ; upper halfword of r9 = #0x1234
MLA r0, r1, r2, r3 ; r0 = (r1 * r2) + r3
31
AAME TechCon 2013
TC001v02
31
MLA r0, r1, r2, r3 ; r0 = (r1 * r2) + r3
Memory Access:
STRB r2, [r10, r1] ; store lower byte in r2 at
address {r10 + r1}
LDR r0, [r1, r2, LSL #2] ; load r0 with data at address
{r1 + r2 * 4}
Program Flow:
BL <label> ; PC relative branch to <label>
location, and return address
stored in LR (r14)
Further Instruction Set Information
You should also be familiar with…
– Load and Store Multiple (LDM/STM)
– Supervisor Call (SVC)
– Status Register Access (MSR/MRS)
– Multiply and Divide (MUL/MLA, DIV)
– Bit Manipulation (BFC/BFI etc)
32
AAME TechCon 2013
TC001v02
32
– Bit Manipulation (BFC/BFI etc)
– Loading Constants into Registers (MOVW/MOVT, LDR=)
– Control Flow (CBZ/CBNZ, IT, TBB/TBH)
– Load and Store Exclusive (LDREX/STREX)
– Saturated Arithmetic (QADD etc)
– Sleep Control (WFI/WFE)
All information can be found in the ARMv7-M
Architecture Reference Manual
Thumb Instruction Encoding Choice
When assembling for a Thumb-2 processor there is often a choice of 16-
bit and 32-bit instruction encodings
– The assembler will normally generate 16-bit instructions
Thumb-2 instruction width specifiers
– Allow you to determine which instruction width the assembler will use
– Can be placed immediately after instruction mnemonics:
33
AAME TechCon 2013
TC001v02
33
– .W
– Forces a 32-bit instruction encoding
– .N
– Forces a 16-bit instruction encoding
– Errors raised by assembler if not possible
Disassembly rules
– One-to-one mapping is defined to ensure correct re-assembly
– .W or .N suffix used for cases when a bit pattern which doesn’t follow the above rules
is disassembled
Agenda
The ARM Architecture
Cortex-M Microcontrollers
ARMv7-M Programmer’s Model
34
AAME TechCon 2013
TC001v02
34
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
System Address Map
ARMv7-M is a memory-mapped architecture
– Same address view for physical memory and processor control & status
registers
Memory is divided into 8 x 512MB segments
System
Device
0xFFFFFFFF
35
AAME TechCon 2013
TC001v02
35
Device
Device
RAM
RAM
Peripheral
SRAM
Code 512MB
0x00000000
Memory bus structure
The Bus Matrix partitions memory access via the AHB and PPB
buses
E0000000
E0040000
E0100000
FFFFFFFF
External Peripheral
Debug Components
System (XN)
SCS + NVIC
APB
CM3
Core
Instruction
Data
1GB
36
AAME TechCon 2013
TC001v02
36
Debug
SYSTEM AHB
The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file
again. If the red x still appears, you may have to delete the image and then insert it again.
Bus Matrix
with
Bit- Bander
Aligner
and Patch
Code Space
RAM
Peripheral
External RAM
00000000
20000000
40000000
60000000
A0000000
SYSTEM AHB
DCODE AHB
ICODE AHB
INTERNAL PPB
Debug
HX
EX+BB
EX
BB
½GB
½GB
½GB
1GB
1GB
EX – Code execution support
HX – High performance code execution
BB – Bit banding
Instruction and Data Alignment
Instruction alignment
– Thumb instructions must be 16-bits wide and halfword-aligned
– Thumb-2 instructions are 16 or 32-bits wide and are halfword-aligned
Data alignment
– Core can be configured for optional unaligned data accesses
37
AAME TechCon 2013
TC001v02
37
Instruction fetches in ARM Cortex-M Profile are always little-endian
Data accesses can support both big and little-endian
– Cortex-M3 is switchable at reset
– System Control Space accesses are always little-endian
Memory Types and Properties
There are 3 different memory types
– Normal, Device and Strongly Ordered
Normal memory is the most flexible memory type
– Suitable for different types of memory, for example, ROM, RAM, Flash and SDRAM
– Accesses may be restarted
– Caches and Write Buffers are permitted to work alongside Normal memory
38
AAME TechCon 2013
TC001v02
38
– Caches and Write Buffers are permitted to work alongside Normal memory
Device memory is suitable for peripherals and I/O devices
– Caches are not permitted, but write buffers are still supported
– Unaligned accesses are unpredictable
– Accesses must not be restarted
– Load/store multiple instructions should not be used to access Device memory
Strongly ordered memory is similar to Device memory
– Buffers are not supported and the PPB is marked Strongly Ordered
Address Map Overview
Address Name Memory Type(s) XN Cache Description / Supported Memory
0xE0000000-
0xFFFFFFFF
System Device &
Strongly Ordered
XN - Vendor system region (VENDOR_SYS)
Private Peripheral Bus (PPB)
0xC0000000-
0xDFFFFFFF
Device Device XN - Non-shareable memory
0xA0000000-
0xBFFFFFFF
Device Device, Shareable XN - Shareable memory
0x80000000-
0x9FFFFFFF
RAM Normal - WT Memory with WT cache attributes
39
AAME TechCon 2013
TC001v02
39
0x60000000-
0x7FFFFFFF
RAM Normal - WBWA Write-back, Write-allocate L2/L3
0x40000000-
0x5FFFFFFF
Peripheral Device XN - On-chip peripheral address space
0x20000000-
0x3FFFFFFF
SRAM Normal - WBWA SRAM
On-chip RAM
0x00000000-
0x1FFFFFF
Code Normal - WT ROM
Flash Memory
XN indicates an eXecute Never region
Any attempt to execute code from an XN region faults, generates a HardFault exception
The Cache column indicates the cache policy (write-through or write-back write allocate)
See appendix for more information about caches and cache policies
System Segment
Segment for control & configuration of the processor
– Including resources like NVIC, System Timer or Debug
Top of memory (511MB) can be used for adding
additional implementation-defined system space
0xFFFFFFFF
40
AAME TechCon 2013
TC001v02
40
System
0xFFFFFFFF
0xE0000000
Private Peripheral Bus
(PPB)
0xE0000000
0xE0100000
VENDOR_SYS
Private Peripheral Bus (PPB)
Private Peripheral Bus
(PPB)
0xE0100000
0xE0000000
System Control Space
ROM Table
(Debug Extensions)
4KB
Reserved
0xE00FF000
0xE000F000
41
AAME TechCon 2013
TC001v02
41
The internal PPB is a 1MB region
It is always accessed as little endian
Only supports aligned word accesses
– Byte/halfword or unaligned accesses are not supported
System Control Space
(SCS)
Data Watchpoint & Trace
(Debug Extensions)
Breakpoint Unit
(Debug Extensions)
Reserved
Reserved
0xE000E000
0xE0002000
0xE0001000
0xE0003000
4KB
4KB
4KB
System Control Space (SCS)
4KB address space within the
PPB
Provides arrays of 32-bit
registers
– Configuration
0xE000EF90
Implementation
Defined
0xE000EFD0
Debug
(Debug Extensions) 0xE000EDF0
0xE000EF00
0xE000EFFF
Reserved
Reserved
42
AAME TechCon 2013
TC001v02
42
– Configuration
– Status
– Control
System Control Space
(SCS)
0xE000F000
0xE000E000
0xE000E000
System Control Block
0xE000E010
SysTick
(optional)
0xE000E100
NVIC
0xE000ED00
System Control Block
0xE000ED90Reserved
System Control Block (SCB)
Provides configuration
registers for the
processor
SHPR3
SHCSR
Reserved
DFSR
Reserved
43
AAME TechCon 2013
TC001v02
43
System Control Block
(SCB)
0xE000ED90
0xE000ED00
CPUID
ICSR
Reserved
AIRCR
SCR
CCR
Reserved
SHPR2
SCB Registers Overview
SHPR2
SHPR3
SHCSR
Reserved
DFSR
Reserved
Debug Fault Status Register
System Handler Control and State Register
System Handler Priority Register 3
System Handler Priority Register 2
44
AAME TechCon 2013
TC001v02
44
CPUID
ICSR
Reserved
AIRCR
SCR
CCR
Reserved
SHPR2 System Handler Priority Register 2
System Control Register
Application Interrupt and Reset Control Register
Interrupt Control State Register
CPU Identification
Configuration & Control Register
Agenda
The ARM Architecture
ARM Cortex-M Microcontrollers
ARMv7-M Programmer’s Model
45
AAME TechCon 2013
TC001v02
45
Exceptions & Interrupts
Instruction Set
Memory Model
Power Management
Power Management
Multiple sleep modes supported - controlled through the NVIC
– Sleep Now
– (Wait for interrupt/event) instructions
– Sleep On Exit
– Sleep immediately on return from last ISR
– Deep Sleep
– Long duration sleep, so PLL can be stopped
– Exports additional output signal SLEEPDEEP
46
AAME TechCon 2013
TC001v02
46
– Exports additional output signal SLEEPDEEP
Core may be clock gated in all sleep modes
– Sleep signal is exported allowing external system to be clock gated also
– NVIC interrupt Interface stays awake
Wake-Up Interrupt Controller (WIC)
– External wake-up detector allows core to be fully powered down
– Effective with State-Retention / Power Gating (SRPG) methodology
ARMv6-M and ARMv7-M
Architecture Overview
& Programmer’s Model& Programmer’s Model

More Related Content

What's hot

XPDDS17: Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
XPDDS17:  Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...XPDDS17:  Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
XPDDS17: Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
The Linux Foundation
 

What's hot (20)

ARM Microcontrollers and Embedded Systems-Module 1_VTU
ARM Microcontrollers and Embedded Systems-Module 1_VTUARM Microcontrollers and Embedded Systems-Module 1_VTU
ARM Microcontrollers and Embedded Systems-Module 1_VTU
 
Superscalar and VLIW architectures
Superscalar and VLIW architecturesSuperscalar and VLIW architectures
Superscalar and VLIW architectures
 
XPDDS17: Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
XPDDS17:  Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...XPDDS17:  Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
XPDDS17: Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
 
Introduction to stm32-part1
Introduction to stm32-part1Introduction to stm32-part1
Introduction to stm32-part1
 
Introduction to arm processor
Introduction to arm processorIntroduction to arm processor
Introduction to arm processor
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
ATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part IATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part I
 
ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
Pci express technology 3.0
Pci express technology 3.0Pci express technology 3.0
Pci express technology 3.0
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 
The IEEE 1149.1 Boundary-scan test standard
The IEEE 1149.1 Boundary-scan test standardThe IEEE 1149.1 Boundary-scan test standard
The IEEE 1149.1 Boundary-scan test standard
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
ARM Micro-controller
ARM Micro-controllerARM Micro-controller
ARM Micro-controller
 
ARM Exception and interrupts
ARM Exception and interrupts ARM Exception and interrupts
ARM Exception and interrupts
 
STM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC blockSTM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC block
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
 
Asic design flow
Asic design flowAsic design flow
Asic design flow
 
Arm cm3 architecture_and_programmer_model
Arm cm3 architecture_and_programmer_modelArm cm3 architecture_and_programmer_model
Arm cm3 architecture_and_programmer_model
 
Arm processor
Arm processorArm processor
Arm processor
 

Viewers also liked

CPU Verification Metrics
CPU Verification MetricsCPU Verification Metrics
CPU Verification Metrics
DVClub
 

Viewers also liked (20)

AAME ARM Techcon2013 Intro
AAME ARM Techcon2013 IntroAAME ARM Techcon2013 Intro
AAME ARM Techcon2013 Intro
 
AAME ARM Techcon2013 003v02 Software Development
AAME ARM Techcon2013 003v02  Software DevelopmentAAME ARM Techcon2013 003v02  Software Development
AAME ARM Techcon2013 003v02 Software Development
 
ARM AAE - Architecture
ARM AAE - ArchitectureARM AAE - Architecture
ARM AAE - Architecture
 
ARM AAE - Memory Systems
ARM AAE - Memory SystemsARM AAE - Memory Systems
ARM AAE - Memory Systems
 
Introduction to ARM
Introduction to ARMIntroduction to ARM
Introduction to ARM
 
ARM Processor
ARM ProcessorARM Processor
ARM Processor
 
IBM System x3300 M4
IBM System x3300 M4IBM System x3300 M4
IBM System x3300 M4
 
Arm
ArmArm
Arm
 
IBM System x3650 M4 HD
IBM System x3650 M4 HDIBM System x3650 M4 HD
IBM System x3650 M4 HD
 
CPU Verification Metrics
CPU Verification MetricsCPU Verification Metrics
CPU Verification Metrics
 
Lecture8
Lecture8Lecture8
Lecture8
 
AAME ARM Techcon2013 005v02 System Startup
AAME ARM Techcon2013 005v02 System StartupAAME ARM Techcon2013 005v02 System Startup
AAME ARM Techcon2013 005v02 System Startup
 
ARM AAE - Introduction
ARM AAE - IntroductionARM AAE - Introduction
ARM AAE - Introduction
 
AAME ARM Techcon2013 006v02 Implementation Diversity
AAME ARM Techcon2013 006v02 Implementation DiversityAAME ARM Techcon2013 006v02 Implementation Diversity
AAME ARM Techcon2013 006v02 Implementation Diversity
 
ARM AAE - Developing Code for ARM
ARM AAE - Developing Code for ARMARM AAE - Developing Code for ARM
ARM AAE - Developing Code for ARM
 
AAME ARM Techcon2013 004v02 Debug and Optimization
AAME ARM Techcon2013 004v02 Debug and OptimizationAAME ARM Techcon2013 004v02 Debug and Optimization
AAME ARM Techcon2013 004v02 Debug and Optimization
 
AAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced Features
 
FPGA/Reconfigurable computing (HPRC)
FPGA/Reconfigurable computing (HPRC)FPGA/Reconfigurable computing (HPRC)
FPGA/Reconfigurable computing (HPRC)
 
ARM AAE - System Issues
ARM AAE - System IssuesARM AAE - System Issues
ARM AAE - System Issues
 
ARM AAE - Intrustion Sets
ARM AAE - Intrustion SetsARM AAE - Intrustion Sets
ARM AAE - Intrustion Sets
 

Similar to AAME ARM Techcon2013 001v02 Architecture and Programmer's model

Arm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_armArm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_arm
Prashant Ahire
 

Similar to AAME ARM Techcon2013 001v02 Architecture and Programmer's model (20)

Arm arc-2016
Arm arc-2016Arm arc-2016
Arm arc-2016
 
arm_3.ppt
arm_3.pptarm_3.ppt
arm_3.ppt
 
Arm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_armArm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_arm
 
ARM Versions, architecture
ARM Versions, architectureARM Versions, architecture
ARM Versions, architecture
 
arm 7 microprocessor architecture ans pin diagram.ppt
arm 7 microprocessor architecture ans pin diagram.pptarm 7 microprocessor architecture ans pin diagram.ppt
arm 7 microprocessor architecture ans pin diagram.ppt
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
arm
armarm
arm
 
Arm processors' architecture
Arm processors'   architectureArm processors'   architecture
Arm processors' architecture
 
Arm Processors Architectures
Arm Processors ArchitecturesArm Processors Architectures
Arm Processors Architectures
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Arm Processor
Arm ProcessorArm Processor
Arm Processor
 
Unit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptxUnit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptx
 
Unit2 arm
Unit2 armUnit2 arm
Unit2 arm
 
LPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.pptLPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.ppt
 
Arm corrected ppt
Arm corrected pptArm corrected ppt
Arm corrected ppt
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
Ec8791 arm 9 processor
Ec8791 arm 9 processorEc8791 arm 9 processor
Ec8791 arm 9 processor
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVR
 

Recently uploaded

Paint shop management system project report.pdf
Paint shop management system project report.pdfPaint shop management system project report.pdf
Paint shop management system project report.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

Lect 2 - Design of slender column-2.pptx
Lect 2 - Design of slender column-2.pptxLect 2 - Design of slender column-2.pptx
Lect 2 - Design of slender column-2.pptx
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdf
 
Dairy management system project report..pdf
Dairy management system project report..pdfDairy management system project report..pdf
Dairy management system project report..pdf
 
Paint shop management system project report.pdf
Paint shop management system project report.pdfPaint shop management system project report.pdf
Paint shop management system project report.pdf
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
 
internship exam ppt.pptx on embedded system and IOT
internship exam ppt.pptx on embedded system and IOTinternship exam ppt.pptx on embedded system and IOT
internship exam ppt.pptx on embedded system and IOT
 
Electrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineElectrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission line
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 

AAME ARM Techcon2013 001v02 Architecture and Programmer's model

  • 1. ARMv6-M and ARMv7-M Architecture Overview & Programmer’s Model& Programmer’s Model
  • 2. Agenda The ARM Architecture ARM® Cortex®-M Microcontrollers ARMv7-M Programmer’s Model 2 AAME TechCon 2013 TC001v02 2 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 3. ARM Ltd ARM founded in November 1990 – Advanced RISC Machines Company headquarters in Cambridge, UK – Processor design centers in Cambridge, Austin, and Sophia Antipolis – Sales, support, and engineering offices all over the world 3 AAME TechCon 2013 TC001v02 3 Best known for its range of RISC processor cores designs – Other products – fabric IP, software tools, models, cell libraries - to help partners develop and ship ARM-based SoCs ARM does not manufacture silicon More information about ARM and our offices on our web site: – http://www.arm.com/aboutarm/
  • 4. ARM Offices Worldwide 4 AAME TechCon 2013 TC001v02 4
  • 5. ARM Connected Community – 1000+ 5 AAME TechCon 2013 TC001v02 5 More information our new Connected Community website - http://community.arm.com
  • 8. Example ARM Based System ARM core deeply embedded within an SoC – External debug and trace via JTAG or CoreSight interface Design can have both external and internal memories – Varying width, speed and size – depending on system requirements Can include ARM licensed PrimeCell ARM Processor core AMBAAXI External Memory Interface DMA Port Clocks and Reset Controller DEBUG FLASH 8 AAME TechCon 2013 TC001v02 8 On chip memory Can include ARM licensed PrimeCell peripherals – Interrupt controller, since core only has two interrupt sources – Other peripherals and interfaces Can include on-chip memory from ARM Artisan Physical IP Libraries Elements connected using AMBA (Advanced Microcontroller Bus Architecture) AMBAAXI APB Bridge AMBAAPB PrimeCell Interrupt Controller Other PrimeCell Peripherals DEBUG nIRQ nFIQ SDRAM ARM based SoC Custom Peripherals
  • 9. Development of the ARM Architecture v4T Halfword and signed halfword / byte support System mode Improved ARM/Thumb Interworking CLZ v5TE v6 SIMD Instructions Multi-processing v6 Memory architecture Unaligned data support v7 Thumb-2 NEON™ TrustZone® Virtualization 9 AAME TechCon 2013 TC001v02 9 System mode Thumb instruction set CLZ Saturated arithmetic DSP multiply- accumulate instructions Extensions Thumb-2 (v6T2) TrustZone (v6Z) Multicore (v6K) Thumb only (v6-M) Note that implementations of the same architecture can be different: ARM Cortex-A8 - architecture v7-A with a 13-stage pipeline ARM Cortex-A9 - architecture v7-A with an 8-stage pipeline Architecture Profiles v7-A (Applications): NEON v7-R (Real-time): Hardware divide v7-M (Microcontroller): Hardware divide, Thumb-only
  • 10. ARM Architecture Profiles Application profile (ARMv7-A) – Memory management support (MMU) – Highest performance at low power – Influenced by multi-tasking OS system requirements – TrustZone and Jazelle-RCT for a safe, extensible system – e.g. ARM Cortex-A8, ARM Cortex-A9 processors Real-time profile (ARMv7-R) 10 AAME TechCon 2013 TC001v02 10 Real-time profile (ARMv7-R) – Protected memory (MPU) – Low latency and predictability ‘real-time’ needs – Evolutionary path for traditional embedded business – e.g. Cortex-R4 Microcontroller profile (ARMv7-M, ARMv6-M) – Lowest gate count entry point – Deterministic and predictable behavior a key priority – Deeply embedded use – e.g. Cortex-M3
  • 11. Agenda The ARM Architecture ARM Cortex-M Microcontrollers ARMv7-M Programmer’s Model 11 AAME TechCon 2013 TC001v02 11 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 12. • ARM Cortex-A15 Processor • v7-A architecture with extensions • big.LITTLE™ companion to ARM Cortex-A7 • 600MHz – 1.2GHz @ 2.5DMIPS/MHz • NEON, Virtualization, LPAE • ARM Cortex-R7 Processor • v7-R architecture The ARM Cortex Processor Family 12 AAME TechCon 2013 TC001v02 12 • v7-R architecture • High-performance real-time • 1.6 DMIPS/MHz @ 400MHz • ECC support, dual-core capable • ARM Cortex-M0+ Processor • v6-M architecture • Embedded microcontroller, integrated NVIC • 1.25DMIPS/MHz @ 135MHz • Thumb-2 instruction set • Programmable entirely in C
  • 13. ARM Cortex-M Processors 13 AAME TechCon 2013 TC001v02 13
  • 14. ARMv7-M Profile Overview v7-M Cores are designed to support the microcontroller market – Simpler to program – entire application can be programmed in C – Fewer features needed than in application processors Register and ISA changes from other ARM cores – No ARM instruction set support – Only one set of registers – xPSR has different bits than CPSR 14 AAME TechCon 2013 TC001v02 14 – xPSR has different bits than CPSR Different modes and exception models – Only two modes: Thread mode and Handler mode – Vector table is addresses, not instructions – Exceptions automatically save state (r0-r3, r12, lr, xPSR, pc) on the stack Different system control/memory layout – Cores have a fixed memory map – No coprocessor 15 – controlled through memory mapped control registers
  • 15. Agenda The ARM Architecture ARM Cortex-M Microcontrollers ARMv7-M Programmer’s Model 15 AAME TechCon 2013 TC001v02 15 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 16. ARMv7-M Register Set Registers R0-R7 – Accessible to all instructions Registers R8-R12 – Accessible to a few 16-bit instructions – Accessible to all 32-bit instructions R13 is the stack pointer (SP) R0 R1 R2 R3 R4 R5 R6 R7 16 AAME TechCon 2013 TC001v02 16 R13 is the stack pointer (SP) – V7-M cores have two banked versions R14 is the link register (LR) R15 is the program counter (PC) xPSR (Program Status Register) – Not explicitly accessible – Saved to the stack on an exception – Subsets available as APSR, IPSR, and EPSR R8 R9 R10 R11 R12 R15 (PC) PSR R13 (SP) R14 (LR) R15 (PC)
  • 17. Program Counter (PC) The Program Counter (PC) points to the instruction in memory which is to be loaded next Changing the PC will change the flow of the program 17 AAME TechCon 2013 TC001v02 17
  • 18. Link Register (LR) The Link Register (LR) is used to enable returns from subroutines void func0 (void) { : func1(); func1func0 18 AAME TechCon 2013 TC001v02 18 Further usage of the LR It has a special function for exception handling : } <func0>LR
  • 19. Stack Pointer (SP) Usage of a stack is to save register contents in memory – The content stored on a stack can be restored for later usage The Stack Pointer (SP) points to a memory location – the stack r13 (SP)r13 (SP)0xABCDABCD 0x12345678 register 0xABCDABCD 19 AAME TechCon 2013 TC001v02 19 0x12345678 r13 (SP) register 0x12345678 Pop Operation r13 (SP) Push Operation 0x12345678 r13 (SP) r13 (SP) 0xABCDABCD Memory
  • 20. xPSR – Program Status Register APSR - Application Program Status Register – Only ALU flags IPSR - Interrupt Program Status Register – Interrupt/Exception Number IT/ICIIT 2731 N Z C V Q 28 7 ISR Number 1623 15 0242526 10 T 20 AAME TechCon 2013 TC001v02 20 – Interrupt/Exception Number ESPR - Execution Program Status Register – IT field – If/Then block information – ICI field – Interruptible-Continuable Instruction information – T bit ( s/b =1, to show core is in Thumb state) xPSR – Composite of the 3 PSRs – Stored on the stack on exception entry
  • 21. Modes Overview ARM Processor Application Code Thread Mode Exception Entry Exception Return Reset 21 AAME TechCon 2013 TC001v02 21 Exception Code Handler Mode Entry Return Not shown: Handler mode can also be re-entered on exception return
  • 22. Privilege, Modes and Stacks Thread mode and handler mode – Handler mode is for an exception or interrupt – Thread mode is for normal application code execution Privileged/non-privileged operation – Handler mode is always privileged 22 AAME TechCon 2013 TC001v02 22 – Handler mode is always privileged – Thread mode can be in privileged or non-privileged mode Stacks - Main stack and Process stack – Both stacks have their own stack pointer (r13) register – Exceptions always use main stack in privileged mode – Applications (thread mode) can use either main or process stack
  • 23. Stacks Two run-time models supported – Single Stack Pointer – MSP for entire application – Two Stack Pointers – MSP for Handler Mode (Exception Handling) – PSP for Thread Mode (Application Code) Main Stack Pointer (MSP) 23 AAME TechCon 2013 TC001v02 23 Main Stack Pointer (MSP) – Used by Thread Mode out of reset – Initial MSP value is taken from first entry of Vector Table – Always used by Handler Mode Process Stack Pointer (PSP) – Optionally used for Thread Mode – PSP is enabled using CONTROL.SPSEL – Must be initialized by user before being used
  • 24. Agenda The ARM Architecture ARM Cortex-M Microcontrollers ARMv7-M Programmer’s Model 24 AAME TechCon 2013 TC001v02 24 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 25. Exception Handling Exception types – Reset – Non-maskable Interrupts (NMI) – Faults – PendSV – SVCall – External Interrupt 25 AAME TechCon 2013 TC001v02 25 – External Interrupt – SysTick Interrupt Exceptions processed in Handler mode – Uses privileged mode Interrupt handling – Interrupts are a sub-class of exception – Automatic save and restore of processor registers ({PC, xPSR, R0-R3, R12, R14) – Allows handler to be written entirely in ‘C’
  • 26. External Interrupts One Non-Maskable Interrupt and up to 240 prioritizable, maskable interrupts Tightly integrated Interrupt Controller (NVIC) Supports tail-chaining, pre-emption and late arrival 26 AAME TechCon 2013 TC001v02 26 Cortex-M3 Processor Core INTNMI NVIC Cortex-M3 1-240 Interrupts INTISR[239:0] …
  • 27. Agenda The ARM Architecture ARM Cortex-M Microcontrollers ARMv7-M Programmer’s Model 27 AAME TechCon 2013 TC001v02 27 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 28. Instruction Set Support ARMv7-M cores implement the Thumb Instruction Set with Thumb-2 technology – Mix of 16-bit and 32-bit instructions – implements almost all of the ARM instruction set functionality – Superset of the complete 16-bit Thumb instruction set – Load/Store instruction set; no direct manipulation of memory contents – Instruction length can vary, depending on functionality 28 AAME TechCon 2013 TC001v02 28 Two optional architecture extensions are available: – v7E-M adds DSP instructions – Currently supported on Cortex-M4 – Single precision floating point instructions – Currently supported on Cortex-M4 with FPU (the processor formerly known as Cortex-M4F) See the Technical Reference Manual (TRM) for the core for more detail
  • 29. Binary Upwards Compatibility ARMv7-M Architecture 29 AAME TechCon 2013 TC001v02 29 ARMv6-M Architecture
  • 30. Instruction Set basics The ARM Architecture is a Load/Store architecture – Data must be loaded from memory into the CPU, modified, then written back out – No direct manipulation of memory contents Instructions consist of – Opcode, destination register, first source operand, optional second source operand OPCODE{<qualifier>}{<cond>} Rd, Rm, {Rn} 30 AAME TechCon 2013 TC001v02 30 Thumb Instruction Set – Optimized for code density from C code (~65% of ARM code size) – Does not include instructions for processor control (e.g., accessing special registers) – Subset of the functionality of the full 32-bit ARM instruction set – Restricted use of registers, constants – Not intended for assembly coding Thumb Instruction Set with Thumb-2 – Mix of 16- and 32-bit instructions – Superset of the traditional Thumb instruction set – Implements most of ARM instruction set functionality
  • 31. Instruction Set Examples: Data Processing: MOV r2, r5 ; r2 = r5 ADD r5, #0x24 ; r5 = r5 + 36 ADD r2, r3, r4, LSL #2 ; r2 = r3 + (r4 * 4) LSL r2, #3 ; r2 = r2 * 8 MOVT r9, #0x1234 ; upper halfword of r9 = #0x1234 MLA r0, r1, r2, r3 ; r0 = (r1 * r2) + r3 31 AAME TechCon 2013 TC001v02 31 MLA r0, r1, r2, r3 ; r0 = (r1 * r2) + r3 Memory Access: STRB r2, [r10, r1] ; store lower byte in r2 at address {r10 + r1} LDR r0, [r1, r2, LSL #2] ; load r0 with data at address {r1 + r2 * 4} Program Flow: BL <label> ; PC relative branch to <label> location, and return address stored in LR (r14)
  • 32. Further Instruction Set Information You should also be familiar with… – Load and Store Multiple (LDM/STM) – Supervisor Call (SVC) – Status Register Access (MSR/MRS) – Multiply and Divide (MUL/MLA, DIV) – Bit Manipulation (BFC/BFI etc) 32 AAME TechCon 2013 TC001v02 32 – Bit Manipulation (BFC/BFI etc) – Loading Constants into Registers (MOVW/MOVT, LDR=) – Control Flow (CBZ/CBNZ, IT, TBB/TBH) – Load and Store Exclusive (LDREX/STREX) – Saturated Arithmetic (QADD etc) – Sleep Control (WFI/WFE) All information can be found in the ARMv7-M Architecture Reference Manual
  • 33. Thumb Instruction Encoding Choice When assembling for a Thumb-2 processor there is often a choice of 16- bit and 32-bit instruction encodings – The assembler will normally generate 16-bit instructions Thumb-2 instruction width specifiers – Allow you to determine which instruction width the assembler will use – Can be placed immediately after instruction mnemonics: 33 AAME TechCon 2013 TC001v02 33 – .W – Forces a 32-bit instruction encoding – .N – Forces a 16-bit instruction encoding – Errors raised by assembler if not possible Disassembly rules – One-to-one mapping is defined to ensure correct re-assembly – .W or .N suffix used for cases when a bit pattern which doesn’t follow the above rules is disassembled
  • 34. Agenda The ARM Architecture Cortex-M Microcontrollers ARMv7-M Programmer’s Model 34 AAME TechCon 2013 TC001v02 34 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 35. System Address Map ARMv7-M is a memory-mapped architecture – Same address view for physical memory and processor control & status registers Memory is divided into 8 x 512MB segments System Device 0xFFFFFFFF 35 AAME TechCon 2013 TC001v02 35 Device Device RAM RAM Peripheral SRAM Code 512MB 0x00000000
  • 36. Memory bus structure The Bus Matrix partitions memory access via the AHB and PPB buses E0000000 E0040000 E0100000 FFFFFFFF External Peripheral Debug Components System (XN) SCS + NVIC APB CM3 Core Instruction Data 1GB 36 AAME TechCon 2013 TC001v02 36 Debug SYSTEM AHB The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again. Bus Matrix with Bit- Bander Aligner and Patch Code Space RAM Peripheral External RAM 00000000 20000000 40000000 60000000 A0000000 SYSTEM AHB DCODE AHB ICODE AHB INTERNAL PPB Debug HX EX+BB EX BB ½GB ½GB ½GB 1GB 1GB EX – Code execution support HX – High performance code execution BB – Bit banding
  • 37. Instruction and Data Alignment Instruction alignment – Thumb instructions must be 16-bits wide and halfword-aligned – Thumb-2 instructions are 16 or 32-bits wide and are halfword-aligned Data alignment – Core can be configured for optional unaligned data accesses 37 AAME TechCon 2013 TC001v02 37 Instruction fetches in ARM Cortex-M Profile are always little-endian Data accesses can support both big and little-endian – Cortex-M3 is switchable at reset – System Control Space accesses are always little-endian
  • 38. Memory Types and Properties There are 3 different memory types – Normal, Device and Strongly Ordered Normal memory is the most flexible memory type – Suitable for different types of memory, for example, ROM, RAM, Flash and SDRAM – Accesses may be restarted – Caches and Write Buffers are permitted to work alongside Normal memory 38 AAME TechCon 2013 TC001v02 38 – Caches and Write Buffers are permitted to work alongside Normal memory Device memory is suitable for peripherals and I/O devices – Caches are not permitted, but write buffers are still supported – Unaligned accesses are unpredictable – Accesses must not be restarted – Load/store multiple instructions should not be used to access Device memory Strongly ordered memory is similar to Device memory – Buffers are not supported and the PPB is marked Strongly Ordered
  • 39. Address Map Overview Address Name Memory Type(s) XN Cache Description / Supported Memory 0xE0000000- 0xFFFFFFFF System Device & Strongly Ordered XN - Vendor system region (VENDOR_SYS) Private Peripheral Bus (PPB) 0xC0000000- 0xDFFFFFFF Device Device XN - Non-shareable memory 0xA0000000- 0xBFFFFFFF Device Device, Shareable XN - Shareable memory 0x80000000- 0x9FFFFFFF RAM Normal - WT Memory with WT cache attributes 39 AAME TechCon 2013 TC001v02 39 0x60000000- 0x7FFFFFFF RAM Normal - WBWA Write-back, Write-allocate L2/L3 0x40000000- 0x5FFFFFFF Peripheral Device XN - On-chip peripheral address space 0x20000000- 0x3FFFFFFF SRAM Normal - WBWA SRAM On-chip RAM 0x00000000- 0x1FFFFFF Code Normal - WT ROM Flash Memory XN indicates an eXecute Never region Any attempt to execute code from an XN region faults, generates a HardFault exception The Cache column indicates the cache policy (write-through or write-back write allocate) See appendix for more information about caches and cache policies
  • 40. System Segment Segment for control & configuration of the processor – Including resources like NVIC, System Timer or Debug Top of memory (511MB) can be used for adding additional implementation-defined system space 0xFFFFFFFF 40 AAME TechCon 2013 TC001v02 40 System 0xFFFFFFFF 0xE0000000 Private Peripheral Bus (PPB) 0xE0000000 0xE0100000 VENDOR_SYS
  • 41. Private Peripheral Bus (PPB) Private Peripheral Bus (PPB) 0xE0100000 0xE0000000 System Control Space ROM Table (Debug Extensions) 4KB Reserved 0xE00FF000 0xE000F000 41 AAME TechCon 2013 TC001v02 41 The internal PPB is a 1MB region It is always accessed as little endian Only supports aligned word accesses – Byte/halfword or unaligned accesses are not supported System Control Space (SCS) Data Watchpoint & Trace (Debug Extensions) Breakpoint Unit (Debug Extensions) Reserved Reserved 0xE000E000 0xE0002000 0xE0001000 0xE0003000 4KB 4KB 4KB
  • 42. System Control Space (SCS) 4KB address space within the PPB Provides arrays of 32-bit registers – Configuration 0xE000EF90 Implementation Defined 0xE000EFD0 Debug (Debug Extensions) 0xE000EDF0 0xE000EF00 0xE000EFFF Reserved Reserved 42 AAME TechCon 2013 TC001v02 42 – Configuration – Status – Control System Control Space (SCS) 0xE000F000 0xE000E000 0xE000E000 System Control Block 0xE000E010 SysTick (optional) 0xE000E100 NVIC 0xE000ED00 System Control Block 0xE000ED90Reserved
  • 43. System Control Block (SCB) Provides configuration registers for the processor SHPR3 SHCSR Reserved DFSR Reserved 43 AAME TechCon 2013 TC001v02 43 System Control Block (SCB) 0xE000ED90 0xE000ED00 CPUID ICSR Reserved AIRCR SCR CCR Reserved SHPR2
  • 44. SCB Registers Overview SHPR2 SHPR3 SHCSR Reserved DFSR Reserved Debug Fault Status Register System Handler Control and State Register System Handler Priority Register 3 System Handler Priority Register 2 44 AAME TechCon 2013 TC001v02 44 CPUID ICSR Reserved AIRCR SCR CCR Reserved SHPR2 System Handler Priority Register 2 System Control Register Application Interrupt and Reset Control Register Interrupt Control State Register CPU Identification Configuration & Control Register
  • 45. Agenda The ARM Architecture ARM Cortex-M Microcontrollers ARMv7-M Programmer’s Model 45 AAME TechCon 2013 TC001v02 45 Exceptions & Interrupts Instruction Set Memory Model Power Management
  • 46. Power Management Multiple sleep modes supported - controlled through the NVIC – Sleep Now – (Wait for interrupt/event) instructions – Sleep On Exit – Sleep immediately on return from last ISR – Deep Sleep – Long duration sleep, so PLL can be stopped – Exports additional output signal SLEEPDEEP 46 AAME TechCon 2013 TC001v02 46 – Exports additional output signal SLEEPDEEP Core may be clock gated in all sleep modes – Sleep signal is exported allowing external system to be clock gated also – NVIC interrupt Interface stays awake Wake-Up Interrupt Controller (WIC) – External wake-up detector allows core to be fully powered down – Effective with State-Retention / Power Gating (SRPG) methodology
  • 47. ARMv6-M and ARMv7-M Architecture Overview & Programmer’s Model& Programmer’s Model