dsp_fft16x32.h64

来自「dm642函数库」· H64 代码 · 共 355 行 · 第 1/2 页

H64
355
字号
;* ======================================================================== *;
;*  TEXAS INSTRUMENTS, INC.                                                 *;
;*                                                                          *;
;*  DSPLIB  DSP Signal Processing Library                                   *;
;*                                                                          *;
;*      Release:        Revision 1.04b                                      *;
;*      CVS Revision:   1.5     Sun Sep 29 03:32:21 2002 (UTC)              *;
;*      Snapshot date:  23-Oct-2003                                         *;
;*                                                                          *;
;*  This library contains proprietary intellectual property of Texas        *;
;*  Instruments, Inc.  The library and its source code are protected by     *;
;*  various copyrights, and portions may also be protected by patents or    *;
;*  other legal protections.                                                *;
;*                                                                          *;
;*  This software is licensed for use with Texas Instruments TMS320         *;
;*  family DSPs.  This license was provided to you prior to installing      *;
;*  the software.  You may review this license by consulting the file       *;
;*  TI_license.PDF which accompanies the files in this library.             *;
;* ------------------------------------------------------------------------ *;
;*          Copyright (C) 2003 Texas Instruments, Incorporated.             *;
;*                          All Rights Reserved.                            *;
;* ======================================================================== *;
;* ======================================================================== *;
;*  Assembler compatibility shim for assembling 4.30 and later code on      *;
;*  tools prior to 4.30.                                                    *;
;* ======================================================================== *;
;* ======================================================================== *;
;*  End of assembler compatibility shim.                                    *;
;* ======================================================================== *;
*========================================================================== *
*      TEXAS INSTRUMENTS, INC.                                              *
*                                                                           *
*      NAME                                                                 *
*            DSP_fft16x32                                                   *
*                                                                           *
*      USAGE                                                                *
*            This routine is C-callable and can be called as:               *
*                                                                           *
*           void DSP_fft16x32(const short * ptr_w, int  npoints,            *
*                            int   * ptr_x, int  *ptr_y ) ;                 *
*                                                                           *
*             ptr_w   =  input twiddle factors                              *
*             npoints =  number of points                                   *
*             ptr_x   =  transformed data reversed                          *
*             ptr_y   =  linear transformed data                            *
*                                                                           *
*            (See the C compiler reference guide.)                          *
*                                                                           *
*   DESCRIPTION                                                             *
*       The following code performs a mixed radix FFT for "npoints" which   *
*       is either a multiple of 4 or 2. It uses logN4 - 1 stages of radix4  *
*       transform and performs either a radix2 or radix4 transform on the   *
*       last stage depending on "npoints". If "npoints" is a multiple of 4, *
*       then this last stage is also a radix4 transform, otherwise it is a  *
*       radix2 transform. This program is available as a C compilable file  *
*       to automatically generate the twiddle factors "twiddle_split.c"     *
*                                                                           *
*         int i, j, k, n = N;                                               *
*         double theta1, theta2, theta3, x_t, y_t;                          *
*         const double M = 32768.0, PI = 3  41592654;                       *
*                                                                           *
*         for (j=1, k=0; j < n>>2; j = j<<2)                                *
*         {                                                                 *
*             for (i=0; i < n>>2; i += j<<1)                                *
*             {                                                             *
*                 theta1 = 2*PI*i/n;                                        *
*                 x_t = M*cos(theta1);                                      *
*                 y_t = M*sin(theta1);                                      *
*                 w[k+1] = (short) x_t;                                     *
*                 if (x_t >= M) w[k+1] = 0x7fff;                            *
*                 w[k+0] = (short) y_t;                                     *
*                 if (y_t >= M) w[k+0] = 0x7fff;                            *
*                                                                           *
*                 theta1 = 2*PI*(i+j)/n;                                    *
*                 x_t = M*cos(theta1);                                      *
*                 y_t = M*sin(theta1);                                      *
*                 w[k+7] = (short) x_t;                                     *
*                 if (x_t >= M) w[k+3] = 0x7fff;                            *
*                 w[k+6] = (short) y_t;                                     *
*                 if (y_t >= M) w[k+2] = 0x7fff;                            *
*                                                                           *
*                 theta2 = 4*PI*i/n;                                        *
*                 x_t = M*cos(theta2);                                      *
*                 y_t = M*sin(theta2);                                      *
*                 w[k+3] = (short) x_t;                                     *
*                 if (x_t >= M) w[k+5] = 0x7fff;                            *
*                 w[k+2] = (short) y_t;                                     *
*                 if (y_t >= M) w[k+4] = 0x7fff;                            *
*                                                                           *
*                 theta2 = 4*PI*(i+j)/n;                                    *
*                 x_t = M*cos(theta2);                                      *
*                 y_t = M*sin(theta2);                                      *
*                 w[k+9] = (short) x_t;                                     *
*                 if (x_t >= M) w[k+7] = 0x7fff;                            *
*                 w[k+8] = (short) y_t;                                     *
*                 if (y_t >= M) w[k+6] = 0x7fff;                            *
*                                                                           *
*                 theta3 = 6*PI*i/n;                                        *
*                 x_t = M*cos(theta3);                                      *
*                 y_t = M*sin(theta3);                                      *
*                 w[k+5] = (short) x_t;                                     *
*                 if (x_t >= M) w[k+9] = 0x7fff;                            *
*                 w[k+4] = (short) y_t;                                     *
*                 if (y_t >= M) w[k+8] = 0x7fff;                            *
*                                                                           *
*                 theta3 = 6*PI*(i+j)/n;                                    *
*                 x_t = M*cos(theta3);                                      *
*                 y_t = M*sin(theta3);                                      *
*                 w[k+11] = (short) x_t;                                    *
*                 if (x_t >= M) w[k+11] = 0x7fff;                           *
*                 w[k+10] = (short) y_t;                                    *
*                 if (y_t >= M) w[k+10] = 0x7fff;                           *
*                                                                           *
*                 k += 12;                                                  *
*             }                                                             *
*         }                                                                 *
*         w[2*n-1] = w[2*n-3] = w[2*n-5] = 0x7fff;                          *
*         w[2*n-2] = w[2*n-4] = w[2*n-6] = 0x0000;                          *
*                                                                           *
*   ASSUMPTIONS                                                             *
*       This code works for  both "npoints" a multiple of 2 or 4.           *
*       The arrays 'x[]', 'y[]', and 'w[]' all must be aligned on a         *
*       double-word boundary for the "optimized" implementations.           *
*                                                                           *
*       The input and output data are complex, with the real/imaginary      *
*       components stored in adjacent locations in the array.  The real     *
*       components are stored at even array indices, and the imaginary      *
*       components are stored at odd array indices.                         *
*                                                                           *
*   TECHNIQUES                                                              *
*       The following C code represents an implementation of the Cooley     *
*       Tukey radix 4 DIF FFT. It accepts the inputs in normal order and    *
*       produces the outputs in digit reversed order. The natural C code    *
*       shown in this file on the other hand, accepts the inputs in nor-    *
*       mal order and produces the outputs in normal order.                 *
*                                                                           *
*       Several transformations have been applied to the original Cooley    *
*       Tukey code to produce the natural C code description shown here.    *
*       In order to understand these it would first be educational to       *
*       understand some of the issues involved in the conventional Cooley   *
*       Tukey FFT code.                                                     *
*                                                                           *
*       void radix4(int n, short x[], short wn[])                           *
*       {                                                                   *
*           int    n1,  n2,  ie,   ia1,  ia2, ia3;                          *
*           int    i0,  i1,  i2,    i3,    i, j,     k;                     *
*           short  co1, co2, co3,  si1,  si2, si3;                          *
*           short  xt0, yt0, xt1,  yt1,  xt2, yt2;                          *
*           short  xh0, xh1, xh20, xh21, xl0, xl1,xl20,xl21;                *
*                                                                           *
*           n2 = n;                                                         *
*           ie = 1;                                                         *
*           for (k = n; k > 1; k >>= 2)                                     *
*           {                                                               *
*               n1 = n2;                                                    *
*               n2 >>= 2;                                                   *
*               ia1 = 0;                                                    *
*                                                                           *
*               for (j = 0; j < n2; j++)                                    *
*               {                                                           *
*                    ia2 = ia1 + ia1;                                       *
*                    ia3 = ia2 + ia1;                                       *
*                                                                           *
*                    co1 = wn[2 * ia1    ];                                 *
*                    si1 = wn[2 * ia1 + 1];                                 *
*                    co2 = wn[2 * ia2    ];                                 *
*                    si2 = wn[2 * ia2 + 1];                                 *
*                    co3 = wn[2 * ia3    ];                                 *
*                    si3 = wn[2 * ia3 + 1];                                 *
*                    ia1 = ia1 + ie;                                        *
*                                                                           *
*                    for (i0 = j; i0< n; i0 += n1)                          *
*                    {                                                      *
*                        i1 = i0 + n2;                                      *
*                        i2 = i1 + n2;                                      *
*                        i3 = i2 + n2;                                      *
*                                                                           *
*                                                                           *

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?