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