bit_reverse.c
来自「基于8051F单片机,实现1024点的FFT 用C 语言实现的.效果与FPGA」· C语言 代码 · 共 51 行
C
51 行
#include "FFT_Code_Tables.h"
//-----------------------------------------------------------------------------
// Bit_Reverse
//-----------------------------------------------------------------------------
//
// Sorts data in Bit Reversed Address order
//
// The BRTable[] array is used to find which values must be swapped. Only
// half of this array is stored, to save code space. The second half is
// assumed to be a mirror image of the first half.
//
void Bit_Reverse(int BR_Array[])
{
#if (NUM_FFT >= 512)
unsigned int swapA, swapB, sw_cnt; // Swap Indices
#endif
#if (NUM_FFT <= 256)
unsigned char swapA, swapB, sw_cnt; // Swap Indices
#endif
int TempStore;
// Loop through locations to swap
for (sw_cnt = 1; sw_cnt < NUM_FFT/2; sw_cnt++)
{
swapA = sw_cnt; // Store current location
swapB = BRTable[sw_cnt] * 2; // Retrieve bit-reversed index
if (swapB > swapA) // If the bit-reversed index is
{ // larger than the current index,
TempStore = BR_Array[swapA]; // the two data locations are
BR_Array[swapA] = BR_Array[swapB]; // swapped. Using this comparison
BR_Array[swapB] = TempStore; // ensures that locations are only
} // swapped once, and never with
// themselves
swapA += NUM_FFT/2; // Now perform the same operations
swapB++; // on the second half of the data
if (swapB > swapA)
{
TempStore = BR_Array[swapA];
BR_Array[swapA] = BR_Array[swapB];
BR_Array[swapB] = TempStore;
}
}
} // END Bit Reverse Order Sort
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?