DspPipeline.v 5.5 KB

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