新闻  |   论坛  |   博客  |   在线研讨会
FFT至简设计法实现法_FFT算法_蝶形运算_明德扬资料
billow兔 | 2017-08-03 09:07:57    阅读:375   发布文章

DIT-FFT至简设计实现法

本案例是FFT的串行实现,但根据同样的思路和资源换速度的思想,可以很方便地实现多个并行或者全并行的设计。

 

3、至简设计代码实现(附录部分代码)

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

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

parameter  N   =   512;

parameter LOGN = 9;

 

/****************************************

/计数器架构,下面三个计数器用于产生读地址

****************************************/

always @(posedge clk or negedge   rst_n)begin

      if(!rst_n)begin

        cnt0 <= 0;

      end

      else if(add_cnt0)begin

        if(end_cnt0)

            cnt0 <= 0;

        else

            cnt0 <= cnt0 + 1;

      end

end

 

assign add_cnt0 = flag;

assign end_cnt0 = add_cnt0 &&   cnt0== (1<<cnt2)-1 ;

 

always @(posedge clk or negedge   rst_n)begin

      if(!rst_n)begin

        cnt1 <= 0;

      end

      else if(add_cnt1)begin

        if(end_cnt1)

            cnt1 <= 0;

        else

            cnt1 <= cnt1 + 1;

      end

end

 

assign add_cnt1 = end_cnt0;

assign end_cnt1 = add_cnt1 &&   cnt1==(N>>(cnt2+1))-1 ;

 

always @(posedge clk or negedge   rst_n)begin

      if(!rst_n)begin

        cnt2 <= 0;

      end

      else if(add_cnt2)begin

        if(end_cnt2)

            cnt2 <= 0;

        else

              cnt2 <= cnt2 + 1;

      end

end

 

assign add_cnt2 = end_cnt1;

assign end_cnt2 = add_cnt2 &&   cnt2==LOGN-1 ;

 

/****************************************

/计数器架构,下面三个计数器用于产生写地址

****************************************/

always @(posedge clk or negedge rst_n)begin

      if(!rst_n)begin

        wr_cnt0 <= 0;

      end

      else if(add_wr_cnt0)begin

        if(end_wr_cnt0)

            wr_cnt0 <= 0;

        else

            wr_cnt0 <= wr_cnt0 + 1;

      end

end

 

assign add_wr_cnt0 = fft_dout_vld;

assign end_wr_cnt0 = add_wr_cnt0   && wr_cnt0==(1<<wr_cnt2)-1 ;

 

always @(posedge clk or negedge   rst_n)begin

      if(!rst_n)begin

        wr_cnt1 <= 0;

      end

      else if(add_wr_cnt1)begin

        if(end_wr_cnt1)

            wr_cnt1 <= 0;

        else

            wr_cnt1 <= wr_cnt1 + 1;

      end

end

 

assign add_wr_cnt1 = end_wr_cnt0;

assign end_wr_cnt1 = add_wr_cnt1   && wr_cnt1==(N>>(wr_cnt2+1))-1 ;

 

always @(posedge clk or negedge   rst_n)begin

      if(!rst_n)begin

        wr_cnt2 <= 0;

      end

      else if(add_wr_cnt2)begin

          if(end_wr_cnt2)

            wr_cnt2 <= 0;

        else

            wr_cnt2 <= wr_cnt2 + 1;

      end

end

 

assign add_wr_cnt2 = end_wr_cnt1;

assign end_wr_cnt2 = add_wr_cnt2   && wr_cnt2==LOGN-1 ;

 

 

/************************************************

RAM1地址0的设计

************************************************/

 

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        addr_0 <= 0;

      end

      else if(wr_cnt2[0]==0) begin

        addr_0 <= cnt0 + cnt1*(1<<(cnt2+1));

      end

      else begin

        addr_0 <= wr_cnt0 +   wr_cnt1*(1<<(wr_cnt2+1));

      end

end

/************************************************

RAM1写数据0的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wdata_0 <= 0;

      end

      else begin

        wdata_0 <= fft_dout0;

      end

end

 

/************************************************

RAM1写请求0的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wrreq_0 <= 0;

      end

      else if(wr_cnt2[0]==1) begin

        wrreq_0 <= fft_dout_vld;

      end

      else begin

        wrreq_0 <= 0;

      end

end

 

/************************************************

RAM1地址1的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        addr_1 <= 0;

      end

      else if(wr_cnt2[0]==0) begin

        addr_1 <= cnt0 + cnt1*(1<<(cnt2+1)) + (1<<cnt2);

      end

      else begin

        addr_1 <= wr_cnt0 +   wr_cnt1*(1<<(wr_cnt2+1)) + (1<<wr_cnt2);

      end

end

/************************************************

RAM1写数据1的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wdata_1 <= 0;

      end

      else begin

        wdata_1 <= fft_dout1;

      end

end

 

/************************************************

RAM1写请求1的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wrreq_1 <= 0;

      end

      else if(wr_cnt2[0]==1)begin

        wrreq_1 <= fft_dout_vld;

      end

      else begin

        wrreq_1 <=  0;

      end

end

 

 

 

 

/************************************************

RAM2地址0的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        addr_2 <= 0;

      end

      else if(wr_cnt2[0]==1) begin

        addr_2 <= cnt0 + cnt1*(1<<(cnt2+1));

      end

      else begin

          addr_2 <= wr_cnt0 +   wr_cnt1*(1<<(wr_cnt2+1));

      end

end

 

/************************************************

RAM2写数据0的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wdata_2 <= 0;

      end

      else begin

        wdata_2 <= fft_dout0;

      end

end

 

/************************************************

RAM2写请求0的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wrreq_2 <= 0;

      end

      else if(wr_cnt2[0]==0) begin

        wrreq_2 <= fft_dout_vld;

      end

      else begin

        wrreq_2 <= 0;

      end

end

 

/************************************************

RAM2地址1的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        addr_3 <= 0;

      end

      else if(wr_cnt2[0]==1) begin

        addr_3 <= cnt0 + cnt1*(1<<(cnt2+1))   + (1<<cnt2);

      end

      else begin

        addr_3 <= wr_cnt0 +   wr_cnt1*(1<<(wr_cnt2+1)) + (1<<wr_cnt2);

      end

end

 

/************************************************

RAM2写数据1的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wdata_3 <= 0;

      end

      else begin

        wdata_3 <= fft_dout1;

      end

end

 

/************************************************

RAM2写请求1的设计

************************************************/

always  @(posedge clk or negedge rst_n)begin

      if(rst_n==1'b0)begin

        wrreq_3 <= 0;

      end

      else if(wr_cnt2[0]==0)begin

        wrreq_3 <= fft_dout_vld;

      end

      else begin

        wrreq_3 <=  0;

      end

end

 

 

 

 


*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客