/*-------------------------------------------------------------------------- rfft4tbl.c C program to generate the radix-4 twiddle factor table and conv tables for the fast RFFT-program RFFT4.ASM for the ADSP-21020. Based on MATLAB-File by Karl Schwarz, Erlangen-Nuernberg Universitaet Author 12-MAR-1991 Ronnin Yee, Analog Devices Revised 25-MAR-1991 Steven Cox, Analog Devices 12-JUN-1991 Ronnnin Yee, Analog Devices ---------------------------------------------------------------------------*/ #include #include main() { double tc,c; double ts,s; double k1, k2, k3; /* coeff for table calculation */ double pi, freq; char cosfn[20]; /* strings for file names */ char sinfn[20]; int *b; /* pntr to bitrev array */ int length, /* length of FFT */ iter, /* length/4 */ i, j, k, n; FILE *s_file, *c_file; /* initialize pi */ pi = 4.0*atan(1.0); /* User interface */ printf("%c%c%c%c",27,91,50,74); /* clears ibm screen */ printf("%c%c%c",27,91,72); /* homes ibm cursor */ printf("\n RFFT4TBL \n"); printf(" Cosine and Sine Table generator for RFFT4.ASM \n"); printf("\nThis program generates the cosine and sine tables for the fast\n"); printf("RFFT program RFFT4.ASM on the ADSP-21020. The length of the RFFTs\n"); printf("must be (a power of four)*2 and have at least 128 points.\n"); printf("\n Enter the FFT length: "); scanf(" %d",&length); length=length/2; printf("\n Name of Cosine table to be created: "); scanf(" %s",cosfn); c_file=fopen(cosfn,"w"); printf(" Name of Sine table to be created: "); scanf(" %s",sinfn); s_file=fopen(sinfn,"w"); /* allocate the storage for bitrev array */ b = (int *) calloc(length,sizeof(int)); if(!b) { printf("\nUnable to allocate memory for bitrev. array.\n"); exit(1); } /* Start Calculations */ if (length > 1024) printf("\n\n Thinking hard . . ."); else printf("\n\n Thinking . . ."); iter = length/4; /* generate array for bit reversed addressing */ for (i=1,j=1;i<=iter;i++) { *(b+i-1) = j-1; k = iter/2; while (k