* Make the FFT size a bit larger.
[matthijs/projects/montium-fft.git] / FFT.h
1 #include "libmontiumc.h"\r
2 #ifndef FFT_H_INCLUDED\r
3 #define FFT_H_INCLUDED\r
4 \r
5 /* Define some parameters for this FFT algorithm. We prefix them \r
6  * with PARAM_ so we can still use variable names like 'n' :-) */\r
7 /* Change these: */\r
8 /* 2log of number of tiles */\r
9 #define PARAM_q 2\r
10 /** 2log of total FFT size */\r
11 #define PARAM_n 12\r
12 \r
13 /* Note that the FFT size on each tile 2^(n-q) must be at least\r
14  * 8 and always a multiple of 4. The number of stages on each \r
15  * tile (n-q) must also be a multiple of 2. */\r
16 \r
17 /* But don't change these: */\r
18 /* Number of tiles */\r
19 #define PARAM_Q (1 << PARAM_q)\r
20 /** Total FFT size */\r
21 #define PARAM_N (1 << PARAM_n)\r
22 /** FFT size on each tile */\r
23 #define PARAM_N_t (PARAM_N / PARAM_Q)\r
24 /** 2log of FFT size on each tile */\r
25 #define PARAM_n_t (PARAM_n - PARAM_q)\r
26 \r
27 #ifndef __MONTIUMCC__\r
28         void pre_run();\r
29         void post_run();\r
30 #endif  \r
31         /**\r
32          * Support structure to store the result of a butterfly.\r
33          */\r
34         struct bf_out {\r
35                 word a_re;\r
36                 word a_im;\r
37                 word b_re;\r
38                 word b_im;\r
39         };\r
40         \r
41         /**\r
42          * Support structure to store teh inputs for a butterfly.\r
43          */\r
44         struct bf_in {\r
45                         word a_re;\r
46                         word a_im;\r
47                         word b_re;\r
48                         word b_im;\r
49                         word W_re;\r
50                         word W_im;\r
51         };\r
52         \r
53         /**\r
54          * A struct to hold all the used memories. We put these in\r
55          * a struct, so we can store them in a local variable and \r
56          * pass them around in arguments, so we can change the memories\r
57          * allocated to each on ever stage (MontiumC doesn't support\r
58          * reassigning global mem variables).\r
59          */\r
60         struct mems {\r
61                 mem input_a_re, input_a_im, input_b_re, input_b_im, output_a_re, output_a_im, output_b_re, output_b_im, twiddle_re, twiddle_im;\r
62         };\r
63         \r
64         INLINE struct bf_out butterfly(struct bf_in in);\r
65         void run(void); \r
66         \r
67         /* Values for the second_half argument */\r
68 #define FIRST_HALF 0\r
69 #define SECOND_HALF 1\r
70         \r
71         /* Values for the stage_odd argument */\r
72 #define EVEN_STAGE 0\r
73 #define ODD_STAGE 1\r
74         \r
75         /* Values for the cycle_odd argument */\r
76 #define EVEN_CYCLE 0\r
77 #define ODD_CYCLE 1\r
78         \r
79 enum in_strategy {      \r
80         REGULAR_IN,\r
81         DISTRIBUTED_IN,\r
82 };\r
83 \r
84 enum out_strategy {\r
85         REGULAR_OUT,\r
86         DISTRIBUTED_OUT,\r
87         BITREVERSED_OUT,\r
88 };\r
89 \r
90 #endif // !FFT_H_INCLUDED\r