Motorola DSP56600 Manual page 31

Application optimization for digital signal processors
Table of Contents

Advertisement

Program Control
Hardware Loops
3-2
A common programming technique is known as "loop unrolling",
in which a high-level loop is replaced by the inner loop code,
repeated N times, thus saving the time needed to decrement the
counter, test for the end of the loop, and jumping back to the top.
From the above explanation, it follows that this technique is less
efficient in the DSP56300/DSP56600 family—the hardware executes
loops normally at the same speed as unrolled code (except for the
initializing DO instruction itself, which takes 5 cycles). Loops
should be unrolled only when the 5-cycle initialization is
meaningful in comparison to the total loop length, especially if this
loop is nested in another loop and the 5-cycle delay is multiplied.
See the example in Section 7.1.1 on page 7-1.
High-level "for" loops are normally implemented in assembly with
the DO instruction. The instructions DO FOREVER and BRKcc
(break on condition) may be used to implement high-level "while"
or "repeat" loops efficiently. The following example is a wave
generator that sends data to a peripheral (Host Interface HI08 in this
example) until a hardware interrupt (IRQA) sets a flag, signalling
the end of the loop. The core drives the HI08 transmitter by polling
the HTDE (Host Transmitter Data Empty) bit in the HI08 status
register. The C high-level code may look like:
while (!flag){
a1 = next_wave_value();
wait_until_transmitter_empty();
send_data(a1);
}
and in Assembler:
org
bset
org
...
move
move
bclr
do forever,_END_LOOP
brkcs
jsr
_WAIT
jclr
btst
movep
_END_LOOP
Optimizing DSP56300/DSP56600 Applications
p:I_IRQA
;IRQA_ interrupt vector
#0,x:<FLAG
;occupies 2 words
p:MAIN_PROGRAM
#0,x0
x0,x:FLAG
;clear FLAG register
#0,sr
;clear carry bit
;break loop if carry bit set
NEXT_WAVE_VALUE;new value returned in a1
#0,x:M_SSR,_WAIT;wait until transmitter empty
#0,x:FLAG
;set carry by flag value
a1,x:M_HTX
;transmit data to host.
MOTOROLA

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dsp56300

Table of Contents