| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- (* keep_hierarchy = "yes" *)
- module DspPipeline
- #(
- parameter AdcDataWidth = 14,
- parameter AccWidth = 48,
- parameter WindWidth = 14,
- parameter AdcCorrData = 20,
- parameter NcoWidth = 14,
- parameter ResultWidth = 32,
- parameter WindNormCoefWidth = 32,
- parameter WindCorrCoefWidth = 32,
- parameter IntermediateWidth = 14,
- parameter FracWidth = 51
- )
- (
- input Clk_i,
- input Rst_i,
- input Val_i,
- input StartFpConv_i,
-
- input [WindCorrCoefWidth-1:0] FilterCorrCoef_i,
- input [WindCorrCoefWidth-1:0] AverageNoizeLvl_i,
- input [AdcCorrData-1:0] AdcData_i,
- input [WindWidth-1:0] Wind_i,
- input [NcoWidth-1:0] NcoSin_i,
- input [NcoWidth-1:0] NcoCos_i,
- input [WindNormCoefWidth-1:0] NormCoef_i,
-
- output [ResultWidth-1:0] CorrResultIm_o,
- output [ResultWidth-1:0] CorrResultRe_o,
- output CorrResultVal_o
- );
- //================================================================================
- // LOCALPARAMS
- localparam NormResultWidth = AccWidth+WindNormCoefWidth;
- localparam AdcWindWidth = 37;
- //================================================================================
- // REG/WIRE
- wire [AdcWindWidth-1:0] adcWindResult;
- wire adcWindResultVal;
-
- wire [54:0] adcWindSinResult;
- wire adcWindSinResultVal;
- wire [54:0] adcWindCosResult;
- wire adcWindCosResultVal;
-
- wire [AccWidth-1:0] AccResultI;
- wire [AccWidth-1:0] AccResultQ;
-
- wire [ResultWidth-1:0] NormResultI;
- wire NormResultIVal;
- wire [ResultWidth-1:0] NormResultQ;
- wire NormResultQVal;
-
- wire [ResultWidth-1:0] iFp32Result;
- wire iFp32ResultVal;
- wire [ResultWidth-1:0] qFp32Result;
- wire qFp32ResultVal;
-
- wire CorrResultReVal;
- wire CorrResultImVal;
-
- reg valReg;
- reg valRegReg;
- //================================================================================
- // ASSIGNMENTS
- assign CorrResultVal_o = CorrResultReVal&CorrResultImVal;
-
- //================================================================================
- // CODING
- always @(posedge Clk_i) begin
- if (!Rst_i) begin
- valReg <= Val_i;
- valRegReg <= valReg;
- end else begin
- valReg <= 0;
- valRegReg <= 0;
- end
- end
-
- //===============================Adc*Wind=========================================
- SimpleMult
- #(
- .FactorAWidth (AdcCorrData),
- .FactorBWidth (WindWidth),
- .OutputWidth (AdcWindWidth)
- )
- AdcWindMult
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .Val_i (valRegReg),
- .FactorA_i (AdcData_i),
- .FactorB_i (Wind_i),
- .Result_o (adcWindResult),
- .ResultVal_o(adcWindResultVal)
- );
- //===============================AdcWind*NcoSinCos================================
- SimpleMult
- #(
- .FactorAWidth (AdcWindWidth),
- .FactorBWidth (NcoWidth),
- .OutputWidth (NcoWidth+AdcWindWidth)
- )
- AdcNcoSinMult
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .Val_i (adcWindResultVal),
- .FactorA_i (adcWindResult),
- .FactorB_i (NcoSin_i),
- .Result_o (adcWindSinResult),
- .ResultVal_o(adcWindSinResultVal)
- );
- SimpleMult
- #(
- .FactorAWidth (AdcWindWidth),
- .FactorBWidth (NcoWidth),
- .OutputWidth (NcoWidth+AdcWindWidth)
- )
- AdcNcoCosMult
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .Val_i (adcWindResultVal),
- .FactorA_i (adcWindResult),
- .FactorB_i (NcoCos_i),
- .Result_o (adcWindCosResult),
- .ResultVal_o(adcWindCosResultVal)
- );
- //===============================SumAcc===========================================
- SumAcc
- #(
- .IDataWidth (NcoWidth+AdcWindWidth-1),
- .ODataWidth (AccWidth)
- )
- SummAccQ
- (
- .Clk_i (Clk_i),
- .Rst_i (Rst_i),
- .Val_i (adcWindSinResultVal),
-
- .Data_i (adcWindSinResult[53:0]),
- .Result_o (AccResultQ)
- );
- SumAcc
- #(
- .IDataWidth (NcoWidth+AdcWindWidth-1),
- .ODataWidth (AccWidth)
- )
- SummAccI
- (
- .Clk_i (Clk_i),
- .Rst_i (Rst_i),
- .Val_i (adcWindCosResultVal),
-
- .Data_i (adcWindCosResult[53:0]),
- .Result_o (AccResultI)
- );
- //===============================InToFpConv=======================================
- MyIntToFp
- #(
- .InWidth (AccWidth),
- .ExpWidth (8),
- .ManWidth (23),
- .FracWidth (FracWidth)
- )
- QToFp32
- (
- .Clk_i (Clk_i),
- .Rst_i (Rst_i),
- .InData_i (AccResultQ),
- .AverageNoizeLvl_i (AverageNoizeLvl_i),
- .InDataVal_i (StartFpConv_i),
- .OutData_o (qFp32Result),
- .OutDataVal_o (qFp32ResultVal)
- );
- MyIntToFp
- #(
- .InWidth (AccWidth),
- .ExpWidth (8),
- .ManWidth (23),
- .FracWidth (FracWidth)
- )
- IToFp32
- (
- .Clk_i (Clk_i),
- .Rst_i (Rst_i),
- .InData_i (AccResultI),
- .AverageNoizeLvl_i (AverageNoizeLvl_i),
- .InDataVal_i (StartFpConv_i),
- .OutData_o (iFp32Result),
- .OutDataVal_o (iFp32ResultVal)
- );
- //===============================Result*NormCoeff=================================
- FpCustomMultiplier
- # (
- .ManWidth (23),
- .ExpWidth (8)
- )
- ResultQNorm
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .A_i (qFp32Result),
- .B_i (NormCoef_i),
- .Nd_i (qFp32ResultVal),
- .Result_o (NormResultQ),
- .ResultValid_o (NormResultQVal)
- );
- FpCustomMultiplier
- # (
- .ManWidth (23),
- .ExpWidth (8)
- )
- ResultINorm
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .A_i (iFp32Result),
- .B_i (NormCoef_i),
- .Nd_i (iFp32ResultVal),
- .Result_o (NormResultI),
- .ResultValid_o (NormResultIVal)
- );
- //===============================NormResult*CorrCoeff========================
- FpCustomMultiplier
- # (
- .ManWidth (23),
- .ExpWidth (8)
- )
- ResultReCorr
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .A_i (NormResultQ),
- .B_i (FilterCorrCoef_i),
- .Nd_i (NormResultQVal),
- .Result_o (CorrResultRe_o),
- .ResultValid_o (CorrResultReVal)
- );
- FpCustomMultiplier
- # (
- .ManWidth (23),
- .ExpWidth (8)
- )
- ResultImCorr
- (
- .Rst_i (Rst_i),
- .Clk_i (Clk_i),
- .A_i (NormResultI),
- .B_i (FilterCorrCoef_i),
- .Nd_i (NormResultIVal),
- .Result_o (CorrResultIm_o),
- .ResultValid_o (CorrResultImVal)
- );
- endmodule
|