Lecture05_TheArmCortexM4ProcessorArchitecture
Lecture05_TheArmCortexM4ProcessorArchitecture
Processor Architecture
Syllabus
This module will cover the following topics
Widely used in mobile and IoT devices, e.g., smartphones, connected cars, wearables
Arm does not manufacture, but it licenses designs to semiconductor companies, who add their own
intellectual property (IP) on top of Arm’s IP
Arm also offers IP other than for processors, such as physical IPs, interconnect IPs, graphics cores, and
development tools.
• Energy-efficiency
• Lower energy cost, longer battery life
• Smaller code
• Lower silicon costs
• Ease of use
• Faster software development and reuse
• Embedded applications
• Smart metering, human interface devices, automotive and industrial
control systems, consumer products (white goods, home automation,
wearables, etc.), and medical instrumentation
Cortex-M4 Armv7E-M Harvard Entire Entire 1 cycle Yes Yes Yes Optional
Cortex-M7 Armv7E-M
Harvard Entire Entire 1 cycle Yes Yes Yes Optional
• Supported interrupts
• Non-maskable interrupt (NMI) + 1 to 240 physical interrupts
• 8 to 256 interrupt priority levels
• Enhanced determinism
• The critical tasks and interrupt routines can be served quickly in a known number of cycles
• Configurable system timer (SysTick) to trigger periodic interrupts
• Sleep modes
• Up to 240 wake-up interrupts
• Integrated wait for interrupt (WFI) and wait for event (WFE) instructions, and sleep on exit capabilities
• Sleep & deep sleep signals
• Optional retention mode with Arm Power Management Kit
• Debug
• Optional JTAG & serial-wire debug (SWD) ports
• Up to eight breakpoints and four watchpoints
• Enhanced instructions
• Hardware divide (2–12 cycles)
• Single-cycle 16, 32-bit multiply-with-accumulate (MAC) instructions, single-cycle dual 16-bit MAC
• Optimizes 8, 16-bit single instruction, multiple data (SIMD) arithmetic
• Saturating arithmetic and optional floating-point unit (FPU)
Optional FPU
Nested Vector Optional
Optional
Interrupt WIC
Interrupt Embedded
Controller Processor core
components (NVIC)
Trace Macrocell
Optional
Optional Memory Optional Serial
Debug
protection unit Wire Viewer
Access Port
Real-time
Optional Optional program
Flash Data
patch Data watchpoints tracing
tracing
Bus matrix
SRAM and
Code interface
peripheral interface
Memory interfaces
14 © 2020 Arm Limited
Cortex-M4 block diagram
• Processor core
• Contains internal registers, the ALU, data path, and some control logic
• Registers include sixteen 32-bit registers for both general and special usage.
Time
15 © 2020 Arm Limited
Cortex-M4 block diagram
• NVIC
• Up to 240 interrupt request signals and an NMI
• Automatically handles nested interrupts, such as comparing priorities between interrupt requests and
the current priority level
• WIC
• For low-power applications, the microcontroller can enter sleep mode by shutting down most of the
components.
• When an interrupt request is detected, the WIC can inform the power management unit to power up
the system.
• MPU (optional)
• Used to protect memory content, e.g., make some memory regions read-only or preventing user
applications from accessing privileged application data
• Bus interconnect
• Allows data transfer to take place on different buses simultaneously
• Provides data transfer management, e.g., write buffer, bit-oriented operations (bit-band)
• May include bus bridges (e.g., AHB-to-APB bus bridge) to connect different buses into a network using
a single global memory space
• Includes the internal bus system, the data path in the processor core, and the AHB-Lite interface unit.
• Debug subsystem
• Handles debug control, program breakpoints, and data watchpoints
• When a debug event occurs, it can put the processor core in a halted state, so that developers can
analyze the status of the processor, including register values and flags, at a particular point.
Cortex-M4 registers
• Register bank
• Sixteen 32-bit registers (thirteen are used for general-purpose)
• Special registers
R5
General-purpose
R6
register
R7
R8
R9
R10 High
Registers
R11
R12 MSP
SP R13 (banked) Main SP
LR R14 PSP
PC R15 Process SP
Special registers Program Status Registers (PSR) x PSR APSR EPSR IPSR
PRIMASK Application Execution Interrupt
PSR PSR PSR
Interrupt mask register FAULTMASK
BASEPRI
Stack definition CONTROL
• R13: SP SP
High
• Records the current address of the stack PC
• Used for saving the context of a program while switching between tasks Heap
• Cortex-M4 has two SPs: Main SP, used in applications that require
privileged access, e.g., OS kernel, and Process SP, used in base-level
application code (when not running an exception handler)
Code
PUSH POP
• PC
• Records the address of the current instruction code Low
• Automatically incremented by four at each operation (for 32-bit instruction Stack Address
code), except branching operations
SP
• A branching operation, such as function calls, will change the PC to a High
specific address, while saving the current PC to the LR. PC
Heap
Code
• R14: LR
• The LR is used to store the return address of a subroutine or a function call.
• The PC will load the value from LR after a function is finished.
Current PC Current LR
PC LR
1. Save current Main Main
PC to LR Program Program
Code region
code Load PC with the code
Code region
LR
address in LR to
return to the
2. Load PC with main program
the starting
address of the
subroutine subroutine
subroutine Current PC
PC
APSR N Z C V Q Reserved
• IPSR
• Interrupt service routine (ISR) number: current executing ISR number
• EPSR
• T: Thumb state: always one since Cortex-M4 only supports the Thumb state
• IC/IT: Interrupt-Continuable Instruction (ICI) bit, IF-THEN instruction status bit