Table 4.6 (continued )
popboth XAR5
bclr
SATD
ret
.end
Table 4.7 List of C program exp4a.c
/* Experiment 4A À exp4a.c */
#include "input.dat"
#define
N128
extern void dft_128(int *, int *);
extern void mag_128(int *, int *);
int Xin [2*N];
int Xout [2*N];
int Spectrum [N];
void main()
{
int i, j;
for(j 0, i 0; i < N ; i)
{
Xin [j] input [i];
/* Get real sample
*/
Xin [j] 0;
/* Imaginary sample 0 */
}
dft_128(Xin, Xout);
/* DFT routine
*/
mag_128(Xout, Spectrum); /* Compute spectrum
*/
}
4.6.3 Experiment 4C ± Implementation of DFT
We will complete the DFT routine of N 128 and test it in this section. The C program
listed in Table 4.7 calls for the assembly routine dft_128()to compute the 128-point
DFT.
The data file, input.dat,is an ASCII file that contains 128 points of data sampled
at 8 kHz,and is available in the software package. First,the program composes the
complex input data array Xin [2*N]by zero-filling the imaginary parts. Then the DFT
is carried out by the subroutine dft_128(). The 128 complex DFT samples are stored
in the output data array Xout [2*N]. The subroutine mag_128()at the end of the
program is used to compute the squared magnitude spectrum of the 128 complex DFT
samples from the array Xout [2*N]. The magnitude is then stored in the array called
Spectrum[N],which will be used for graphic display later. The assembly routine,
mag_128.asm,is listed in Table 4.8.
EXPERIMENTS USING THE TMS320C55X
171