Chapter 2 - Architecture of ARM Processor
Chapter 2 - Architecture of ARM Processor
Architecture of ARM
Processor
Chessda Utt raphan, PhD
Chapter
Outline
Processor’s Core Architecture
Programmer’s Model
Memory Organization and Addressing
Instruction Set Architecture (ISA)
© C. Uttraphan
Processor’s Core
Architecture
Program memory
Processor core
Processor core
Data memory
Von Neumann architecture Harvard architecture
© C. Uttraphan
Processor’s Core Architecture
(Cont..)
© C. Uttraphan
Processor’s Core Architecture
(Cont..)
© C. Uttraphan
Processor’s Core Architecture
(Cont..)
© C. Uttraphan
Programmer’s model
© C. Uttraphan
Programmer’s model
(Cont..)
R0
R1
R2
R3 General purpose
Special registers
R4 Registers
(Low registers) xPSR Program status register
R5
PRIMASK
R6
FAULT TMASK Interrupt mask register
R7
BASEPRI
R8
CONTROL
R9 Control register
General purpose
R10 Registers
R11 (High registers)
R12
R13 (MSP) Main Stack Pointer (MSP)
R13 (PSP) Process Stack Pointer (PSP)
R14 (LR) Link Register
R15 (PC) Program Counter
32 bits © C. Uttraphan
Programmer’s model
(Cont..)
© C. Uttraphan
Programmer’s model
(Cont..)
R0 – R12
• Registers R0 to R12 are for general uses.
© C. Uttraphan
Programmer’s model
(Cont..)
Special Register
© C. Uttraphan
Programmer’s model
(Cont..)
© C. Uttraphan
Programmer’s model
(Cont..)
Operation Modes of the Cortex-M3
© C. Uttraphan
Programmer’s model
(Cont..)
Condition Flags
© C. Uttraphan
Programmer’s model
(Cont..)
The N-Flag
This flag is useful when checking for a negative result.
FFFFFFFF
+ FFFFFFFF
FFFFFFFD
© C. Uttraphan
Programmer’s model
(Cont..)
The V-Flag
When performing an operation like addition or subtraction, if we calculate
the V flag as an exclusive OR of the carry bit going into the most significant
bit of the result with the carry bit coming out of the most significant bit,
then the V flag accurately indicates a signed overflow. Overflow occurs if
the result of an add, subtract, or compare is greater than or equal to 231, or
less than –231.
Example:
A1234567
+
B0000000
151234567 © C. Uttraphan
Programmer’s model
(Cont..)
The C-Flag
The C flag will set if an arithmetic operation produce a carry as in example
below
Example:
FFFFFFFF
+ 00000001
100000000
carry
© C. Uttraphan
Programmer’s model
(Cont..)
The Z-Flag
The Z flag will set if an arithmetic operation (can be other operation,
depend on instruction used) produce zero result
Example:
FFFFFFFF
+ 00000001
100000000
32-bit 0
© C. Uttraphan
Memory Organization
© C. Uttraphan
Memory Organization
(Cont..)
• The ARM core consists of 32 bits, meaning that you could address bytes
in memory from address 0 to 232 – 1, or 4,294,967,295 (0xFFFFFFFF),
which is considered to be 4 GB of memory space.
• A memory map is a structure of data (which usually resides in memory
itself) that indicates how memory is laid out.
• Normally not all addresses are used, and much of the memory map
contains areas dedicated to specific functions some of which we’ll
examine further in later chapters. While the memory layout is defined
by an SoC’s implementation, it is not part of the processor core.
© C. Uttraphan
Memory Organization
(Cont..)
© C. Uttraphan
Addressing: Loads and Stores
(Cont..)
© C. Uttraphan
Addressing: Loads and Stores
(Cont..)
© C. Uttraphan
Instruction Set Architecture
(ISA)
• The instructions themselves can be of different lengths, depending on
the processor architecture: 8, 16, or 32 bits long, or even a combination
of these.
• For our studies, the instructions are either 16 or 32 bits long; although,
much later on, we’ll examine how the ARM processors can use some
shorter, 16-bit instructions in combination with the 32-bit instructions.
• Reading and writing a string of 1’s and 0’s can give you a headache
rather quickly, so to aid in programming, a particular bit pattern is
mapped onto an instruction name, or a mnemonic
© C. Uttraphan
Instruction Set Architecture
(ISA)
• Hence, instead of reading
2805
F101010A
F04F0208
• the
programmer
can read
CMP
R0,#5 ADD
R1,#10 MOV
R2,#8 © C. Uttraphan
Instruction Set Architecture
(ISA)
• Consider the bit pattern for the instruction above:
MOV R2, #8
• The pattern is the hex number 0xF04F0208. From Figure below, we can
see that the ARM processor expects parts of our instruction in certain
fields. The number 8, for example, would be placed in the field called
8_bit_immediate, and the instruction itself, moving a number into a
register, is encoded in the field called opcode.
© C. Uttraphan
Instruction Set Architecture
(ISA)
How the microprocessor executes the instruction?
CMP R0,#5 :2805
ADD :F101010A 20000000 0 x 28
R1,#10 MOV :F04F0208 20000001 0 x 05
R2,#8
20000002 0 x F1
PC 0 x 20000002
20000003 0 x 01
20000004 0 x 01
R0 0 x 00000005 20000005 0 x 0A
R1 0 x 00000003 20000006 0 x F0
0 x 00000002
20000007 0 x 4F
R2
20000008 0 x 02
20000009 0 x 08
When the P executes CMP instruction, the PC will point to the next instruction to
be executed © C. Uttraphan
Instruction Set Architecture
(ISA)
How the microprocessor executes the instruction?
CMP R0,#5 :2805
ADD :F101010A 20000000 0 x 28
R1,#10 MOV :F04F0208 20000001 0 x 05
R2,#8
20000002 0 x F1
PC 0 x 20000006
20000003 0 x 01
20000004 0 x 01
R0 0 x 00000005 20000005 0 x 0A
R1 0 x 0000000D 20000006 0 x F0
0 x 00000002
20000007 0 x 4F
R2
20000008 0 x 02
20000009 0 x 08
When the P executes ADD instruction, the PC will point to the next instruction to
be executed © C. Uttraphan
Instruction Set Architecture
(ISA)
How the microprocessor executes the instruction?
CMP R0,#5 :2805
ADD :F101010A 20000000 0 x 28
R1,#10 MOV :F04F0208 20000001 0 x 05
R2,#8
20000002 0 x F1
PC 0 x 2000000A
20000003 0 x 01
20000004 0 x 01
R0 0 x 00000005 20000005 0 x 0A
R1 0 x 0000000D 20000006 0 x F0
0 x 00000008
20000007 0 x 4F
R2
20000008 0 x 02
20000009 0 x 08
When the P executes MOV instruction, the PC will point to the next instruction to
be executed © C. Uttraphan
Instruction Set Architecture
(ISA)
Instruction pipeline
• Instruction pipelining is a technique used in the design of modern
microprocessors, microcontrollers and CPUs to increase their
instruction throughput (the number of instructions that can be
executed in a unit of time).
• The Cortex-M3 processor has a three- pipeline. The
ARM
pipeline stages instruction stage decode,
are
instruction execution. fetch, instruction and
© C. Uttraphan
Instruction Set Architecture
(ISA)
Instruction pipeline
clock
© C. Uttraphan
Instruction Set Architecture
(ISA)
The Thumb-2 Technology
• The original ARM instructions are 32-bit wide, and they the first to be
used on older architectures such as the ARM7TDMI, ARM9, ARM10,
and ARM11.
For list of ARM architecture:
https://en.wikipedia.org/wiki/ARM_architecture
• Thumb instructions (Thumb 1), which are a
subset of ARM instructions,
also work on 32-bit data; however, they are 16
bits wide.
• Thumb-2 is a superset of Thumb instructions, including new 32-bit
instructions for more complex operations. In other words, Thumb-2 is a
combination of both 16-bit and 32-bit instructions.
• Generally, it is left to the compiler or assembler to choose the optimal
size, but a programmer can force the issue if necessary. Some cores,
© C. Uttraphan
such as the Cortex-M3 and M4, only execute Thumb-2 instructions,
Instruction Set Architecture
(ISA)
The Thumb-2 Technology
• The Thumb-2 technology extended the Thumb Instruction Set
Architecture (ISA) into a highly efficient and powerful instruction set
that delivers significant benefits in terms of ease of use, code size, and
performance
© C. Uttraphan
Instruction Set Architecture
(ISA)
ARMv7-M
Architecture
ARMv6-M
Architecture
Binary upwards
compatibility
© C. Uttraphan
Exercise
1. What is the size of the memory for the microprocessor if it has 24-bit
address lines (bus)? Furthermore, give the starting address and the last
address of the memory.
2. List the operation modes of the ARM Cortex-M3.
3. What is the function of register R13? Register R14? Register R15?
4. On an ARM Cortex-M3, in any given mode, how many registers does a
programmer see at one time?
5. Which bits of the ARM Cortex-M3 status registers contain the status
flags?
6. How many stages does the ARM Cortex-M3 pipeline have? Name them.
7. Suppose that the Program Counter, register R15, contained the hex value
0x8000. From what address would an Cortex-M3 fetch an instruction.
Assume that all instructions are 32-bit wide
8. What is the size the ARM Cortex-M3’s address bus?
9. What is Thumb instruction set? What is the different between Thumb-1
and Thumb-2
© C. Uttraphan
Exercise
© C. Uttraphan