;FFT_RL-FROM DSP APPLICATIONS WITH THE TMS320C30, VOL.3 ; WITH BIT REVERSAL ROUTINE MODIFIED * Name: * fft_rl --- radix-2 real FFT to be called as a C function. * * Synopsis: * int fft_rl(N, M, data) * int N FFT size: N=2**M * int M Number of stages = log2(N) * float *data Array with input and output data * * Description: * Generic function to do a radix-2 FFT computation on the 320C30. * The data array is N-long, with only real data. The output is stored in * the same locations with real and imaginary points R and I as follows: * R(0), R(1),..., R(N/2), I(N/2-1),..., I(1) * The program is based on the FORTRAN program in the paper by Sorensen et * al., June 1987 issue of Trans. on ASSP. * The computation is done in place, and the original data is destroyed. * Bit reversal is implemented at the beginning of the function. If this * is not necessary, this part can be commented out. * The sine/cosine table for the twiddle factors is expected to be supplied * during link time, and it should have the following format: * * .global _sine * .data * _sine .float value1 = sin(0*2*pi/N) * .float value2 = sin(1*2*pi/N) * ...... * .float value(N/2) = cos((N/4-1)*2*pi/N) * * The values value1 to value(N/4) are the first quarter of the sine * period, and value(N/4+1) to value(N/2) are the first quarter of the * cosine period. * * Stack structure upon the call: * +--------------+ * -FP(4) | data | * -FP(3) | M | * -FP(2) | N | * -FP(1) | return addr | * -FP(0) | old FP | * +--------------+ * * Registers used: R0, R1, R2, R3, R4, R5, AR0, AR1, AR2, AR4, AR5 * IR0, IR1, RS, RE, RC * * AUTHOR: PANOS E. PAPAMICHALIS * TEXAS INSTRUMENTS OCTOBER 13, 1987 * ***************************************************************************** * FP .set AR3 .GLOBL _fft_rl ; ENTRY POINT FOR EXECUTION .GLOBL _sine ; ADDRESS OF SINE TABLE .BSS FFTSIZ,1 .BSS LOGFFT,1 .BSS INPUT,1 .TEXT SINTAB .word _sine ; INITIALIZE C FUNCTION _fft_rl: PUSH FP ; SAVE DEDICATED REGISTERS LDI SP,FP PUSH R4 PUSH R5 PUSH AR4 PUSH AR5 LDI *-FP(2),R0 ; MOVE ARGUMENTS TO LOCATIONS MATCHING STI R0,@FFTSIZ ; THE NAMES IN THE PROGRAM LDI *-FP(3),R0 STI R0,@LOGFFT LDI *-FP(4),R0 STI R0,@INPUT ; DO THE BIT-REVERSING AT THE BEGINNING ;;MODIFICATIONS FROM D.G.CHANDLER/N.L.CHANG ;;(DETAILS ON SIGNAL PROCESSING,FALL 90) LDI @FFTSIZ,RC ; RC=N SUBI 1,RC ; RC SHOULD BE ONE LESS THAN DESIRED # LDI @FFTSIZ,IR0 LSH -1,IR0 ; IR0=HALF THE SIZE OF FFT=N/2 SUBI R0,R0 ;;(ADDED) R0=0 LDI R0,AR0 ;;(ADDED) AR0=0 LDI R0,AR1 ;;(ADDED) AR1=0 LDI @INPUT,IR1 ;;(ADDED),IR1 FOR PROPER OFFSET RPTB BITRV CMPI AR1,AR0 ; XCHANGE LOCATIONS ONLY BGE CONT ; IF AR0