DspPipeline.v 5.4 KB

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