Saving Interlocks By Using The Tfr Instruction - Motorola DSP56600 Manual

Application optimization for digital signal processors
Table of Contents

Advertisement

Pipeline Interlocks
Data ALU Pipeline Interlocks
6-6
Optimizing DSP56300/DSP56600 Applications
move
x:(r0)+,bb,y:(r4)+
_end
move
a,y:(r4)+
move
b,y:(r4)+
6.1.2.3

Saving Interlocks by Using the TFR Instruction.

The following C code adds a constant to two memory arrays, one in
X memory space and the other in Y memory space:
static int a[N],b[N];
int i;
for (i=0;i<N;i++)
{
b[i] = b[i]+c;}
for (i=0;i<N;i++)
{
a[i] = a[i]+c;}
The straightforward implementation of the code will execute in 8N
cycles:
move
var_a,r4
move
var_b,r0
move
var_c,x0
do
#N,_1Loop
move
y:(r4),a
add
x0,a
move
a,y:(r4)+
_1Loop
do
#N,_2Loop
move
x:(r0),a
add
x0,a
move
a,x:(r0)+
_2Loop
By combining the two loops into one and using the TFR instruction,
an optimized implementation takes only 1.5 cycles for main loop
iteration summing up to 3N cycles for the whole task:
move
var_a,r4
move
var_b,r0
lua
(r4)+,r5
lua
(r0)+,r1
move
var_c,x1
move
x:(r0),b
add
x1,b
do
#N,_3Loop
add
x1,a
add
x1,b
tfr
y1,a
_3Loop
;previous data
;write destination memory,
;read next data
;write last-1 word to
;destination memory
;write last word to destination
;memory
;a array in Y:memory space
;b array in X:memory space
;constant to add
;handle Y array
;read data word
;add constant
;store result and increment pointer
;handle X array
;read data word
;add constant
;store result and increment
;pointer
x:(r1)+,x0
y:(r4),a
b,x:(r0)+
x0,b
y:(r5)+,y1
x:(r1)+,x0
a,y:(r4)+
;a array in Y memory
;b array in X memory
;r5 = r4 + 1
;r1 = r0 + 1
MOTOROLA

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dsp56300

Table of Contents