* Prefix all algorithm parameters with PARAM_ so we can still use variable
[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 BIT_SIZE 3\r
6 #define SIZE (1<<BIT_SIZE)\r
7 \r
8 /* Define some parameters for this FFT algorithm. We prefix them \r
9  * with PARAM_ so we can still use variable names like 'n' :-) */\r
10 /* Change these: */\r
11 /* 2log of number of tiles */\r
12 #define PARAM_q 2\r
13 /** 2log of total FFT size */\r
14 #define PARAM_n 4\r
15 \r
16 /* But don't change these: */\r
17 /* Number of tiles */\r
18 #define PARAM_Q (1 << PARAM_q)\r
19 /** Total FFT size */\r
20 #define PARAM_N (1 << PARAM_n)\r
21 /** FFT size on each tile */\r
22 #define PARAM_N_t (PARAM_N / PARAM_Q)\r
23 /** 2log of FFT size on each tile */\r
24 #define PARAM_n_t (PARAM_n - PARAM_q)\r
25 \r
26 #ifndef __MONTIUMCC__\r
27         void pre_run();\r
28         void post_run();\r
29 #endif  \r
30         /**\r
31          * Support structure to store the result of a butterfly.\r
32          */\r
33         struct bf_out {\r
34                 word a_re;\r
35                 word a_im;\r
36                 word b_re;\r
37                 word b_im;\r
38         };\r
39         \r
40         /**\r
41          * Support structure to store teh inputs for a butterfly.\r
42          */\r
43         struct bf_in {\r
44                         word a_re;\r
45                         word a_im;\r
46                         word b_re;\r
47                         word b_im;\r
48                         word W_re;\r
49                         word W_im;\r
50         };\r
51         \r
52         /**\r
53          * A struct to hold all the used memories. We put these in\r
54          * a struct, so we can store them in a local variable and \r
55          * pass them around in arguments, so we can change the memories\r
56          * allocated to each on ever stage (MontiumC doesn't support\r
57          * reassigning global mem variables).\r
58          */\r
59         struct mems {\r
60                 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
61         };\r
62         \r
63         INLINE struct bf_out butterfly(struct bf_in in);\r
64         void run(void); \r
65         \r
66         /* Values for the second_half argument */\r
67 #define FIRST_HALF 0\r
68 #define SECOND_HALF 1\r
69         \r
70         /* Values for the stage_odd argument */\r
71 #define EVEN_STAGE 0\r
72 #define ODD_STAGE 1\r
73         \r
74         /* Values for the cycle_odd argument */\r
75 #define EVEN_CYCLE 0\r
76 #define ODD_CYCLE 1\r
77 \r
78 #endif // !FFT_H_INCLUDED\r