X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fmontium-fft.git;a=blobdiff_plain;f=FFT_support.cpp;fp=FFT_support.cpp;h=23d07f08ca102e114e7428807701f364fcdcc566;hp=6f21e5a24afa1e9cca6fe74a37bfa4965ff6d2ea;hb=a62dbd706365d44bdcac9f8ac4c7c6dd05484642;hpb=57eb86fc79d7056a4b91438104cc1fe1eaf86c59 diff --git a/FFT_support.cpp b/FFT_support.cpp index 6f21e5a..23d07f0 100644 --- a/FFT_support.cpp +++ b/FFT_support.cpp @@ -4,7 +4,7 @@ /* Didn't the Montium use Q15 instead of Q14? */ -#define FIXED_POINT 14 +#define FIXED_POINT 15 #define WORD_SIZE 16 #define WORDS_PER_LINE 4 @@ -55,46 +55,73 @@ void pre_run() input_a_im = alloc_mem(P1M0); input_b_re = alloc_mem(P2M0); input_b_im = alloc_mem(P3M0); - output_a_re = alloc_mem(P0M1); - output_a_im = alloc_mem(P1M1); - output_b_re = alloc_mem(P2M1); - output_b_im = alloc_mem(P3M1); + + twiddle_re = alloc_mem(P4M0); + twiddle_im = alloc_mem(P4M1); /* TODO: Init memory and twiddles */ - for (i=0;iid, i, to_fixed(cos(2*M_PI/SIZE*i))); - set_mem(twiddle_im->id, i, to_fixed(sin(2*M_PI/SIZE*i))); + set_mem(twiddle_re->id, i, to_fixed(cos(i*2*M_PI/PARAM_N_t))); + set_mem(twiddle_im->id, i, to_fixed(sin(i*2*M_PI/PARAM_N_t))); } - for (i=0;iid, i, value); - set_mem(input_a_im->id, i, 0); + if (i % 2 == 0) { + set_mem(input_a_re->id, i, value); + set_mem(input_a_im->id, i, 0); + } else { + set_mem(input_b_re->id, i, value); + set_mem(input_b_im->id, i, 0); + } } else { - set_mem(input_a_re->id, i - SIZE / 2, value); - set_mem(input_a_im->id, i - SIZE / 2, 0); + if (i % 2 == 0) { + set_mem(input_b_re->id, i - PARAM_N_t/2, value); + set_mem(input_b_im->id, i - PARAM_N_t/2, 0); + } else { + set_mem(input_a_re->id, i - PARAM_N_t/2, value); + set_mem(input_a_im->id, i - PARAM_N_t/2, 0); + } } } -} - -void post_run() -{ + printf("re(W)\n"); - print_mem(twiddle_re, 0, SIZE, true); + print_mem(twiddle_re, 0, PARAM_N_t/2, true); printf("im(W)\n"); - print_mem(twiddle_im, 0, SIZE, true); + print_mem(twiddle_im, 0, PARAM_N_t/2, true); printf("re(in_a)\n"); - print_mem(input_a_re, 0, SIZE, true); + print_mem(input_a_re, 0, PARAM_N_t/2, true); printf("re(in_b)\n"); - print_mem(input_b_re, 0, SIZE, true); + print_mem(input_b_re, 0, PARAM_N_t/2, true); +} + +void post_run() +{ + if (PARAM_n_t % 2 == 0) { + /* When the number of stages is odd, the + * outputs end up at the left memories again */ + output_a_re = alloc_mem(P0M0); + output_a_im = alloc_mem(P1M0); + output_b_re = alloc_mem(P2M0); + output_b_im = alloc_mem(P3M0); + } else { + output_a_re = alloc_mem(P0M1); + output_a_im = alloc_mem(P1M1); + output_b_re = alloc_mem(P2M1); + output_b_im = alloc_mem(P3M1); + } printf("re(out_a)\n"); - print_mem(output_a_re, 0, SIZE, true); + print_mem(output_a_re, 0, PARAM_N_t/2, true); + print_mem(output_b_re, 0, PARAM_N_t/2, true); printf("im(out_a)\n"); - print_mem(output_a_im, 0, SIZE, true); + print_mem(output_a_im, 0, PARAM_N_t/2, true); + print_mem(output_b_im, 0, PARAM_N_t/2, true); + }