From 81823b7486c210898290292ed87142a89c496946 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Apr 2008 12:28:47 +0200 Subject: [PATCH] * Add a missing ! in write_output_regular(). * Use while loops instead of do while, since loop_next checks for zero before decrementing, not after. Regular FFT seems to work now, though there seem to be quite some rounding errors. Testing a larger FFT is hard, since decoding the results is still manual. --- FFT.mc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FFT.mc b/FFT.mc index 626b0dc..6688275 100644 --- a/FFT.mc +++ b/FFT.mc @@ -52,7 +52,7 @@ INLINE void write_output_regular(struct mems m, struct bf_out res, bool second_h add_offset(m.output_b_re, 2); add_offset(m.output_b_im, 2); - if (second_half) { + if (!second_half) { write_mem(m.output_a_re, res.a_re); write_mem(m.output_a_im, res.a_im); write_mem(m.output_b_re, res.b_re); @@ -187,9 +187,9 @@ INLINE void do_half_regular_stage(struct mems m, bool stage_odd, bool second_hal /* Now, do half a single stage. That means N_t / 4 cycles. Since we do 2 * cycles on every iteration, plus one before and after the loop, - * we will loop N_t / 8 - 1 times. */ + * we will loop N_t / 8 - 1 times. We add an extra - 1 because this is a do while loop... */ init_loop(LC2, (PARAM_N_t / 8) - 1); - do { + while (loop_next(LC2)) { /* Write outputs of previous cycle */ write_output_regular(m, out, second_half); @@ -204,7 +204,7 @@ INLINE void do_half_regular_stage(struct mems m, bool stage_odd, bool second_hal /* Even cycle */ in = read_input_regular(m, EVEN_CYCLE, second_half); out = butterfly(in); - } while (loop_next(LC2)); + } /* Write outputs of previous cycle */ write_output_regular(m, out, second_half); @@ -256,7 +256,7 @@ void run() { /* We need to do n_t regular stages. Since we do two stages each * iteration, we'll do n_t / 2 iterations. */ init_loop(LC1, (PARAM_n_t / 2)); - do { + while (loop_next(LC1)) { m = init_mem_mapping(EVEN_STAGE); init_input_addresses_regular(m, EVEN_STAGE); /* do_half_regular_stage will init output addresses */ @@ -271,5 +271,5 @@ void run() { do_half_regular_stage(m, ODD_STAGE, FIRST_HALF); do_half_regular_stage(m, ODD_STAGE, SECOND_HALF); stage++; - } while (loop_next(LC1)); + } } -- 2.30.2