dsp_bitrev_cplx.h64

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

H64
199
字号
*       }                                                                   *
*                                                                           *
*     C CODE                                                                *
*         void bitrev(int *x, short *index, int nx)                         *
*         {                                                                 *
*             int     i;                                                    *
*             short       i0, i1, i2, i3;                                   *
*             short       j0, j1, j2, j3;                                   *
*             int     xi0, xi1, xi2, xi3;                                   *
*             int     xj0, xj1, xj2, xj3;                                   *
*             short       t;                                                *
*             int     a, b, ia, ib, ibs;                                    *
*             int     mask;                                                 *
*             int     nbits, nbot, ntop, ndiff, n2, halfn;                  *
*             short   *xs = (short *) x;                                    *
*                                                                           *
*             nbits = 0;                                                    *
*             i = nx;                                                       *
*             while (i > 1)                                                 *
*             {                                                             *
*                 i = i >> 1;                                               *
*                 nbits++;                                                  *
*             }                                                             *
*                                                                           *
*             nbot    = nbits >> 1;                                         *
*             ndiff   = nbits & 1;                                          *
*             ntop    = nbot + ndiff;                                       *
*             n2      = 1 << ntop;                                          *
*             mask    = n2 - 1;                                             *
*             halfn   = nx >> 1;                                            *
*                                                                           *
*             for (i0 = 0; i0 < halfn; i0 += 2)                             *
*             {                                                             *
*                 b   = i0 & mask;                                          *
*                 a   = i0 >> nbot;                                         *
*                 if (!b) ia  = index[a];                                   *
*                 ib  = index[b];                                           *
*                 ibs = ib << nbot;                                         *
*                                                                           *
*                 j0  = ibs + ia;                                           *
*                 t   = i0 < j0;                                            *
*                 xi0 = x[i0];                                              *
*                 xj0 = x[j0];                                              *
*                                                                           *
*                 if (t){x[i0] = xj0;                                       *
*                 x[j0] = xi0;}                                             *
*                                                                           *
*                 i1  = i0 + 1;                                             *
*                 j1  = j0 + halfn;                                         *
*                 xi1 = x[i1];                                              *
*                 xj1 = x[j1];                                              *
*                 x[i1] = xj1;                                              *
*                 x[j1] = xi1;                                              *
*                                                                           *
*                 i3  = i1 + halfn;                                         *
*                 j3  = j1 + 1;                                             *
*                 xi3 = x[i3];                                              *
*                 xj3 = x[j3];                                              *
*                 if (t){x[i3] = xj3;                                       *
*                 x[j3] = xi3;}                                             *
*             }                                                             *
*         }                                                                 *
*                                                                           *
*   ASSUMPTIONS                                                             *
*       nx must be a power of 2.                                            *
*       The table from bitrev_index is already created.                     *
*       LITTLE ENDIAN configuration used.                                   *
*                                                                           *
*   NOTES                                                                   *
*       If nx <= 4K one can use the char (8-bit) data type for              *
*       the "index" variable. This would require changing the LDH when      *
*       loading index values in the assembly routine to LDB. This would     *
*       further reduce the size of the Index Table by half its size.        *
*                                                                           *
*       This code is interrupt tolerant, but not interruptible.             *
*                                                                           *
*   CYCLES                                                                  *
*       (nx/4 + 2) * 7 + 18                                                 *
*                                                                           *
*       e.g. nx = 256, cycles = 480                                         *
*                                                                           *
*   CODESIZE                                                                *
*       352 bytes                                                           *
*                                                                           *
*                                                                           *
* ------------------------------------------------------------------------- *
*             Copyright (c) 2003 Texas Instruments, Incorporated.           *
*                            All Rights Reserved.                           *
* ========================================================================= *

        .global _DSP_bitrev_cplx

* ========================================================================= *
*   End of file:  dsp_bitrev_cplx.h64                                       *
* ------------------------------------------------------------------------- *
*             Copyright (c) 2003 Texas Instruments, Incorporated.           *
*                            All Rights Reserved.                           *
* ========================================================================= *

⌨️ 快捷键说明

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