rptb outer_loop-1
; for(k 0; k < N;k) {
mov #TWOPIN (#16, AC0 ; hi(AC0) 2*PI/N
mpy T2, AC0
mov #0, *(angle)
mov AC0, T3
; angle 2*PI*k/N
rptb inner_loop-1
; for(n 0 ; n < N;n) {
mov *(angle), T0
; T0 2*PI*k*n/N
mov *(angle), AC0
add T3, AC0
mov AC0, *(angle)
; Update angle
amov #Wn, XAR0
; AR0 is the pointer to Wn
call sine_cos
; sine_cos(angle, Wn)
inner_loop
add #1,T2
outer_loop
4.6.2 Experiment 4B ± Complex Data Operation
For the experiment,the complex data and twiddle factor vectors are arranged
in order of the real and the imaginary pairs. That is,the input array
Xin [2N] fX
r
, X
i
, X
r
, X
i
, F F Fg and the twiddle factor [2] fW
r
, W
i
g. The computa-
tion of (4.6.3) is implemented in C as follows:
Xr [n] 0;
Xi [n] 0;
for(n 0; n < N ; n)
{
Xr [n] Xr [n] Xin [n]*Wr Xin [n 1]*Wi;
Xi [n] Xi [n] Xin [n 1]*Wr À Xin [n]*Wi;
}
The C55x assembly program implementation of (4.6.3) is listed as follows:
mov
#0, AC2
mov
#0, AC3
rptb
inner_loop-1
macm40 *AR5, *AR0, AC2
; Xin [n]*Wr
macm40 *AR5À, *AR0, AC3 ; Xin [n1]*Wr
masm40 *AR5, *AR0, AC3
; Xi [k] Xin [n1]*Wr À Xin [n]*Wi
macm40 *AR5, *AR0À, AC2 ; Xr [k] Xin [n]*Wr Xin [n1]*Wi
inner_loop
Because the DFT function accumulates N intermediate results,the possible overflow
during computation should be considered. The instruction masm40 enables the use of
accumulator guard bits that allow the intermediate multiply±accumulate result to be
handled in a 40-bit accumulator. Finally,we can put all the pieces together to complete
the routine,as listed in Table 4.6.
EXPERIMENTS USING THE TMS320C55X
169