Prev: Narrowband Rician fading
Next: phase of FFT
From: septer012 on 20 Jan 2010 14:35 I am not too comfortable with the C wrappers and C Asm interfacing. I am writing a Radix-2 in C right now to compute an 8 point FFT. I will see if I can get this going to give me data out. Then I will try to do the same thing in matlab and compare my results (crosses fingers). Thank you guys for your input by the way. If I can figure this out, I will definitely think about writing a Radix-32. Hey I only have to write it once.
From: Jerry Avins on 20 Jan 2010 15:12 septer012 wrote: > I am not too comfortable with the C wrappers and C Asm interfacing. > > I am writing a Radix-2 in C right now to compute an 8 point FFT. Will you forgo the MAC and bit-reversed addressing instructions, or are they accessible to your compiler? > I will see if I can get this going to give me data out. Then I will try > to do the same thing in matlab and compare my results (crosses fingers). > > Thank you guys for your input by the way. > > If I can figure this out, I will definitely think about writing a > Radix-32. Hey I only have to write it once. Yeah. Good luck! Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
From: septer012 on 25 Jan 2010 20:17 I have been struggling with this for a long time. I wrote code for a Radix-2 N=4 FFT. But I am having trouble indexing twiddle factors maybe someone knows a good solution to my problem? // Load Initial Test Data data_real[0] = 0; data_imag[0] = 0; data_real[1] = 1; data_imag[1] = 0; data_real[2] = 2; data_imag[2] = 0; data_real[3] = 3; data_imag[3] = 0; twid_real[0] = 1; twid_imag[0] = 0; twid_real[1] = 0; twid_imag[1] = -1; twid_real[2] = -1; twid_imag[2] = 0; twid_real[3] = 0; twid_imag[3] = 1; for(stage = 1; stage<=M; stage++) { for(butterfly = 0; butterfly < (N/2); butterfly++) { butterflynext = butterfly+N/(2^stage); //Temp store data temp_data_real_A = data_real[butterfly]; temp_data_real_B = data_real[butterflynext]; temp_data_imag_A = data_imag[butterfly]; temp_data_imag_B = data_imag[butterflynext]; //handle twiddle temp_data_real_B = (data_real[butterflynext] * twid_real[butterflynext]); temp_data_real_B = temp_data_real_B - (data_imag[butterflynext] * twid_imag[butterflynext]); temp_data_imag_B = (data_real[butterflynext] * twid_imag[butterflynext]); temp_data_imag_B = temp_data_imag_B + (twid_real[butterflynext] * data_imag[butterflynext]); //finish calc data_real[butterfly] = temp_data_real_A + temp_data_real_B; data_real[butterflynext] = temp_data_real_A - temp_data_real_B; data_imag[butterfly] = temp_data_imag_A + temp_data_imag_B; data_imag[butterflynext] = temp_data_imag_A - temp_data_imag_B; } }
From: kevin on 26 Jan 2010 01:11 On Jan 25, 8:17 pm, "septer012" <johnson.dani...(a)yahoo.com> wrote: Ouch! Thats an awful lot of code for doing a 4 point FFT. And where did those twiddle values come from? For a 4 point, you should have just two of them - the 0 twiddle, which is = 1, and a twiddle of - j. And what about in-place processing? A 2 point butterfly (top inputs r[0], i[0] and bottom inputs r[1], i[1]) should be more like: t = r[0] + r[1]; r[1] = r[0] - r[1]; r[0] = t; t = i[0] + i[1]; i[1] = i[0] - i[1]; i[0]= t; No extra storage needed other than one temporary variable. Some people would use a t1 and t2 in the above because the compiler might be able to speed it up. The twiddle placements and the values that they represent depend on which one of the 16 basic FFT algorithms youre using (and there are more non-basic types, too). Your twiddles dont seem right. Where are they from? Perhaps youre basing them on a picture that uses one of the old-fashioned ways of drawing FFT flow? Kevin McGee
From: septer012 on 26 Jan 2010 13:01
Tell me about it! I have not taken a formal programming course in quite a few years. Your right I do have too many twiddles, I should have N/2 twiddles. I have decomposed your sample code and that makes sense and is the same thing I did with shorter variable names. (well kind of) Thanks!, I am still trying to figure out how to grab the correct array index from a twiddle array. |