X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fmontium-fft.git;a=blobdiff_plain;f=FFT_support.cpp;h=2ddf150b6f1bb8e3e215dac89d9256cbb4fe31cd;hp=d3b5d09d28cc0917cd68106f5db53c7b7a53d916;hb=HEAD;hpb=2af1857cd1a8eab206dbde5f5af0156d9ee9f702 diff --git a/FFT_support.cpp b/FFT_support.cpp index d3b5d09..2ddf150 100644 --- a/FFT_support.cpp +++ b/FFT_support.cpp @@ -2,8 +2,7 @@ #include #include - -/* Didn't the Montium use Q15 instead of Q14? */ +/* Use Q15 fixed point format (1 sign bit plus 15 fractional bits) */ #define FIXED_POINT 15 #define WORD_SIZE 16 @@ -28,7 +27,7 @@ float from_fixed(int n) return n / (float)(1<id, i))); else printf("%04hx", (short)get_mem(m->id, i)); - if ((i + 1) % WORDS_PER_LINE == 0) + if (newline && (i + 1) % WORDS_PER_LINE == 0) printf("\n"); else if ((i + 1) % WORDS_PER_GROUP == 0) printf(" "); } - if (i % WORDS_PER_LINE != 0) + if (newline && i % WORDS_PER_LINE != 0) printf("\n"); } @@ -68,9 +67,9 @@ void pre_run() for (i=0;iid, 0, PARAM_N_t/2, "Memory/sin_a_re.mm"); + save_mem_range_to_file(input_a_im->id, 0, PARAM_N_t/2, "Memory/sin_a_im.mm"); + save_mem_range_to_file(input_b_re->id, 0, PARAM_N_t/2, "Memory/sin_b_re.mm"); + save_mem_range_to_file(input_b_im->id, 0, PARAM_N_t/2, "Memory/sin_b_im.mm"); + save_mem_range_to_file(twiddle_re->id, 0, PARAM_N_t/2, "Memory/twiddle_re.mm"); + save_mem_range_to_file(twiddle_im->id, 0, PARAM_N_t/2, "Memory/twiddle_im.mm"); } void post_run() { if (PARAM_n_t % 2 == 0) { - /* When the number of stages is odd, the + /* When the number of stages is even, the * outputs end up at the left memories again */ output_a_re = alloc_mem(P0M0); output_a_im = alloc_mem(P1M0); @@ -119,11 +131,21 @@ void post_run() output_b_re = alloc_mem(P2M1); output_b_im = alloc_mem(P3M1); } - printf("re(out_a)\n"); - 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, PARAM_N_t/2, true); - print_mem(output_b_im, 0, PARAM_N_t/2, true); + printf("re_out = ["); + print_mem(output_a_re, 0, PARAM_N_t/2, true, false); + print_mem(output_b_re, 0, PARAM_N_t/2, true, false); + printf("];\n"); + printf("im_out = ["); + print_mem(output_a_im, 0, PARAM_N_t/2, true, false); + print_mem(output_b_im, 0, PARAM_N_t/2, true, false); + printf("];\n"); + /* + printf("re(out)\n"); + print_mem(output_a_re, 0, PARAM_N_t/2, false, true); + print_mem(output_b_re, 0, PARAM_N_t/2, false, true); + printf("im(out)\n"); + print_mem(output_a_im, 0, PARAM_N_t/2, false, true); + print_mem(output_b_im, 0, PARAM_N_t/2, false, true); + */ }