enabling the arm learning in india arm workshop on blueboard part-1 by b. vasu dev [email protected]

42
Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev [email protected]

Upload: jason-francis

Post on 13-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

ARM Workshop on Blueboard

Part-1By

B. Vasu Dev [email protected]

Page 2: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Workshop Overview

Enabling the ARM Learning in INDIA

Day 1 ARM Arch Tools setup Blueboard Programming Intro

Day 2 ARM Programming

TIMER/COUNT, PWM

UART, Interrupts, I2C

Day 3 ARM Programming

SPI, ADC, DAC, RTC,

Watchdog Timer

Day 4Modules Programming

GSM, GPS, Zigbee, SD Card, Bluetooth, Smartcard, Robotics

Page 3: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

DAY-1

Enabling the ARM Learning in INDIA

AGENDA

Introduction

Pipeline

Registers

Exception Modes

Instruction Sets

Page 4: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

INTRODUCTION

Page 5: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

What is ARM?

Enabling the ARM Learning in INDIA

The ARM is a 32-bit reduced instruction set

computer (RISC) instruction set architecture (ISA)

developed by ARM Holdings.

ARM also known as Advance RISC Machine

Page 6: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Why ARM?

Enabling the ARM Learning in INDIA

Simplicity is the key philosophy behind the ARM design

RISC machine with small instruction set and consequently a small gate count.

High Performance

Low power consumption

Small amount of silicon die area.

Open Source Development Tools

Page 7: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Where is ARM?

Enabling the ARM Learning in INDIA

Page 8: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

History

Enabling the ARM Learning in INDIA

Founded in November 1990

Spun out of Acorn Computers

Designs the ARM range of RISC processor cores

Licenses ARM core designs to semiconductor partners who

fabricate and sell to their customers.

ARM does not fabricate silicon itself

Also develop technologies to assist with the design-in of the

ARM architecture

Software tools, boards, debug hardware,

application

software, bus architectures, peripherals etc

Page 9: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Core Family

Enabling the ARM Learning in INDIA

Application Cores Embedded Cores Secure Cores

ARM720T ARM7EJ-S SecureCore SC100

ARM920T ARM7TDMI SecureCore SC110

ARM922T ARM7TDMI-S SecurCore SC200

ARM926EJ-S ARM946E-S SecurCore SC210

ARM1020E ARM966E-S

ARM1022 ARM968E-S

ARM1026EJ-S ARM996HS

ARM11 MPCore ARM1026EJ-S

ARM1136J(F)-S ARM1156T2(F)-S

ARM1176JZ(F)-S ARM Cortex-M0

ARM Cortex-A8 ARM Cortex-M1

ARM Cortex-A9 ARM Cortex-M3

Page 10: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Core Family

Enabling the ARM Learning in INDIA

T: ThumbD: On-chip debug supportM: Enhanced multiplierI: Embedded ICE hardwareT2: Thumb-2S: Synthesizable codeE: Enhanced DSP instruction setJ: JAVA support, JazelleZ: Should be TrustZone?F: Floating point unitH: Handshake, clockless design for synchronous orasynchronous design

Page 11: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Core Family

Enabling the ARM Learning in INDIA

ARM processor core + cache + MMU = ARM CPU cores

ARM6 → ARM7– 3-stage pipeline– Keep its instructions and data in the same memory system– Thumb 16-bit compressed instruction set– On-chip Debug support, enabling the processor to halt in response to a debug request– Enhanced Multiplier, 64-bit result– Embedded ICE hardware, give on-chip breakpoint and watchpoint support

Page 12: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Core Family

Enabling the ARM Learning in INDIA

ARM8 → ARM9 → ARM10ARM9– 5-stage pipeline (130 MHz or 200MHz)– Using separate instruction and data memory ports

ARM 10 (1998. Oct.)– High performance, 300 MHz– Multimedia digital consumer applications– Optional vector floating-point unit

ARM11 (2002 Q4)–8-stage pipeline– Addresses a broad range of applications in the wireless, consumer, networking and automotive segments–Support media accelerating extension instructions–Can achieve 1GHz & Support AXI

Page 13: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Architecture Versions

Enabling the ARM Learning in INDIA

Version 1– The first ARM processor, developed at Acorn Computers Limited 1983-1985– 26-bit address, no multiply or coprocessor supportVersion 2– Sold in volume in the Acorn Archimedes and A3000 products– 26-bit addressing, including 32-bit result multiply and coprocessorVersion 2a– Coprocessor 15 as the system control coprocessor to manageCache– Add the atomic load store (SWP) instructionVersion 3– First ARM processor designed by ARM Limited (1990)– ARM6 (macro cell), ARM60 (stand-alone processor) ARM600 (an integrated CPU with on-chip cache, MMU, write buffer) ARM610 (used in Apple Newton)– 32-bit addressing, separate CPSR and SPSRs– Add the undefined and abort modes to allow coprocessor emulation and virtual memory support in supervisor mode

Page 14: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Architecture Versions

Enabling the ARM Learning in INDIA

Version 3M– Introduce the signed and unsigned multiply and multiplyaccumulateinstructions that generate the full 64-bit resultVersion 4– Add the signed, unsigned half-word and signed byte load and store instructions– Reserve some of SWI space for architecturally defined operation– System mode is introducedVersion 4T– 16-bit Thumb compressed form of the instruction set is introducedVersion 5T– Introduced recently, a superset of version 4T adding the BLX, CLZ and BRK instructionsVersion 5TEAdd the signal processing instruction set extension

Page 15: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Architecture Versions

Enabling the ARM Learning in INDIA

Version 6– Media processing extensions (SIMD) • 2x faster MPEG4 encode/decode

• 2x faster audio DSP

– Improved cache architecture• Physically addressed caches• Reduction in cache flush/refill• Reduced overhead in context switches

– Improved exception and interrupt handling• Important for improving performance in real-time tasks

– Unaligned and mixed-endian data support• Simpler data sharing, application porting and saves memory

Page 16: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Architecture Versions

Enabling the ARM Learning in INDIA

Version7

Page 17: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

SA-110

ARM7TDMI

4T

1Halfword and signed halfword / byte support

System mode

Thumb instruction set

2

4

ARM9TDMI

SA-1110

ARM720T ARM940T

Improved ARM/Thumb Interworking

CLZ

5TE

Saturated maths

DSP multiply-accumulate instructions

XScale

ARM1020E

ARM9E-S

ARM966E-S

3

Early ARM architectures

ARM9EJ-S

5TEJ

ARM7EJ-S

ARM926EJ-S

Jazelle

Java bytecodeexecution

6

ARM1136EJ-S

ARM1026EJ-S

SIMD Instructions

Multi-processing

V6 Memory architecture (VMSA)

Unaligned data support

Development of theARM Architecture

Enabling the ARM Learning in INDIA

Page 18: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM Cores & Arch Ver

Enabling the ARM Learning in INDIA

Page 19: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

The Pipeline

Page 20: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Three Stage Pipeline

Enabling the ARM Learning in INDIA

The pipeline is used to overcome the delay caused by instruction fetching and decoding before execution.

Page 21: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Three Stage Pipeline

Enabling the ARM Learning in INDIA

Fetch – The instruction is fetched from memory and placed in the instruction pipelineDecode – The instruction is decoded and the data path control signals prepared for the next cycleExecute – The register bank is read, an operand shifted, the ALU result generated and written back into destination register

The three stage pipeline has hardware independent stages that execute one instruction while decoding a second and fetching a third.

PC runs 8 bytes ahead of current execution instruction since it holds the address of the fetching instruction but not the current execution instruction.

0x4000 LDR PC,[PC,#4] results PC => 0x400C not 0x4004

Page 22: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Processor Modes

Enabling the ARM Learning in INDIA

User : Normal program execution state

FIQ : Data transfer state (fast irq, DMA-type transfer)

IRQ : Used for general interrupt services

Supervisor : Protected mode for operating system support

Abort : Selected when data or instruction fetch is aborted

Undef : Selected when undefined instruction is fetched

System : Operating system ‘privilege’-mode for user

Page 23: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

Registers

Page 24: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Registers

Enabling the ARM Learning in INDIA

ARM has 37 registers all of which are 32-bits long.

-1 dedicated program counter

-1 dedicated current program status register

-5 dedicated saved program status registers

-30 general purpose registers

Page 25: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Registers

Enabling the ARM Learning in INDIA

Page 26: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Registers

Enabling the ARM Learning in INDIA

Condition code flagsN = Negative result from ALU Z = Zero result from ALUC = ALU operation Carried outV = ALU operation Overflowed

Sticky Overflow flag - Q flagArchitecture 5TE/J onlyIndicates if saturation has occurred

J bitArchitecture 5TEJ onlyJ = 1: Processor in Jazelle state

Interrupt Disable bits.I = 1: Disables the IRQ.F = 1: Disables the FIQ.

T BitArchitecture xT onlyT = 0: Processor in ARM stateT = 1: Processor in Thumb state

Mode bitsSpecify the processor mode

Page 27: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

Exception Handling

Page 28: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Exception Handling

Enabling the ARM Learning in INDIA

When an exception occurs, the ARM: Copies CPSR into SPSR_<mode> Sets appropriate CPSR bits Change to ARM state Change to exception mode Disable interrupts (if appropriate) Stores the return address in LR_<mode> Sets PC to vector address

To return, exception handler needs to: Restore CPSR from SPSR_<mode> Restore PC from LR_<mode>

Page 29: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Exception Handling

Enabling the ARM Learning in INDIA

Page 30: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

Instruction Set

Page 31: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Instruction Set

Enabling the ARM Learning in INDIA

ARM’s implement two types of instruction sets

32-bit ARM Instruction Set

16-bit Thumb Instruction Set

Page 32: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM (32bit) IS

Enabling the ARM Learning in INDIA

Page 33: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

ARM (32bit) IS

Enabling the ARM Learning in INDIA

Every ARM (32 bit) instruction is conditionally executed.

The top four bits are ANDed with the CPSR condition codes, If they do not matched the

instruction is executed as NOP

The AL condition is used to execute the instruction irrespective of the value of the condition

code flags. By default, data processing instructions do not affect the condition code flags but the flags can be optionally set by using “S”. Ex: SUBS r1,r1,#1

Conditional Execution improves code density and performance by reducing the number of

forward branch instructions.Normal Conditional CMP r3,#0 CMP r3,#0 BEQ skip ADDNE r0,r1,r2 ADD r0,r1,r2skip

Page 34: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Condition Codes

Enabling the ARM Learning in INDIA

Each ARM (32bit) Instruction can be prefixed with any of the following conditional code.

Page 35: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Condition Codes

Enabling the ARM Learning in INDIA

Examples:

Set the flags, then use various condition codesif (a==0) x=0;if (a>0) x=1;

CMP r0,#0MOVEQ r1,#0MOVGT r1,#1

Page 36: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Branch instructions

Enabling the ARM Learning in INDIA

B Basic branch instruction used to jump forward or backward of up to 32 MB.BL Branch and Link instruction jumps to the destination and stores a return address in R14 (Link Register).BX, BLX Branch, Brach Link and Exchange.

This swaps the instruction sets from ARM to THUMB and vice versa while jumping.BXJ Branch and change to Jazelle state.

Page 37: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Data Processing Inst.

Enabling the ARM Learning in INDIA

Arithmetic: ADD ADC SUB SBC RSB RSCLogical: AND ORR EOR BICComparisons: CMP CMN TST TEQData movement:MOV MVN

Page 38: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Multiply Instructions

Enabling the ARM Learning in INDIA

MUL, MLA

MULL, MLAL

Page 39: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Data Transfer Inst.

Enabling the ARM Learning in INDIA

Simple Data Transfer Inst. LDR STR Word LDRB STRB Byte LDRH STRH Halfword LDRSB Signed byte load LDRSH Signed halfword load

Load / Store Multiple RegistersLDMSTM

Page 40: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Swap Instruction

Enabling the ARM Learning in INDIA

Are also called as semaphore instructions

SWP R12, R10, [R9] ; load R12 from address R9 and ; store R10 to address R9

SWPB R3, R4, [R8] ; load byte to R3 from address R8 and ; store byte from R4 to address R8SWP R1, R1, [R2] ; Exchange value in R1 and address in R2

Page 41: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Miscellaneous Inst.

Enabling the ARM Learning in INDIA

Software Interrupt 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.Ex. SWI #3

PSR Transfer InstructionsMRS and MSR allow contents of CPSR / SPSR to be transferred to / from a general purpose register.

MRS{<cond>} Rd,<psr> ; Rd = <psr> MSR{<cond>} <psr[_fields]>,Rm ; <psr[_fields]> = Rm

Page 42: Enabling the ARM Learning in INDIA ARM Workshop on Blueboard Part-1 By B. Vasu Dev vasu@easyarm.com

Enabling the ARM Learning in INDIA

?