Forum Discussion
Altera_Forum
Honored Contributor
14 years ago --- Quote Start --- I want cross-correlation. --- Quote End --- Ok. --- Quote Start --- So I need help in parameterizing the FIR Megacore. --- Quote End --- When you 'correlate' your input signal with a sinusoid, you're performing an operation that is very similar to what you do when you perform a discrete Fourier transform (DFT). The following may give you a better understanding of what you are doing ... The Forward DFT equation is X[k] = sum_{n=0}^{n=N-1} x[n] * exp(-2*pi*k*n/N) Where the exponential can be split into cos and sine, or real and imaginary components, i.e., assuming x[n] are real-valued samples, then X_real[k] = sum_{n=0}^{n=N-1} x[n] * cos(2*pi*k*n/N) X_imag[k] = -sum_{n=0}^{n=N-1} x[n] * sin(2*pi*k*n/N) These equations implement the sum of N input samples x[n] multiplied by N weights; now what does that sound like? A FIR filter perhaps? There are two sets of FIR filter coefficients; one filter is a cosine filter, the other is a sine filter. The output of the filter is related to the magnitude and phase of the Fourier response at channel k. Where, in your case, k is the frequency of your sinusoid normalized by the sampling rate, i.e., k = f0/fs. Note that the above equation is the calculation at a single output sample time instant, so there is a parameter missing (your output sample time index), which is why the above equation doesn't look exactly like a FIR filter equation (the parameter k is fixed, since you're only measuring at one frequency). Cheers, Dave