The present invention relates to semiconductor devices, and in particular to devices and methods for fast Fourier transforms.
The terminology fast Fourier transform (FFT) refers to efficient methods for computation of discrete Fourier transforms (DFT). See generally, Burrus and Parks, DFT/FFT and Convolution Algorithms (Wiley-Interscience 1985), for a definition and discussion of various forms of the FFT. The commonly used FFT can be schematically represented as a series of elementary “butterfly” computations. In particular,
The FFT is widely used in real time digital signal processing requiring fast execution. However, typical computing systems have time consuming memory access, and the FFT is extremely memory access and storage intensive. Indeed, each butterfly (for radix-4) reads four complex data entries plus three complex twiddle coefficients from memory and writes four complex data entries back to the same data memory locations. Thus a 64-point radix-4 FFT requires a total of 192 data memory reads and 192 data memory writes and 144 memory reads for twiddle coefficients. Thus various approaches for efficient memory arrangement in FFTs have been proposed; such as the addressing system of U.S. Pat. No. 5,091,875.
However, in the known FFTs the jumping of the memory accesses (in the middle stages) typically results in cache thrashing and obliterates the advantages of cache memory as only one element in each cacheline is used and so reduces memory bandwidth. Thus the known FFTs have cache usage problems. And with the increasing availability of processors using packed data operations (single instruction multiple dispatch or SIMD), it is also important that the FFT be able to make effective use of these kinds of architectures.
The present invention provides an FFT method with an inner loop which sequentially progresses through memory to compute all the butterflies of a stage and thereby takes advantage of cache and all available SIMD processing bandwidth. Preferred embodiments also create a twiddle factor table with redundancy so the stage loop can sequentially progress through the table. Preferred embodiments include digital signal processors having data cache and programmed with the FFT method, and also include processors with SIMD architectures.
The invention has advantages including faster execution in systems with cache memory and SIMD instructions such as very wide load/store datapath and greater than two multipliers.
The Figures are heuristic for clarity.
a–4c illustrate a radix-4 butterfly plus an unrolled version.
Overview
As illustrated by
As the inner loop always has N/R iterations in a deeply pipelined machine, the epilogue and prologue are constant and predictable. Not so in the prior art. Prior art progression through the loops causes the epilogue and prologue to become more and more of an overhead. This is reinforced as DSPs tend to be more deeply pipelined to achieve higher speeds, so loop prologue and epilogue is an architectural issue that must be overcome.
Radix-2 Preferred Embodiment
The arrows in
The computation of the twiddle factors in the foregoing pseudocode of both the preferred embodiment and the prior art could be avoided by precomputation and storage in a lookup table. But this implies another memory location sequence and cache usage question. Indeed, prior art
Some preferred embodiments employ a redundant twiddle factor table with sequential memory locations for butterfly computations in all stages. Indeed,
The following general radix-4 section includes generation of a redundant twiddle factor table.
Radix-4 FFT
A radix-4 FFT has four-winged butterflies and twiddle factors as illustrated in
A preferred embodiment FFT with a redundant twiddle factor lookup table can be described with the following code (written in C):
First, presume the input data consists of an array x of N (a power of 4) complex numbers, x[0]+jx[1], x[2]+jx[3], . . . , x[i]+jx[i+1], . . . , with 16-bit real parts x[0], x[2], . . . and 16-bit imaginary parts x[1], x[3], . . . , and stored on word boundaries. Next, presume the twiddle factors, 1, W, W2, . . . , Wk . . . with W=ej2π/N, with 16-bit real and imaginary parts (cosines and sines), are redundantly generated and stored in array w follows whre PI is a 16-bit approximation of π and theta1, theta2, theta3, x—t, and y—t are double precision floating point numbers for accuracy:
a shows the twiddle factors for the nth butterfly in the first stage form a group of four as W0 (=1), Wn, W2n, and W3n, and the foregoing theta1, theta2, and theta3 correspond to the n, 2n, and 3n powers for n=i. Thus each butterfly has three nontrivial twiddle factors.
The first (j=1) loop generates the 3N/4 nontrivial twiddle factors for the N/4 butterflies of the first stage and stores them in w[0] to w[3N/4−1] in the order of use as indicated by
Similarly for subsequent loops: the block size and number of nontrivial twiddle factors to be generated and stored reduces by a factor of 4 for each stage. Thus the total number of twiddle factors stored is 3N/4+3N/16+3N/64+. . . +3=3N/4*(1+¼+ 1/16+. . . +4/N)≈3N/4*4/3=N. This compares to the prior art table of 3N/4 entries; so the preferred embodiment twiddle factor table is only 33% larger.
The following function performs the FFT and stores the results in the same locations as the initial data but with the usual digit-reversed address (for radix-4 a digit is 2 bits and for radix-2 a digit is 1 bit):
Note that the foregoing C code is optimized for the standard compilers for the 320C6211 DSP manufactured by Texas Instruments.
Cache Usage
SIMD Transformation
SIMD (single instruction multiple dispatch) transformations can be performed on algorithms where the data accesses form a linear pattern. For example, a convolution used in an FIR filter such as
Now the data pairs h[j], h[j+1] can be loaded as single data object; similarly the data pair x[i-j], x[i-(j+1)] can be loaded as a single data object. Then a complex multiplication operation (e.g., cmpy) can be used in the unrolled form:
y[i]+=cmpy(x[i−(j+1)]:x[i−j], h[j]:h[j+1])
The unrolled preferred embodiment can leverage such operations. The accesses are more FIR-like than FFT-like. In the prior art FFT the loops cannot be unrolled and merged together as the accesses jump about as illustrated for the middle stage in
Modifications
The preferred embodiments can be varied in many ways while retaining the feature of an FFT with sequential memory location butterfly computations. For example, a radix other than 2 or 4 could be used, the number of stages could be larger (e.g., a 4096-point FFT with radix equal to 4 would have six stages), the precision of the data could be varied, the butterfly can employ saturation and/or rounding to improve precision and stability.
Number | Name | Date | Kind |
---|---|---|---|
4612626 | Marchant | Sep 1986 | A |
5313413 | Bhatia et al. | May 1994 | A |
5430667 | Takano | Jul 1995 | A |
5491652 | Luo et al. | Feb 1996 | A |
5694347 | Ireland | Dec 1997 | A |
5890098 | Kozaki et al. | Mar 1999 | A |
6366936 | Lee et al. | Apr 2002 | B1 |
6591284 | Brockmeyer et al. | Jul 2003 | B1 |
Number | Date | Country | |
---|---|---|---|
60128340 | Apr 1999 | US |