EC6703 - Embedded Real Time Systems: 1 8/6/2019 R.M.D.Engineering College
EC6703 - Embedded Real Time Systems: 1 8/6/2019 R.M.D.Engineering College
Dr.D.Rukmanidevi
Professor
R.M.D. Engineering College
Embedding Computers
Characteristics of Embedded
Computing Applications
Why use microprocessors?
Challenges in Embedded Computing
System Design
Performance in Embedded Computing
Software
(Application Programs)
Processor
Coprocessors
ASIC
Converters
sensor sensor
brake brake
hydraulic
ABS
pump
brake brake
sensor sensor
Performance.
Overall speed, deadlines.
Functionality and user interface.
Manufacturing cost.
Power consumption.
Other requirements (physical size, etc.)
requirements
specification
architecture
component
design
system
integration
8/6/2019 R.M.D.Engineering College 31
Top-down vs. bottom-up
Top-down design:
start from most abstract description;
work to most detailed.
Bottom-up design:
work from small components to big system.
Real design uses both techniques.
Functional requirements:
output as a function of input.
Non-functional requirements:
time required to compute output;
size, weight, etc.;
power consumption;
reliability;
Performance -Speed
Cost – Manufacturing Cost and Nonrecurring
Engineering Cost
8/6/2019 R.M.D.Engineering College 35
Our requirements form
name
purpose
inputs
outputs
functions
performance
manufacturing cost
power
physical size/weight
Moving map
obtains position
from GPS, paints I-78
map from local
Scotch Road
database.
lat: 40 13 lon: 32 19
8/6/2019 R.M.D.Engineering College 37
GPS moving map needs
Functionality: For automotive use. Show major
roads and landmarks.
User interface: At least 400 x 600 pixel screen.
Three buttons max. Pop-up menu.
Performance: Map should scroll smoothly. No
more than 1 sec power-up. Lock onto GPS within
15 seconds.
Cost: $120 street price = approx. $30 cost of
goods sold.
Should include:
What is received from GPS;
map data;
user interface;
operations required to satisfy user requests;
background operations needed to keep the
system running.
user
database interface
memory
panel I/O
user
timer
interface
Dr.D.Rukmanidevi
Professor
R.M.D. Engineering College
8/6/2019
ARM 7 PROCESSOR
Processor and Memory Organization
ARM processor was designed by Advanced RISC Machine (ARM) Limited Company.
ARM processors are used for low-power and low cost applications like Mobile
phones, Communication modems, Automotive engine management systems and
Hand-held digital systems. There are different versions of the ARM architecture are
identified by different numbers. ARM7 is a von Neumann architecture machine, while
ARM9 uses Harvard architecture.
The ARM architecture supports
Memory is byte addressable
32-bit addresses
32-bit processor registers
Two operand lengths are used in moving data between the memory and the
processor registers
Bytes (8 bits) and words (32 bits)
Word addresses must be aligned, i.e., they must be multiple of 4
Both little-endian and big-endian memory addressing
When a byte is loaded from memory into a processor register or stored from a
register into the memory always located in the low-order byte position of the register
8/6/2019
8/6/2019
ARM Features
Capable of executing Thumb instruction set
Featuring with IEEE Std. 1149.1 JTAG boundary-scan debugging
interface.
Featuring with a Multiplier-And-Accumulate (MAC) unit for DSP
applications.
Featuring with the support of embedded In-Circuit Emulator.
Three Pipe Stages: Instruction fetch, decode, and Execution.
7 modes of operation (usr, fiq, irq, svc, abt, sys, und)
Simple structure -> reasonably good speed / Low power consumption
High density Code and Smaller die Size
8/6/2019
ARM Pins
ALE –Address Latch Enable DBGACK -Debug acknowledge
ABORT –Memory Abort
DBGEN -Debug enable
APE-Address pipeline enable
ABE-Address bus enable DBGRQ-Debug request
BIGEND -Big endian configuration DBGRQI -Internal debug request
BL[3:0] -Byte latch control
BREAKPT Breakpoint ECLK -External clock output
HIGHZ-High impedance
BUSDIS Bus disable
ISYNC -Synchronous interrupts
BUSEN Data bus configuration MCLK-Memory clock input
CPA -Coprocessor absent MAS –Memory Access size
CPB -Coprocessor busy
DBE -Data bus enable
8/6/2019
Byte organizations within
an ARM word
Bit 31 Bit 0
Word 4
Little-endian
Bit 31 Bit 0
Word 4
Big-endian
8/6/2019
ARM Registers
8/6/2019
ARM Encoding Format
8/6/2019
ARM assembly language
8/6/2019
ARM data instructions
8/6/2019
Example
ADD R0,R1,R2 ---- add [R1]+[R2] and store results into R0.
ADD R0,R1,#2 ----- immediate operands, add [ R1]+ 2 and store
results into R0.
RSB R0, R1,R2 ----- subtract[ R2]-[R1] and store results into R0.
ADD R0, R1, R5, LSL #4 ---- R5 is shifted left 4-bit positions (equivalent to
[R5]x16), and it is then added to the contents of R1; the sum is placed in
R0
8/6/2019
ARM comparison
instructions
CMP : compare
CMN : negated compare
TST : bit-wise test
TEQ : bit-wise negated test
These instructions set only the NZCV bits
of CPSR.
8/6/2019
Example
8/6/2019
ARM move instructions
Example
8/6/2019
ARM load/store
instructions
8/6/2019
ARM ADR pseudo-op
8/6/2019
Example: C assignments
C:
x = (a + b) - c;
Assembler:
ADR r4,a ; get address for a
LDR r0,[r4] ; get value of a
ADR r4,b ; get address for b, reusing r4
LDR r1,[r4] ; get value of b
ADD r3,r0,r1 ; compute a+b
ADR r4,c ; get address for c
LDR r2[r4] ; get value of c
8/6/2019
C assignment, cont’d.
SUB r3,r3,r2 ; complete computation of x
ADR r4,x ; get address for x
STR r3[r4] ; store value of x
8/6/2019
Example: C assignment
C:
y = a*(b+c);
Assembler:
ADR r4,b ; get address for b
LDR r0,[r4] ; get value of b
ADR r4,c ; get address for c
LDR r1,[r4] ; get value of c
ADD r2,r0,r1 ; compute partial result
ADR r4,a ; get address for a
LDR r0,[r4] ; get value of a
8/6/2019
C assignment, cont’d.
MUL r2,r2,r0 ; compute final value for y
ADR r4,y ; get address for y
STR r2,[r4] ; store y
8/6/2019
Example: C assignment
C:
z = (a << 2) | (b & 15);
Assembler:
ADR r4,a ; get address for a
LDR r0,[r4] ; get value of a
MOV r0,r0,LSL 2 ; perform shift
ADR r4,b ; get address for b
LDR r1,[r4] ; get value of b
AND r1,r1,#15 ; perform AND
ORR r1,r0,r1 ; perform OR
8/6/2019
C assignment, cont’d.
ADR r4,z ; get address for z
STR r1,[r4] ; store value for z
8/6/2019
Additional addressing
modes
Base-plus-offset addressing:
LDR r0,[r1,#16]
Loads from location r1+16
Auto-indexing increments base register:
LDR r0,[r1,#16]!
Post-indexing fetches, then does offset:
LDR r0,[r1],#16
Loads r0 from r1, then adds 16 to r1.
8/6/2019
ARM flow of control
8/6/2019
ARM flow of control
8/6/2019
Example: if statement
C:
if (a > b) { x = 5; y = c + d; } else x = c - d;
Assembler:
; compute and test condition
ADR r4,a ; get address for a
LDR r0,[r4] ; get value of a
ADR r4,b ; get address for b
LDR r1,[r4] ; get value for b
CMP r0,r1 ; compare a < b
BGE fblock ; if a >= b, branch to false block
8/6/2019
If statement, cont’d.
; true block
MOV r0,#5 ; generate value for x
ADR r4,x ; get address for x
STR r0,[r4] ; store x
ADR r4,c ; get address for c
LDR r0,[r4] ; get value of c
ADR r4,d ; get address for d
LDR r1,[r4] ; get value of d
ADD r0,r0,r1 ; compute y
ADR r4,y ; get address for y
STR r0,[r4] ; store y
B after ; branch around false block
8/6/2019
If statement, cont’d.
; false block
fblock ADR r4,c ; get address for c
LDR r0,[r4] ; get value of c
ADR r4,d ; get address for d
LDR r1,[r4] ; get value for d
SUB r0,r0,r1 ; compute a-b
ADR r4,x ; get address for x
STR r0,[r4] ; store value of x
after ...
8/6/2019
Example: Conditional
instruction implementation
; true block
MOVLT r0,#5 ; generate value for x
ADRLT r4,x ; get address for x
STRLT r0,[r4] ; store x
ADRLT r4,c ; get address for c
LDRLT r0,[r4] ; get value of c
ADRLT r4,d ; get address for d
LDRLT r1,[r4] ; get value of d
ADDLT r0,r0,r1 ; compute y
ADRLT r4,y ; get address for y
STRLT r0,[r4] ; store y
8/6/2019
Example: switch
statement
C:
switch (test) { case 0: … break; case 1: … }
Assembler:
ADR r2,test ; get address for test
LDR r0,[r2] ; load value for test
ADR r1,switchtab ; load address for switch table
LDR r1,[r1,r0,LSL #2] ; index switch table
switchtab DCD case0
DCD case1
...
8/6/2019
Example: FIR filter
C:
for (i=0, f=0; i<N; i++)
f = f + c[i]*x[i];
Assembler
; loop initiation code
MOV r0,#0 ; use r0 for I
MOV r8,#0 ; use separate index for arrays
ADR r2,N ; get address for N
LDR r1,[r2] ; get value of N
MOV r2,#0 ; use r2 for f
8/6/2019
FIR filter, cont’.d
ADR r3,c ; load r3 with base of c
ADR r5,x ; load r5 with base of x
; loop body
loop LDR r4,[r3,r8] ; get c[i]
LDR r6,[r5,r8] ; get x[i]
MUL r4,r4,r6 ; compute c[i]*x[i]
ADD r2,r2,r4 ; add into running sum
ADD r8,r8,#4 ; add one word offset to array index
ADD r0,r0,#1 ; add 1 to i
CMP r0,r1 ; exit?
BLT loop ; if i < N, continue
8/6/2019
ARM subroutine linkage
8/6/2019
Nested subroutine calls
8/6/2019
Summary
Load/store architecture
Most instructions are RISCy, operate in
single cycle.
Some multi-register operations take longer.
All instructions can be executed
conditionally.
8/6/2019