Risc Processor - Arm 9
Risc Processor - Arm 9
1
Salient Features of ARM
2
Salient Features of ARM
1. 32 bit Microcontroller
2. 32 bit ALU
3. 32 bit data bus
0000
0100
1000
1100
3
Salient Features of ARM
4
Salient Features of
ARM
• Harvard model
5
RECAP
• 32 bit microcontroller
• 32 bit ALU
• 32 bit data bus
• 32 bit address bus
• 32 bit long instructions
• HARVARD Model
• 5 stage pipeline
• 7 operating modes
6
ARM ARCHITECTURE
Salient Features of
ARM
• 5 stage Pipelining
User
Fast
Interrupt (FIQ)
• 7 operating
Interrupt (IRQ)
Modes Supervisor
Abort mode
System 10
MAIN FUNCTION OF PROCESSOR/MICROCONTROLLER
Control
unit
• PC is incremented
• Address bus holds the address of memory
• Opcode /data is fetched from memory
after appropriate control signal
• Instruction enters into instruction decoder
and data into
Register
DECODING AN INSTRUCTION
• 16 registers in ARM
REGISTER
Importance of SIGN EXTEND
EXAMPLE:
+7 in binary 0000 0111
-7 in binary 1111 1001
ADD R0,R1,R2
R0=R1+R2
SHIFT 0: y0,y1,y2,y3
SHIFT 1: Y1,Y2,Y3,Y0
• MAC – Multiply and
Accumulate
Multiplier
Multiplicant
• If we need to access subsequent memory
addressing
• No ALU involvement
numbers – No division
RECAP
Instruction Decoder
Sign extend
Register
Multiplier
ALU with shifter Multiplica
nt
MAC
Address register
ARM 9 REGISTERS
Programmers Model
&
OPERATING MODES
OPERATING MODES
(ON SUPERVISOR
RESET)
ort ABORT
Ab
SWI ta
fetch / da
m
Pre gra
IRQ pro
USER MODE
UNDEF
FIQ
System
Calls
SYSTEM
SUPERVISOR MODE:
On reset (when u switch on ARM) - processor enters into supervisor mode
Example: In Mobile phone BIOS – loads OS from Secondary memory to primary memory
then ICONs then control comes to u (USER MODE)
SYSTEM MODE:
• Protection should be there in processor similar to protection in mobile phone
• System program access system data or user data
• User program cannot access system data/program - changing the APP- not permitted
• When ARM is in supervisor mode, we can access system mode and not in user mode
USER MODE:
• 90% of its life time, ARM is in user mode
• Rearranging icon in mobile phone – go to supervisor and then come back to user mode
• Install an app from play store (SWI – ARM goes to supervisor)
• FIQ and IRQ mode - when appropriate interrupt
comes
SUPERVISOR
USER
SYSTEM
ABORT
IRQ
FIQ
UNDEF
ARM REGISTERS – PROGRAMMING MODEL
ARM REGISTERS
• 37 registers
• User mode has 17 registers –
r0 to r15, CPSR
Remaining 20 registers-
• 5 register in FIQ
• 5 new SP
• 5 new LR
• 5 new SPSR
ARM REGISTERS
Normal operation of
stack
-80 +7f
Negative Flag
When overflow happens, positive number looks like
negative number and vice versa
when flag =1
• T- thumb state
Different states of ARM
• Two states in ARM processor – Thumb and Normal
instruction)
256 1KB
instruction MEMO 512
RY instructions
Normal Vs Thumb State
THUMB
More powerful
More cost
More power
consumption
NORMAL
MODES
RECAP
CONTROL
Branch and other
instructions
STRUCTUAL HAZARDS
SOLVE
USING
STALL
DATA HAZARDS
TO
SOLVE
CONTROL/BRANCH HAZARDS
SOLVE USING
STALL
Summarize
• Pipeline Hazards
ARM 9 INSTRUCTION SET
BRANCH INSTRUCTIONS
Branch Descriptions
Instructio
ns
BAL Branch Always (Unconditional
Jump)
BNV Branch Never (NOP) BRANCH
BCS Branch if carry flag is set Instruction sees
the previous
BCC Branch if carry flag is cleared instructions and
Jumps
BVS Brach if overflow flag is set accordingly
BVC Brach if overflow flag is cleared
BMI Branch if MINUS
BPL Branch if POSITIVE
BEQ Branch if equal
BNE Branch if not equal
Branch Descriptions
Instructions
BHI Branch if higher
Compare first with second number. If first number
is greater then jumps
BHS Branch if higher or same
Compare first with second number. If first number
is greater/same then jumps For Signed
BLO Branch if lower numbers
Compare first with second number. If first number
is lesser then jumps
BLS Branch if lower or same
Compare first with second number. If first number
is lesser/same then jumps
BGT Branch if greater
BGE Branch if greater or equal Unsigned
BLT Branch if lesser numbers
BLE Branch if lesser or equal
DATA MOVEMENT/DATA TRANSFER INSTRUCTIONS
INSTRUCTIONS DESCRIPTIONS OPERATIONS
MOV R0,R1 Move the content of R1 to R0. Here R1 R0 R1
and R0 is 32 bit data
ADD R0,R1,R2 Add R1 and R2 and store the result in R0. R0=R1+R2
Here R1,R2,R0 are32 bit . No flags are
affected
ADDS R0,R1,R2 Add R1 and R2 and store the result in R0.
Here R1,R2,R0 are32 bit . Flags are affected
RSCEQS R0,R1,R2 Reverse subtract with carry if carry flag is set in Affects the flag
previous instruction
MUL R0,R1,R2 Multiply R1 and R2 and store in R0 R0=R1*R2 result will be 32 bit
MLA R0,R1,R2, R3 Multiply R1 and R2 and add R3 then store in R0 R0=(R1*R2)+R3 result will be 32 bit
UMLAL R0,R1,R2,R3 Unsigned multiplication and accumulation long (R0, R1)=(R2*R3)+(R0,R1) result will
be 64 bit
SMLAL R0,R1,R2,R3 signed multiplication and accumulation long For signed numbers
LOGICAL INSTRUCTIONS
INSTRUCTIONS DESCRIPTIONS OPERATIONS
AND R0,R1,R2 Logically AND R1 and R2 and store the result in R0=R1 AND R2
R0
ORR R0,R1,R2 Logically OR R1 and R2 and store the result in R0=R1 OR R2
R0
EOR R0,R1,R2 Logically EOR R1 and R2 and store the result in R0=R1 EOR R2
R0
CMP R0,R1 Compare R0 and R1. the content of R0 and R1 Only flags are affected
are not changed . do R0-R1
CMN R0,R1 Compare negate Only flags are affected
Compare R0 and R1. the content of R0 and R1
are not changed . Do R0+R1
LO
W
STACK OPERATION
RECAP
• ARITHMETIC INSTRUCTIONS
• LOGICAL INSTRUCTIONS
• BRANCH INSTRUCTIONS
• STACK INSTRUCTIONS
ARM
ADDRESSING MODES
ADDRESSING MODES OF ARM
ADDRESSING
MODES
Base
Immedi Register Base with
Register Direct Indirect Relative
ate index scaled
index
ADDRESSING MODE: Manner in which
operand is given in the instruction
Operand is in Register
MOV R0, R1
ADD R0, R1, R2
AMOUNT is 12 bit
OFFSET (Variable)
INDIRECT ADDRESSING MODE
• Acess one/two
location – Direct int arr[5] = {1,2,3,4,5};
X=arr[3];
• Access series of if (i=0; i<4; i++)
location - Indirect Y=arr[i];
i++;
REGISTER RELATIVE ADDRESSING MODE
Normal
LDR R0, [R1,#04H]
ADDRESS is given by the
Let R1=2000; register and
R0= [R1+04] but R1 =2000 displacement
then r0<=(r1)+4
Pre Index
Post Index
LDR R0, [R1],#04H]
Load the content of 2000 and then R1 become
2004
then r0<=(r1)+4
Let R1=2000;
R0= [R1] then R1 =2004
BASE INDEXED ADDRESSING MODE
ADDRESS is given
Normal by SUM of two
LDR R0, [R1,R2] registers
Let R1=2000; R2=1000;
R0= [R1+R2] but R1 =2000; R2=1000;
Pre Index
Post Index
LDR R0, [R1], R2
Post Index
LDR R0, [R1], R2, LSL#02H
R0=[0034]
Let R1=0034; R2=12;
R2<<02 = 1200
R0= [R1] then R1=R1+R2<<2
R1=1234
RECAP
ADDRESSING
MODES
Base
Immedi Register Base with
Register Direct Indirect Relative
ate index scaled
index