DspPipeline.v 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. (* keep_hierarchy = "yes" *)
  2. module DspPipeline
  3. #(
  4. parameter AdcDataWidth = 14,
  5. parameter AccWidth = 48,
  6. parameter WindWidth = 14,
  7. parameter AdcCorrData = 20,
  8. parameter NcoWidth = 14,
  9. parameter ResultWidth = 32,
  10. parameter WindNormCoefWidth = 32,
  11. parameter WindCorrCoefWidth = 32,
  12. parameter IntermediateWidth = 14,
  13. parameter FracWidth = 51
  14. )
  15. (
  16. input Clk_i,
  17. input Rst_i,
  18. input Val_i,
  19. input StartFpConv_i,
  20. input [WindCorrCoefWidth-1:0] FilterCorrCoef_i,
  21. input [AdcCorrData-1:0] AdcData_i,
  22. input [WindWidth-1:0] Wind_i,
  23. input [NcoWidth-1:0] NcoSin_i,
  24. input [NcoWidth-1:0] NcoCos_i,
  25. input [WindNormCoefWidth-1:0] NormCoef_i,
  26. output [ResultWidth-1:0] CorrResultIm_o,
  27. output [ResultWidth-1:0] CorrResultRe_o,
  28. output CorrResultVal_o
  29. );
  30. //================================================================================
  31. // LOCALPARAMS
  32. localparam NormResultWidth = AccWidth+WindNormCoefWidth;
  33. localparam AdcWindWidth = 37;
  34. //================================================================================
  35. // REG/WIRE
  36. wire [AdcWindWidth-1:0] adcWindResult;
  37. wire adcWindResultVal;
  38. wire [54:0] adcWindSinResult;
  39. wire adcWindSinResultVal;
  40. wire [54:0] adcWindCosResult;
  41. wire adcWindCosResultVal;
  42. wire [AccWidth-1:0] AccResultI;
  43. wire AccResultIVal;
  44. wire [AccWidth-1:0] AccResultQ;
  45. wire AccResultQVal;
  46. wire [ResultWidth-1:0] NormResultI;
  47. wire NormResultIVal;
  48. wire [ResultWidth-1:0] NormResultQ;
  49. wire NormResultQVal;
  50. wire [ResultWidth-1:0] iFp32Result;
  51. wire iFp32ResultVal;
  52. wire [ResultWidth-1:0] qFp32Result;
  53. wire qFp32ResultVal;
  54. wire CorrResultReVal;
  55. wire CorrResultImVal;
  56. reg valReg;
  57. reg valRegReg;
  58. //================================================================================
  59. // ASSIGNMENTS
  60. assign CorrResultVal_o = CorrResultReVal&CorrResultImVal;
  61. //================================================================================
  62. // CODING
  63. always @(posedge Clk_i) begin
  64. if (!Rst_i) begin
  65. valReg <= Val_i;
  66. valRegReg <= valReg;
  67. end else begin
  68. valReg <= 0;
  69. valRegReg <= 0;
  70. end
  71. end
  72. //===============================Adc*Wind=========================================
  73. SimpleMult
  74. #(
  75. .FactorAWidth (AdcCorrData),
  76. .FactorBWidth (WindWidth),
  77. .OutputWidth (AdcWindWidth)
  78. )
  79. AdcWindMult
  80. (
  81. .Rst_i (Rst_i),
  82. .Clk_i (Clk_i),
  83. .Val_i (valRegReg),
  84. .FactorA_i (AdcData_i),
  85. .FactorB_i (Wind_i),
  86. .Result_o (adcWindResult),
  87. .ResultVal_o(adcWindResultVal)
  88. );
  89. //===============================AdcWind*NcoSinCos================================
  90. SimpleMult
  91. #(
  92. .FactorAWidth (AdcWindWidth),
  93. .FactorBWidth (NcoWidth),
  94. .OutputWidth (NcoWidth+AdcWindWidth)
  95. )
  96. AdcNcoSinMult
  97. (
  98. .Rst_i (Rst_i),
  99. .Clk_i (Clk_i),
  100. .Val_i (adcWindResultVal),
  101. .FactorA_i (adcWindResult),
  102. .FactorB_i (NcoSin_i),
  103. .Result_o (adcWindSinResult),
  104. .ResultVal_o(adcWindSinResultVal)
  105. );
  106. SimpleMult
  107. #(
  108. .FactorAWidth (AdcWindWidth),
  109. .FactorBWidth (NcoWidth),
  110. .OutputWidth (NcoWidth+AdcWindWidth)
  111. )
  112. AdcNcoCosMult
  113. (
  114. .Rst_i (Rst_i),
  115. .Clk_i (Clk_i),
  116. .Val_i (adcWindResultVal),
  117. .FactorA_i (adcWindResult),
  118. .FactorB_i (NcoCos_i),
  119. .Result_o (adcWindCosResult),
  120. .ResultVal_o(adcWindCosResultVal)
  121. );
  122. //===============================SumAcc===========================================
  123. SumAcc
  124. #(
  125. .IDataWidth (NcoWidth+AdcWindWidth-1),
  126. .ODataWidth (AccWidth)
  127. )
  128. SummAccQ
  129. (
  130. .Clk_i (Clk_i),
  131. .Rst_i (Rst_i),
  132. .Val_i (adcWindSinResultVal),
  133. .Data_i (adcWindSinResult[53:0]),
  134. .Result_o (AccResultQ),
  135. .ResultVal_o(AccResultQVal)
  136. );
  137. SumAcc
  138. #(
  139. .IDataWidth (NcoWidth+AdcWindWidth-1),
  140. .ODataWidth (AccWidth)
  141. )
  142. SummAccI
  143. (
  144. .Clk_i (Clk_i),
  145. .Rst_i (Rst_i),
  146. .Val_i (adcWindCosResultVal),
  147. .Data_i (adcWindCosResult[53:0]),
  148. .Result_o (AccResultI),
  149. .ResultVal_o(AccResultIVal)
  150. );
  151. //===============================InToFpConv=======================================
  152. MyIntToFp
  153. #(
  154. .InWidth (AccWidth),
  155. .ExpWidth (8),
  156. .ManWidth (23),
  157. .FracWidth (FracWidth)
  158. )
  159. QToFp32
  160. (
  161. .Clk_i (Clk_i),
  162. .Rst_i (Rst_i),
  163. .InData_i (AccResultQ),
  164. .InDataVal_i (StartFpConv_i),
  165. .OutData_o (qFp32Result),
  166. .OutDataVal_o (qFp32ResultVal)
  167. );
  168. MyIntToFp
  169. #(
  170. .InWidth (AccWidth),
  171. .ExpWidth (8),
  172. .ManWidth (23),
  173. .FracWidth (FracWidth)
  174. )
  175. IToFp32
  176. (
  177. .Clk_i (Clk_i),
  178. .Rst_i (Rst_i),
  179. .InData_i (AccResultI),
  180. .InDataVal_i (StartFpConv_i),
  181. .OutData_o (iFp32Result),
  182. .OutDataVal_o (iFp32ResultVal)
  183. );
  184. //===============================Result*NormCoeff=================================
  185. FpCustomMultiplier
  186. # (
  187. .ManWidth (23),
  188. .ExpWidth (8)
  189. )
  190. ResultQNorm
  191. (
  192. .Rst_i (Rst_i),
  193. .Clk_i (Clk_i),
  194. .A_i (qFp32Result),
  195. .B_i (NormCoef_i),
  196. .Nd_i (qFp32ResultVal),
  197. .Result_o (NormResultQ),
  198. .ResultValid_o (NormResultQVal)
  199. );
  200. FpCustomMultiplier
  201. # (
  202. .ManWidth (23),
  203. .ExpWidth (8)
  204. )
  205. ResultINorm
  206. (
  207. .Rst_i (Rst_i),
  208. .Clk_i (Clk_i),
  209. .A_i (iFp32Result),
  210. .B_i (NormCoef_i),
  211. .Nd_i (iFp32ResultVal),
  212. .Result_o (NormResultI),
  213. .ResultValid_o (NormResultIVal)
  214. );
  215. //===============================NormResult*CorrCoeff========================
  216. FpCustomMultiplier
  217. # (
  218. .ManWidth (23),
  219. .ExpWidth (8)
  220. )
  221. ResultReCorr
  222. (
  223. .Rst_i (Rst_i),
  224. .Clk_i (Clk_i),
  225. .A_i (NormResultQ),
  226. .B_i (FilterCorrCoef_i),
  227. .Nd_i (NormResultQVal),
  228. .Result_o (CorrResultRe_o),
  229. .ResultValid_o (CorrResultReVal)
  230. );
  231. FpCustomMultiplier
  232. # (
  233. .ManWidth (23),
  234. .ExpWidth (8)
  235. )
  236. ResultImCorr
  237. (
  238. .Rst_i (Rst_i),
  239. .Clk_i (Clk_i),
  240. .A_i (NormResultI),
  241. .B_i (FilterCorrCoef_i),
  242. .Nd_i (NormResultIVal),
  243. .Result_o (CorrResultIm_o),
  244. .ResultValid_o (CorrResultImVal)
  245. );
  246. endmodule