-
Notifications
You must be signed in to change notification settings - Fork 0
/
fft_and_ifft.v
120 lines (110 loc) · 3.19 KB
/
fft_and_ifft.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
module fft_and_ifft(
input clk,
input isready, //输入缓冲队列读取信号
input [15:0] audio_input,
output source_valid_ifft, //ifft输出开始信号
output [15:0] source_real_ifft //ifft输出数据信号
);
//====================================
//Send to freq_change
//====================================
wire source_valid_fft; //fft输出开始信号
wire [15:0] source_real_fft; //fft输出实部
wire [15:0] source_imag_fft; //fft输出虚部
wire sink_ready_ifft; //ifft能够接收信号
//====================================
//receive from freq_change
//==================================
wire fc_is_output;
wire [15:0] sink_real_ifft;
wire [15:0] sink_imag_ifft;
//=====================================
//Don't care
//======================================
wire sink_ready_fft;
wire source_error_fft;
wire source_sop_fft;
wire source_eop_fft;
wire sink_error_ifft;
wire source_error_ifft;
wire source_sop_ifft;
wire source_eop_ifft;
wire [15:0] source_imag_ifft;
//=================================
//中间变量
//=================================
reg reach512_fft;
reg [8:0] cnt_fft;
reg reach512_ifft;
reg [8:0] cnt_ifft;
always @ (posedge clk)
begin
if(isready)
begin
if(cnt_fft == 511) begin reach512_fft <= 1;cnt_fft <= 0; end
else begin reach512_fft <= 0; cnt_fft <= cnt_fft + 1; end
end
else begin cnt_fft <= 0; reach512_fft <= 0; end
end
in_fft my_fft (
.clk (clk),
.reset_n (1'b1),
.sink_valid (1'b1),
.sink_ready (sink_ready_fft),
.sink_error (1'b0),
.sink_sop (isready),
.sink_eop (reach512_fft),
.sink_real (audio_input),
.sink_imag (16'b0),
.fftpts_in (512),
.inverse (1'b1),
.source_valid (source_valid_fft),
.source_ready (1'b1),
.source_error (source_error_fft),
.source_sop (source_sop_fft),
.source_eop (source_eop_fft),
.source_real (source_real_fft),
.source_imag (source_imag_fft),
.fftpts_out (512)
);
freq_change my_fc(
.clk(clk),
.source_real_fft(source_real_fft),
.source_imag_fft(source_imag_fft),
.source_valid_fft(source_valid_fft), //fft输出开始信号
.sink_ready_ifft(sink_ready_ifft), //ifft能够接收信号
.sink_real_ifft(sink_real_ifft),
.sink_imag_ifft(sink_imag_ifft),
.fc_is_output(fc_is_output)
);
always @ (posedge clk)
begin
if(fc_is_output)
begin
if(cnt_ifft == 511) begin reach512_ifft <= 1;cnt_ifft <= 0; end
else begin reach512_ifft <= 0; cnt_ifft <= cnt_ifft + 1; end
end
else begin cnt_ifft <= 0; reach512_ifft <= 0; end
end
in_fft my_ifft (
.clk (clk),
.reset_n (1'b1),
.sink_valid (1'b1),
.sink_ready (sink_ready_ifft),
.sink_error (sink_error_ifft),
.sink_sop (fc_is_output),
.sink_eop (reach512_ifft),
.sink_real (sink_real_ifft),
.sink_imag (sink_imag_ifft),
.fftpts_in (512),
.inverse (1'b1),
.source_valid (source_valid_ifft),
.source_ready (1'b1),
.source_error (source_error_ifft),
.source_sop (source_sop_ifft),
.source_eop (source_eop_ifft),
.source_real (source_real_ifft),
.source_imag (source_imag_ifft),
.fftpts_out (512)
);
endmodule