11// fft top level module.
22// the width is the bit width (e.g. if width=16, 16 real and 16 im bits).
3- // N_2 is log base 2 of N (points in the FFT). e.g. N_2 =5 for 32-point FFT.
4- // the input should be width-N_2 to account for bit growth.
3+ // M is log base 2 of N (points in the FFT). e.g. M =5 for 32-point FFT.
4+ // the input should be width-M to account for bit growth.
55module fft
6- # (parameter width= 16 , N_2 = 5 )
6+ # (parameter width= 16 , M = 5 )
77 (input logic clk, // clock
88 input logic reset, // reset
99 input logic start, // pulse once loading is complete to begin calculation.
1010 input logic load, // when high, sample #`rd_adr` is read from `rd` to mem.
11- input logic [N_2 - 1 : 0 ] rd_adr, // index of the input sample.
11+ input logic [M - 1 : 0 ] rd_adr, // index of the input sample.
1212 input logic [2 * width- 1 : 0 ] rd, // read data in
1313 output logic [2 * width- 1 : 0 ] wd, // complex write data out
1414 output logic done); // stays high when complete until `reset` pulsed.
1515
1616 logic rdsel; // read from RAM0 or RAM1
1717 logic we0, we1; // RAMx write enable
18- logic [N_2 - 1 : 0 ] adr0a, adr0b, adr1a, adr1b;
19- logic [N_2 - 2 : 0 ] twiddleadr; // twiddle ROM adr
18+ logic [M - 1 : 0 ] adr0a, adr0b, adr1a, adr1b;
19+ logic [M - 2 : 0 ] twiddleadr; // twiddle ROM adr
2020 logic [2 * width- 1 : 0 ] twiddle, a, b, writea, writeb, aout, bout;
2121 logic [2 * width- 1 : 0 ] rd0a, rd0b, rd1a, rd1b, val_in;
2222
@@ -26,19 +26,19 @@ module fft
2626 assign writeb = load ? val_in : bout;
2727
2828 // output logic
29- assign wd = N_2 [0 ] ? rd1a : rd0a; // ram holding results depends on #fftLevels
29+ assign wd = M [0 ] ? rd1a : rd0a; // ram holding results depends on #fftLevels
3030
3131 // ping-pong read (BFU input) logic
3232 assign a = rdsel ? rd1a : rd0a;
3333 assign b = rdsel ? rd1b : rd0b;
3434
3535 // submodules
36- fft_twiddleROM # (width, N_2 ) twiddlerom (twiddleadr, twiddle);
37- fft_control # (width, N_2 ) control (clk, start, reset, load, rd_adr, done, rdsel,
36+ fft_twiddleROM # (width, M ) twiddlerom (twiddleadr, twiddle);
37+ fft_control # (width, M ) control (clk, start, reset, load, rd_adr, done, rdsel,
3838 we0, adr0a, adr0b, we1, adr1a, adr1b, twiddleadr);
3939
40- twoport_RAM # (width, N_2 ) ram0 (clk, we0, adr0a, adr0b, writea, writeb, rd0a, rd0b);
41- twoport_RAM # (width, N_2 ) ram1 (clk, we1, adr1a, adr1b, aout, bout, rd1a, rd1b);
40+ twoport_RAM # (width, M ) ram0 (clk, we0, adr0a, adr0b, writea, writeb, rd0a, rd0b);
41+ twoport_RAM # (width, M ) ram1 (clk, we1, adr1a, adr1b, aout, bout, rd1a, rd1b);
4242
4343 fft_butterfly # (width) bgu (twiddle, a, b, aout, bout);
4444
0 commit comments