Professional Documents
Culture Documents
Lecture8 2
Lecture8 2
TMS320C54x
DSP
Architecture and Programming
Andrew Fernandez
April 30, 2001
Why DSP?
Growing Market
Dedicated ASIC not always
best option for implementing
signal processing
Flexibility
Sample Products
JVC GR-DVM90
Digital Camcorder
2
Types of Processing
Continuous / Real - Time
Limited storage
Hard constraints
Offline
Entire signal stored in memory
Softer constraints
May 2, 2001
May 2, 2001
Number Crunching
May 2, 2001
May 2, 2001
Memory
Extl
Mem
I/F
A
D
External
Memory
Pipeline Phases
P - generate program address
F - get opcode
D - decode instruction
A - generate read address
R - read operands
X - execute
P F D A R X
P F D A R X
P F D A R X
P F D A R X
P F D A R X
P F D A R X
Full Pipeline
May 2, 2001
10
Program
RAM?
1400
0000
OVLY
bit
Data
0000
I/O
MMR / RAM
1400
External
memory
External
memory
I/O Memory
9000
Internal or
External
memory
E000
DROM
bit
FF80
FFFF
VECTORS
PAGE 0 (64K)
May 2, 2001
FFFF
External
memory
or Internal
ROM
PAGE 1 (64K)
FFFF
PAGE 2 (64K)
11
0000
DARAM
Block a
DARAM
and SARAM
1480
0000
0400
External
memory
FFFF
May 2, 2001
MMR
0060
0080
DARAM
Block a
SARAM
147F
C54 Architecture and Programming
SPRAM
03FF
12
Assembly!
13
Shorthand Notation
Term
Smem
Xmem
src
What it means
16-bit single data memory operand
16-bit dual data memory operand used in dual-operand instructions
and some single-operand instructions. Read through D bus.
16-bit dual data-memory operand used in dual-operand instructions.
Read through C bus.
16-bit long constant
16-bit immediate data memory address (0 - 65,535)
16-bit immediate program memory address (0 - 65,535)
This includes extended program memory devices
Source accumulator (A or B)
dst
PA
Destination accumulator (A or B)
16-bit port (I/O) immediate address (0 - 65,535)
Ymem
lk
dmad
pmad
May 2, 2001
14
Direct
Absolute
Immediate
MMR
May 2, 2001
15
Syntax
*ARn
Action
no modification to ARn
Affected by:
Increment /
Decrement
*ARn+
*ARn-
post increment by 1
post decrement by 1
Indexed
*ARn+0
*ARn-0
AR0
Circular
*ARn+%
*ARn-%
*ARn+0%
*ARn-0%
BK
Bit-Reversed
*ARn+0B
*ARn-0B
AR0
(=FFT size/2)
Pre-modify
*ARn (lk)
*+ARn (lk)
*+ARn (lk)%
*+ARn
BK
*(lk)
Absolute
May 2, 2001
BK, AR0
16
Indirect Addressing - *
LD
STL
*AR1+,A
A,*AR2+
;...
May 2, 2001
17
#tbl,AR1
#x,AR2
0000h
MMRs
0060h
SPRAM
STM to AR1
# tbl
16 bits
May 2, 2001
007Fh
#tbl is the 16-bit address of
the assembly variable tbl.
2 words, 2 cycles
18
May 2, 2001
;A or B
19
Direct Addressing - @
Instruction
opcode
7-bit offset
Address
9-bit DP
7-bit offset
16 bits
20
#x,DP
LD
ADD
ADD
@x+1,A
@x,A
@x+2,A
= 85h
16-bit address of x
LD @x+1,A
ADD @x,A
= 85h
ADD @x+2,A
= 87h
LD #x, DP
May 2, 2001
21
*( )
A,*(y)
May 2, 2001
22
Modes:
*ARn
*ARn+
*ARn*Arn+0%
Modifiers: BK + AR0
Since the only index offered is circular, regular index is only accessible
if BK is set to 0, or made very large, e.g., FFFFh.
May 2, 2001
23
x0
a0
a1
x1
z-1
a2
x2
z-1
a3
x3
...
y0
19
y 0 = an * xn
n=0
24
Coding Environment
lab1.obj
-o lab1.out
-m lab1.map
Overview
Link.cmd
ROM
MEMORY {
PAGE 1: /* Data Memory */
SPRAM: org=00060h len=0020h
InRAM: org=00400h len=0400h
OutRAM: org=00800h len=0400h
PAGE 0: /* Program Memory */
ROM:
org=0F000h len=0F80h
}
SECTIONS {
code
:>
init
:>
input
:>
output :>
coeff
:>
}
May 2, 2001
ROM
ROM
InRAM
OutRAM
SPRAM
PAGE
PAGE
PAGE
PAGE
PAGE
0
0
1
1
1
code
init_a[20]
C54x
InRAM
x[20]
OutRAM
y[1]
SPRAM
a[20]
x
a
y
.usect input",20
.usect coeff",20
.usect output",1
.sect init
init_a .int
1,2,3,4,5
.int
1,2,3,4,5
.int
1,2,3,4,5
.int
1,2,3,4,5
.mmregs
FIR.asm
.sect "code"
25
Processing Loop
fir:
FIR.asm
math: MAC
*AR2+,*AR3+,A
2. Multiply/Accumulate
MAC *AR2+, *AR3+, A
done:
26
Initialize Pointers
Coefficients
FIR.asm
fir:
AR2
math:
STM
STM
STM
STM
#a,AR2
#a,AR2
#x,AR3
#x,AR3
MAC
*AR2+,*AR3+,A
a0
a1
a2
...
Input Data
AR3
x0
x1
x2
...
STM
done:
May 2, 2001
27
Load Accumulator
FIR.asm
fir:
math:
STM
STM
LD
#a,AR2
#x,AR3
#0,A
MAC
*AR2+,*AR3+,A
location
none
T [5:0] (use TS)
constant (-16 to +16)
done:
dst: A,B,T,DP,ASM
Accumulator A
G
39-32
H
31-16
May 2, 2001
L
15-0
LD:
Loads dst[15:0] by default
May be 1 or 2 cycles
28
Store Result
FIR.asm
fir:
math:
STM
STM
LD
#a,AR2
#x,AR3
#0,A
MAC
STL
*AR2+,*AR3+,A
A, *(y)
done:
none
ASM
constant (-16 to 15)
dst: any memory location
Accumulator A
G
39-32
H
31-16
May 2, 2001
L
15-0
29
Streamline Loops
FIR.asm
fir:
math:
STM
STM
LD
RPT
MAC
STL
#a,AR2
#x,AR3
#0,A
#(20-1)
*AR2+,*AR3+,A
A, *(y)
1. RPT #n
2. RPT Smem
3. RPTZ src,#n
RPT: 1 or 2 cycles
RPTZ: Clears the ACC before
repeating. Always 2 words, 2
cycles
done:
Execute the next block of instructions
n+1 times:
30
Copy Coefficients
FIR.asm
fir:
math:
STM
RPT
MVPD
STM
STM
LD
RPT
MAC
STL
#a, AR2
#3
#(20-1)
#init_a,*AR2+
#a,AR2
#x,AR3
#0,A
#(20-1)
*AR2+,*AR3+,A
A, *(y)
init_a
1
2
3
...
a
1
AR2
done:
May 2, 2001
Prog
Data
MVPD,MVDP
READA,WRITA
MMR
Data
MVMD,MVDM
Data
Data
MVKD,MVDK,MVDD
MMR
MVMM
MMR
31
Program Flow
fir:
math:
done:
STM
RPT
MVPD
STM
STM
LD
RPT
MAC
STL
done:
CALL
RET
fir
2w, 4c
1w, 4c
RET
- or -
Implementing a subroutine
requires:
next
src
src
2w, 4c
1w, 6c
1w, 6c
2w, 3c/5c
2w, 3c/5c
1w, 3c/5c
done
May 2, 2001
32
May 2, 2001
value
value
8 1
double
33
A or B
32 31
Guard
16 15
High
Low
34
Fractional Multiplication
. 9
. 9
. 8 1
. 8
value
times value
yields double size result
result to be stored
May 2, 2001
35
1111 0100
mem
1110
;MANUAL
;AUTO
May 2, 2001
36
AR2
*AR2+,*AR3+0%,A
Input Buffer
a0
x[0]
a1
x[1]
a2
x[2]
...
...
AR3
STM
l
x[n]
BK
...
STM
May 2, 2001
#(N+1),BK
#1,AR0
37
x[0]
x[1]
x[2]
...
x[19]
BK
...
align 32
May 2, 2001
38
Pipeline Issues
Analysis:
C Code
ASM Code
No Problem
Latency requirements
resolved via Latency Tables
CALU Operations
No Problem
MMR Writes
Early Writes
39
References
[1] TMS320C54x Users Guide, available from the Texas Instruments Literature Response Center.
[2] TMS320C54x DSP Design Workshop, Texas Instruments Technical Training.
[3] S. W. Smith, The Scientist and Engineers Guide to Digital Signal Processing, San Diego: California Technical
Publishing, 1999.
[4] Ingrid Verbauwhede, Dave Garrett, Low-Power DSPs for Wireless Communications, ISLPED 2000.
May 2, 2001
40