# DFT algorithm for FPGA without phase

For my FPGA programming lab final project, I want to implement an audio spectrum analyzer. Since I won't be recreating any signals, I only need the frequency magnitude, and not the phase. I'm hoping that ignoring the phase will spare me the trouble of using complex arithmetic, and make the algorithm leaner. I found some references to the discrete hartley transform, which has "no intrinsic involvement of complex numbers" according to wikipedia. I also found the "real DFT" which splits the complex numbers into sine and consine parts. I was wondering, though, how the radix-2 fft butterfly method would be modified for the real DFT or the hartley dft. Or, maybe there's another method to get just the magnitude information that's better for hardware.

magnitude-only FFT can really only be done with the complex FFT followed by computing the magnitude.

the radix-2 Cooley-Tukey FFT (with the butterflies) will likely be the easiest to implement with a FPGA because of the self-similarity of the butterflies in each FFT pass. (if you want some simple C code that you might translate into FPGA code, i can supply you with a very simple radix-2 FFT in C. are you limited to fixed-point or can you do floating point in your implementation?)

if you're displaying spectrum magnitude in dB, then magnitude-squared (without the square root required for magnitude) is easier and just changes the scaling factor on the $\log(\cdot)$ function.

\begin{align} 20\log_{10}\left( \Big|X[k] \Big|\right) &= 10\log_{10}\left( \Big|X[k] \Big|^2\right) \\ \\ &= 10\log_{10}\left( \Re\{X[k]\}^2 + \Im\{X[k]\}^2 \right) \end{align}

so, for dB, don't bother with the square-root.

if your spectrum analyzer also wants log frequency along the frequency axis, that's another different problem to solve.

If you know the frequency of interest, you can implement a Goertzel filter. This filter reduces computational complexity over a traditional DFT or FFT.