Pārlūkot izejas kodu

Merge branch 'S5443' into S5243_minor_merge_gen_filt

Mihail Zaytsev 2 gadi atpakaļ
vecāks
revīzija
1491a42965

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 44 - 12
S5443_M/S5443.srcs/constrs_1/new/S5443Top.xdc


+ 28 - 28
S5443_M/S5443.srcs/sources_1/new/ExtDspInterface/DspInterface.v

@@ -229,33 +229,33 @@ DecimFilterWrapper	DecimFilter
 	.FilteredDataVal_o	(filteredDecimDataVal)
 );
 
-FftDataFormer	FftDataFormerInst
-(
-	.Clk_i				(Clk_i), 
-	.Rst_i				(Rst_i),	
-	.OscWind_i			(OscWind_i),
-	.MeasNum_i			(MeasNum_i),
-	
-	.AdcData_i			({filteredDecimDataI,filteredDecimDataQ}),
+// FftDataFormer	FftDataFormerInst
+// (
+	// .Clk_i				(Clk_i), 
+	// .Rst_i				(Rst_i),	
+	// .OscWind_i			(OscWind_i),
+	// .MeasNum_i			(MeasNum_i),
+	
+	// .AdcData_i			({filteredDecimDataI,filteredDecimDataQ}),
 	// .AdcData_i			({testPatternData,testPatternData}),
-	.AdcDataVal_i		(filteredDecimDataVal),
+	// .AdcDataVal_i		(filteredDecimDataVal),
 	
-	.OscDataBus_o		(fftDataBus),
-	.OscDataBusVal_o	(fftDataBusVal)
-);
+	// .OscDataBus_o		(fftDataBus),
+	// .OscDataBusVal_o	(fftDataBusVal)
+// );
 
-OscDataFormer	BypassDataFormer
-(
-	.Clk_i				(Clk_i), 
-	.Rst_i				(Rst_i),	
-	.OscWind_i			(OscWind_i),
-	.MeasNum_i			(MeasNum_i),
-	
-	.AdcData_i			(currDataChannel),	
-	
-	.OscDataBus_o		(bypassDataBus),
-	.OscDataBusVal_o	(bypassDataBusVal)
-);
+// OscDataFormer	BypassDataFormer
+// (
+	// .Clk_i				(Clk_i), 
+	// .Rst_i				(Rst_i),	
+	// .OscWind_i			(OscWind_i),
+	// .MeasNum_i			(MeasNum_i),
+	
+	// .AdcData_i			(currDataChannel),	
+	
+	// .OscDataBus_o		(bypassDataBus),
+	// .OscDataBusVal_o	(bypassDataBusVal)
+// );
 
 always	@(posedge	Clk_i)	begin
 	if	(!Rst_i)	begin
@@ -290,10 +290,10 @@ MeasDataFifoInst
 	.MeasNum_i		(MeasNum_i),	
 	.StartMeasDsp_i	(StartMeasDsp_i),	
 	.DspReadyForRx_i(DspReadyForRx_i),	
-	// .MeasDataBus_i	(measDataBus),
-	.MeasDataBus_i	(dataForFifo),
-	// .MeasDataVal_i	(LpOutStart_i),	
-	.MeasDataVal_i	(dataForFifoVal),	
+	.MeasDataBus_i	(measDataBus),
+	// .MeasDataBus_i	(dataForFifo),
+	.MeasDataVal_i	(LpOutStart_i),	
+	// .MeasDataVal_i	(dataForFifoVal),	
 	
 	.MeasDataBus_o	(measDataBusTx),
 	.MeasDataVal_o	(measDataValTx)

+ 62 - 35
S5443_M/S5443.srcs/sources_1/new/FftDataFiltering/DecimFilterWrapper.v

@@ -23,7 +23,7 @@ module	DecimFilterWrapper
 	parameter	AdcDataWidth		=	14,
 	parameter	N	=	4,
 	parameter	M	=	1,
-	parameter	FilteredDataWidth	=	28,
+	parameter	FilteredDataWidth	=	29,
 	parameter	FirOutDataWidth		=	48,
 	parameter	FirOutCutBit		=	42
 )
@@ -38,8 +38,8 @@ module	DecimFilterWrapper
 	
 	input	signed	[AdcDataWidth-1:0]	AdcData_i,
 	
-	output	signed	[AdcDataWidth+1:0]	FilteredAdcDataI_o,
-	output	signed	[AdcDataWidth+1:0]	FilteredAdcDataQ_o,
+	output	signed	[16-1:0]	FilteredAdcDataI_o,
+	output	signed	[16-1:0]	FilteredAdcDataQ_o,
 	output	FilteredDataVal_o
 );
 //================================================================================
@@ -48,7 +48,9 @@ module	DecimFilterWrapper
 	wire	signed	[FilteredDataWidth-1:0]	decimDataI;
 	wire	signed	[FilteredDataWidth-1:0]	decimDataQ;
 	wire	decimDataValI;
+	reg		decimDataValIR;
 	wire	decimDataValQ;
+	reg		decimDataValQR;
 	
 	wire	signed	[FirOutDataWidth-1:0]	firDataOut;
 	wire	firDataOutVal;
@@ -56,15 +58,16 @@ module	DecimFilterWrapper
 	wire	[AdcDataWidth-1:0]	ncoCos;
 	wire	[AdcDataWidth-1:0]	ncoSin;
 	
-	wire	[FilteredDataWidth-1:0]	adcSinResult;
+	wire	[AdcDataWidth-1:0]	adcSinResult;
 	wire	adcSinVal;
-	wire	[FilteredDataWidth-1:0]	adcCosResult;
+	wire	[AdcDataWidth-1:0]	adcCosResult;
 	wire	adcCosVal;
 	
 	reg		[24-1:0]	ifFtwLReg;
 	reg		[24-1:0]	ifFtwHReg;
 	
-	reg		[FilteredDataWidth-1:0]	outData;
+	reg		[15:0]	outDataI;
+	reg		[15:0]	outDataQ;
 	
 	localparam	maxWidthForR2	=	5'd18;	//msb for R = 2;
 	localparam	maxWidthForR3	=	5'd21;	//msb for R = 3;
@@ -72,18 +75,24 @@ module	DecimFilterWrapper
 	localparam	maxWidthForR5	=	5'd24;	//msb for R = 5;
 	localparam	maxWidthForR6	=	5'd25;	//msb for R = 6;
 	localparam	maxWidthForR7	=	5'd26;	//msb for R = 7;
-	localparam	maxWidthForR8	=	5'd26;	//msb for R = 8;
-	localparam	maxWidthForR9	=	5'd27;	//msb for R = 9;
-	localparam	maxWidthForR10	=	5'd28;	//msb for R = 10;
+	// localparam	maxWidthForR8	=	5'd26;	//msb for R = 8;
+	// localparam	maxWidthForR9	=	5'd27;	//msb for R = 9;
+	// localparam	maxWidthForR10	=	5'd28;	//msb for R = 10;
 	
 //================================================================================
 //	ASSIGNMENTS
 //================================================================================
 
-	assign	FilteredAdcDataI_o	=	decimDataI[FilteredDataWidth-1-:AdcDataWidth+2];
-	assign	FilteredAdcDataQ_o	=	decimDataQ[FilteredDataWidth-1-:AdcDataWidth+2];
+	assign	FilteredAdcDataI_o	=	outDataI;
+	// assign	FilteredAdcDataI_o	=	decimDataI;
+	assign	FilteredAdcDataQ_o	=	outDataQ;
+	// assign	FilteredAdcDataQ_o	=	decimDataQ;
+	// assign	FilteredDataVal_o	=	decimDataValIR&decimDataValQR;
 	assign	FilteredDataVal_o	=	decimDataValI&decimDataValQ;
-	
+
+
+// {{14{AdcData_i[AdcDataWidth-1]}},AdcData_i}
+
 //================================================================================
 //	CODING
 //================================================================================
@@ -92,35 +101,47 @@ always	@(posedge	Clk_i)	begin
 	if	(!Rst_i)	begin
 		case(DecimFactor_i)
 			3'd2:	begin
-						outData	<=	{{FilteredDataWidth-maxWidthForR2{decimDataI[FilteredDataWidth-1]}},decimDataI[maxWidthForR2-1:0]};
+						outDataI	<=	decimDataI[maxWidthForR2-:16];
+						outDataQ	<=	decimDataQ[maxWidthForR2-:16];
+						decimDataValIR	<=	decimDataValI;
+						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd3:	begin
-						outData	<=	decimDataI[maxWidthForR3-1:0];
+						outDataI	<=	decimDataI[maxWidthForR3-:16];
+						outDataQ	<=	decimDataQ[maxWidthForR3-:16];
+						decimDataValIR	<=	decimDataValI;
+						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd4:	begin
-						outData	<=	decimDataI[maxWidthForR4-1:0];
+						outDataI	<=	decimDataI[maxWidthForR4-:16];
+						outDataQ	<=	decimDataQ[maxWidthForR4-:16];
+						decimDataValIR	<=	decimDataValI;
+						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd5:	begin
-						outData	<=	decimDataI[maxWidthForR5-1:0];
+						outDataI	<=	decimDataI[maxWidthForR5-:16];
+						outDataQ	<=	decimDataQ[maxWidthForR5-:16];
+						decimDataValIR	<=	decimDataValI;
+						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd6:	begin
-						outData	<=	decimDataI[maxWidthForR6-1:0];
+						outDataI	<=	decimDataI[maxWidthForR6-:16];
+						outDataQ	<=	decimDataQ[maxWidthForR6-:16];
+						decimDataValIR	<=	decimDataValI;
+						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd7:	begin
-						outData	<=	decimDataI[maxWidthForR7-1:0];
-					end
-			3'd8:	begin
-						outData	<=	decimDataI[maxWidthForR8-1:0];
-					end
-			3'd9:	begin
-						outData	<=	decimDataI[maxWidthForR9-1:0];
-					end
-			3'd10:	begin
-						outData	<=	decimDataI[maxWidthForR10-1:0];
+						outDataI	<=	decimDataI[maxWidthForR7-:16];
+						outDataQ	<=	decimDataQ[maxWidthForR7-:16];
+						decimDataValIR	<=	decimDataValI;
+						decimDataValQR	<=	decimDataValQ;
 					end
 		endcase
 	end	else	begin
-		outData	<=	5'd0;
+		outDataI	<=	16'd0;
+		outDataQ	<=	16'd0;
+		decimDataValIR	<=	1'b0;
+		decimDataValQR	<=	1'b0;
 	end
 end
 
@@ -146,7 +167,8 @@ ncoInst
 	.Clk_i		(Clk_i),
 	.Rst_i		(Rst_i),
 	.Val_i		(1'b1),
-	.PhaseInc_i	({ifFtwHReg[0+:32-24],ifFtwLReg}),
+	// .PhaseInc_i	({ifFtwHReg[0+:32-24],ifFtwLReg}),
+	.PhaseInc_i	(32'h3eb851eb),
 	.WindVal_i	(1'b1),
 	.WinType_i	(),
 	.Wind_o		(),
@@ -159,7 +181,7 @@ SimpleMult
 #(	
 	.FactorAWidth	(AdcDataWidth),
 	.FactorBWidth	(AdcDataWidth),
-	.OutputWidth	(FilteredDataWidth)
+	.OutputWidth	(AdcDataWidth)
 )
 AdcNcoSinMult	
 (
@@ -168,6 +190,7 @@ AdcNcoSinMult
 	.Val_i		(1'b1),
 	.FactorA_i	(ncoSin),
 	.FactorB_i	(AdcData_i),	
+	// .FactorB_i	(ncoSin),	
 	.Result_o	(adcSinResult),
 	.ResultVal_o(adcSinVal)
 );
@@ -176,7 +199,7 @@ SimpleMult
 #(	
 	.FactorAWidth	(AdcDataWidth),
 	.FactorBWidth	(AdcDataWidth),
-	.OutputWidth	(FilteredDataWidth)
+	.OutputWidth	(AdcDataWidth)
 )
 AdcNcoCosMult	
 (
@@ -185,6 +208,7 @@ AdcNcoCosMult
 	.Val_i		(1'b1),
 	.FactorA_i	(ncoCos),
 	.FactorB_i	(AdcData_i),
+	// .FactorB_i	(ncoSin),
 	.Result_o	(adcCosResult),
 	.ResultVal_o(adcCosVal)
 );
@@ -202,8 +226,8 @@ cicFilterInstI
 	.Clk_i			(Clk_i),
 	.Rst_i			(Rst_i),
 	.DecimFactor_i	(DecimFactor_i),
-	.Data_i			({{14{AdcData_i[AdcDataWidth-1]}},AdcData_i}),
-	// .Data_i			(adcCosResult),
+	.Data_i			({{15{adcCosResult[AdcDataWidth-1]}},adcCosResult}),
+	// .Data_i			({{15{AdcData_i[AdcDataWidth-1]}},AdcData_i}),
 	.DataNd_i		(OscWind_i),
 	.Data_o			(decimDataI),
 	.DataValid_o	(decimDataValI)
@@ -222,8 +246,8 @@ cicFilterInstQ
 	.Clk_i			(Clk_i),
 	.Rst_i			(Rst_i),
 	.DecimFactor_i	(DecimFactor_i),
-	.Data_i			({{14{AdcData_i[AdcDataWidth-1]}},AdcData_i}),
-	// .Data_i			(adcSinResult),
+	.Data_i			({{15{adcSinResult[AdcDataWidth-1]}},adcSinResult}),
+	// .Data_i			({{15{AdcData_i[AdcDataWidth-1]}},AdcData_i}),
 	.DataNd_i		(OscWind_i),
 	.Data_o			(decimDataQ),
 	.DataValid_o	(decimDataValQ)
@@ -245,3 +269,6 @@ endmodule
 
 
 
+
+
+

+ 1 - 1
S5443_M/S5443.srcs/sources_1/new/FftDataFiltering/cicFilter.v

@@ -3,7 +3,7 @@ module cicFilter
 	parameter N = 2,	//filter order
 	parameter M = 1,	//comb delay
 	// parameter R = 4,	//decim fartor
-	parameter	filteredDataWidth	=	24,
+	parameter	filteredDataWidth	=	28,
 	parameter	inOutDataWidth	=	16,
 	parameter	decimCntWidth	=	7
 )

+ 33 - 36
S5443_M/S5443.srcs/sources_1/new/InternalDsp/InternalDsp.v

@@ -84,7 +84,8 @@ module InternalDsp
 	
 	output	wire	MeasDataRdy_o,
 	output	wire	MeasWind_o,
-	output	wire	MeasEnd_o
+	output	wire	MeasEnd_o,
+	output	wire	SampleStrobeGenRst_o
 );
 
 //================================================================================
@@ -143,9 +144,11 @@ module InternalDsp
 	wire	[CorrAdcDataWidth-1:0]	adc2ChT2DataGated	=	(GatingPulse_i)?	adcDataBusExt[ChNum-1]:{CorrAdcDataWidth{1'b0}};	
 	
 	wire	[WindNcoPhIncWidth-1:0]	ncoPhInc = {ifFtwHReg[0+:WindNcoPhIncWidth-CmdDataRegWith],ifFtwLReg};
+	
 //================================================================================
 //  ASSIGNMENTS
 	
+	
 	// assign	adcDataBus	[ChNum-1]	=	Adc2ChT2Data_i;
 	// assign	adcDataBus	[ChNum-2]	=	Adc2ChR2Data_i;
 	// assign	adcDataBus	[ChNum-3]	=	Adc1ChR1Data_i;
@@ -185,6 +188,7 @@ module InternalDsp
 	assign	MeasWind_o	=	measWind;
 	
 	assign	CalModeDone_o	=	&calDone;
+	
 //================================================================================
 //  INSTANTIATIONS
 
@@ -213,43 +217,37 @@ always	@(posedge	Clk_i)	begin
 	end 
 end
 
-// PseudoRandomGenerator	RandomGenInst
-// (
-	// .Rst_i	(Rst_i),
-	// .Clk_i	(Clk_i),
-	// .Data_o	()
-// );
-
 MeasCtrlModule	
 #(	
 	.WindPNumWidth	(WindPNumWidth)
 )
 MeasCtrlModule	
 (
-	.Clk_i				(Clk_i),
-	.Rst_i				(Rst_i),
-	.OscWind_o			(OscWind_o),
-	.FilterCmd_i		(measCtrlReg[15-:8]),
-	
-	.MeasNum_i			(measNumReg),
-	.StartMeas_i		(StartMeas_i),
-	.StartMeasDsp_i		(StartMeasDsp_i),
-	.Mode_i				(measCtrlReg[0]),
-	.OscDataRdFlag_i	(OscDataRdFlag_i),
-	
-	.WindPointsNum_i	(windPointsNumReg),
-	
-	.WindPhInc_i		(windPhInc),
-	.WindPhIncStart_i	(winPhIncStart),
-	.WindArg_o			(windArg),
-	
-	.StartFpConv_o		(StartFpConv),
-	.MeasWind_o			(measWind),
-	.MeasWindDel_o		(measWindDelayed),
-	.StopMeas_o			(stopMeas),
-	.MeasEnd_o			(MeasEnd_o),
-	.WinCtrl_o			(winCtrl),
-	.TukeyCtrl_o		(tukeyCtrl)
+	.Clk_i					(Clk_i),
+	.Rst_i					(Rst_i),
+	.OscWind_o				(OscWind_o),
+	.FilterCmd_i			(measCtrlReg[15-:8]),
+		
+	.MeasNum_i				(measNumReg),
+	.StartMeas_i			(StartMeas_i),
+	.StartMeasDsp_i			(StartMeasDsp_i),
+	.Mode_i					(measCtrlReg[0]),
+	.OscDataRdFlag_i		(OscDataRdFlag_i),
+		
+	.WindPointsNum_i		(windPointsNumReg),
+		
+	.WindPhInc_i			(windPhInc),
+	.WindPhIncStart_i		(winPhIncStart),
+	.WindArg_o				(windArg),
+		
+	.StartFpConv_o			(StartFpConv),
+	.MeasWind_o				(measWind),
+	.MeasWindDel_o			(measWindDelayed),
+	.StopMeas_o				(stopMeas),
+	.MeasEnd_o				(MeasEnd_o),
+	.WinCtrl_o				(winCtrl),
+	.TukeyCtrl_o			(tukeyCtrl),
+	.SampleStrobeGenRst_o	(SampleStrobeGenRst_o)
 );	
 
 //----------------------------------------------
@@ -311,11 +309,10 @@ ncoInst
 	.WinType_i	(),
 	.Wind_o		(),
 	.Sin_o		(ncoSin),
-	.Cos_o		(ncoCos),
+	.Cos_o		(ncoCos),	
 	.Val_o		()
 );
 
-
 ComplPrng
 #(
 	.DataPrngWidth	(8),
@@ -383,8 +380,8 @@ generate
 			.AverageNoizeLvl_i	(averageNoizeLvl),
 			.AdcData_i			(gatedAdcDataBus[g]),
 			.Wind_i				(wind),
-			.NcoSin_i			(ncoCos),
-			.NcoCos_i			(ncoSin),	
+			.NcoSin_i			(ncoSin),
+			.NcoCos_i			(ncoCos),	
 			.NormCoef_i			(windNormCoef),
 
 			.CorrResultIm_o		(resultImBus[g]),

+ 25 - 10
S5443_M/S5443.srcs/sources_1/new/InternalDsp/MeasCtrlModule.v

@@ -48,6 +48,7 @@ module MeasCtrlModule
 	output	StopMeas_o,
 	output	MeasEnd_o,
 	output	WinCtrl_o,
+	output	SampleStrobeGenRst_o,
 	output	[1:0]	TukeyCtrl_o
 );
 
@@ -102,21 +103,35 @@ module MeasCtrlModule
 	wire	decrPhase	=	(pNumCnt	>=	tukeySecondCosValues-1	&	pNumCnt	<=	WindPointsNum_i-1);
 	
 	wire	wideFilterFlag	=	(FilterCmd_i>=8'h54	&	FilterCmd_i!=8'h70);
-
+	
+	reg		sampleStrobeGenRst;
 //================================================================================
 //  ASSIGNMENTS
-	assign	StartFpConv_o		=	startFpConvPipe	[2];
-	assign	MeasWind_o			=	measWind;
-	assign	MeasWindDel_o		=	measWindR;
-	assign	StopMeas_o			=	pMeasEnd;
-	assign	MeasEnd_o			=	stopMeasCmd;
-	assign	WindArg_o			=	windArg;
-	assign	OscWind_o			=	oscWind;
-	assign	TukeyCtrl_o			=	tukeyCtrl;
-	assign	WinCtrl_o			=	(pNumCnt<=tukeyFirstCosValuesDiv2+1|pNumCnt>tukeySecondCosValuesDiv2);
+	assign	StartFpConv_o			=	startFpConvPipe	[2];
+	assign	MeasWind_o				=	measWind;
+	assign	MeasWindDel_o			=	measWindR;
+	assign	StopMeas_o				=	pMeasEnd;
+	assign	MeasEnd_o				=	stopMeasCmd;
+	assign	WindArg_o				=	windArg;
+	assign	OscWind_o				=	oscWind;
+	assign	TukeyCtrl_o				=	tukeyCtrl;
+	assign	WinCtrl_o				=	(pNumCnt<=tukeyFirstCosValuesDiv2+1|pNumCnt>tukeySecondCosValuesDiv2);
+	assign	SampleStrobeGenRst_o	=	sampleStrobeGenRst;
 //================================================================================
 //  CODING
 	
+	always	@(posedge	Clk_i)	begin
+		if	(!Rst_i)	begin
+			if	(measCnt	==	MeasNum_i-1	&	measWind)	begin
+				sampleStrobeGenRst	<=	1'b1;
+			end	else	begin
+				sampleStrobeGenRst	<=	1'b0;
+			end
+		end	else	begin
+			sampleStrobeGenRst	<=	1'b0;
+		end
+	end
+	
 	always	@(*)	begin
 		if	(!Rst_i)	begin
 			if	(measWind)	begin

+ 1 - 0
S5443_M/S5443.srcs/sources_1/new/InternalDsp/Win_calc.v

@@ -53,6 +53,7 @@ module Win_calc	(
 	reg	[35:0]	sinWindPow2;
 	
 	wire	sinFilterFlag	=	(filterCmd_i>=8'h54	&	filterCmd_i<=8'h62);
+	// wire	rectFilterFlag	=	(filterCmd_i>=8'h63	&	filterCmd_i!=8'h70)|filterCmd_i==8'h30;
 	wire	rectFilterFlag	=	(filterCmd_i>=8'h63	&	filterCmd_i!=8'h70);
 	
 	wire	[17:0]	bSin	=	win_value_i[31]	?	18'h3FFFF	-	win_value_i[31:14]	:	win_value_i	[31:14];

+ 60 - 56
S5443_M/S5443.srcs/sources_1/new/S5443Top.v

@@ -400,6 +400,8 @@ module	S5443Top
 	reg		dspReadyForRxReg;
 	reg		dspReadyForRxRegR;
 	reg		dspReadyForRxRegRR;
+	
+	wire	sampleStrobeGenRst;
 //================================================================================
 //  assignments
 //================================================================================	
@@ -699,15 +701,15 @@ ExternalDspInterface
 	
 	.OscDataRdFlag_o	(oscDataRdFlag),
 	
-	// .Adc1ChT1Data_i		(adc1ChT1Data),	
-	// .Adc1ChR1Data_i		(adc1ChR1Data),	
-	// .Adc2ChR2Data_i		(adc2ChT2Data),	
-	// .Adc2ChT2Data_i		(adc2ChR2Data),	
+	.Adc1ChT1Data_i		(adc1ChT1Data),	
+	.Adc1ChR1Data_i		(adc1ChR1Data),	
+	.Adc2ChR2Data_i		(adc2ChR2Data),	
+	.Adc2ChT2Data_i		(adc2ChT2Data),	
 
-	.Adc1ChT1Data_i		(AdcData_i),	
-	.Adc1ChR1Data_i		(AdcData_i),	
-	.Adc2ChR2Data_i		(AdcData_i),	
-	.Adc2ChT2Data_i		(AdcData_i),	
+	// .Adc1ChT1Data_i		(AdcData_i),	
+	// .Adc1ChR1Data_i		(AdcData_i),	
+	// .Adc2ChR2Data_i		(AdcData_i),	
+	// .Adc2ChT2Data_i		(AdcData_i),	
 	
 	// .Adc1ChT1Data_i		(14'h1fff),	
 	// .Adc1ChR1Data_i		(14'h257f),	
@@ -768,57 +770,58 @@ InternalDsp
 )
 InternalDsp
 (
-	.Clk_i				(gclk),
-	.WindCalcClk_i		(Clk100_o),
-	.Rst_i				(initRst),
-	.NcoRst_i			(ncoRst),
-	.OscWind_o			(oscWind),
-	
-	.Adc1ChT1Data_i		(adc1ChT1Data),	//T1
-	.Adc1ChR1Data_i		(adc1ChR1Data),	//R1
-	.Adc2ChR2Data_i		(adc2ChR2Data),	//R2
-	.Adc2ChT2Data_i		(adc2ChT2Data),	//T2
-	
-	// .Adc1ChT1Data_i		(AdcData_i),	//T1
-	// .Adc1ChR1Data_i		(AdcData_i),	//R1
-	// .Adc2ChR2Data_i		(AdcData_i),	//R2
-	// .Adc2ChT2Data_i		(AdcData_i),	//T2
-	
-	.GatingPulse_i		(gatingPulse),
-	
-	.StartMeas_i		(measStart),
-	.StartMeasDsp_i		(startMeasSyncRR),
-	.OscDataRdFlag_i	(oscDataRdFlag),
-	
-	.MeasNum_i			({measNum2[7:0],measNum1}),
+	.Clk_i					(gclk),
+	.WindCalcClk_i			(Clk100_o),
+	.Rst_i					(initRst),
+	.NcoRst_i				(ncoRst),
+	.OscWind_o				(oscWind),
+
+	.Adc1ChT1Data_i			(adc1ChT1Data),	//T1
+	.Adc1ChR1Data_i			(adc1ChR1Data),	//R1
+	.Adc2ChR2Data_i			(adc2ChR2Data),	//R2
+	.Adc2ChT2Data_i			(adc2ChT2Data),	//T2
+
+	// .Adc1ChT1Data_i			(AdcData_i),	//T1
+	// .Adc1ChR1Data_i			(AdcData_i),	//R1
+	// .Adc2ChR2Data_i			(AdcData_i),	//R2
+	// .Adc2ChT2Data_i			(AdcData_i),	//T2
+
+	.GatingPulse_i			(gatingPulse),
+
+	.StartMeas_i			(measStart),
+	.StartMeasDsp_i			(startMeasSyncRR),
+	.OscDataRdFlag_i		(oscDataRdFlag),
+
+	.MeasNum_i				({measNum2[7:0],measNum1}),
+
+	.MeasCtrl_i				(measCtrl),
+	.FilterCorrCoefH_i		(filterCorrCoefH),
+	.FilterCorrCoefL_i		(filterCorrCoefL),
+
+	.CalModeEn_i			(adcCtrl[1]),
+	.CalModeDone_o			(calDone),
+
+	.IfFtwL_i				(ifFtwL),
+	.IfFtwH_i				(ifFtwH),
 	
-	.MeasCtrl_i			(measCtrl),
-	.FilterCorrCoefH_i	(filterCorrCoefH),
-	.FilterCorrCoefL_i	(filterCorrCoefL),
+	.NcoSin_o				(ncoSin),
+	.NcoCos_o				(ncoCos),
 	
-	.CalModeEn_i		(adcCtrl[1]),
-	.CalModeDone_o		(calDone),
+	.Adc1ImT1Data_o			(adc1ImT1),
+	.Adc1ReT1Data_o			(adc1ReT1),
+	.Adc1ImR1Data_o			(adc1ImR1),
+	.Adc1ReR1Data_o			(adc1ReR1),
 	
-	.IfFtwL_i			(ifFtwL),
-	.IfFtwH_i			(ifFtwH),
+	.Adc2ImR2Data_o			(adc2ImR2),
+	.Adc2ReR2Data_o			(adc2ReR2),
+	.Adc2ImT2Data_o			(adc2ImT2),
+	.Adc2ReT2Data_o			(adc2ReT2),
 	
-	.NcoSin_o			(ncoSin),
-	.NcoCos_o			(ncoCos),
-
-	.Adc1ImT1Data_o		(adc1ImT1),
-	.Adc1ReT1Data_o		(adc1ReT1),
-	.Adc1ImR1Data_o		(adc1ImR1),
-	.Adc1ReR1Data_o		(adc1ReR1),
-
-	.Adc2ImR2Data_o		(adc2ImR2),
-	.Adc2ReR2Data_o		(adc2ReR2),
-	.Adc2ImT2Data_o		(adc2ImT2),
-	.Adc2ReT2Data_o		(adc2ReT2),
-
-	.MeasDataRdy_o		(measDataRdy),
-	.EndMeas_o			(stopMeas),
-	.MeasWind_o			(measWind),
-	.MeasEnd_o			(measEnd)
+	.MeasDataRdy_o			(measDataRdy),
+	.EndMeas_o				(stopMeas),
+	.MeasWind_o				(measWind),
+	.MeasEnd_o				(measEnd),
+	.SampleStrobeGenRst_o	(sampleStrobeGenRst)
 ); 
 
 //--------------------------------------------------------------------------------
@@ -1427,7 +1430,8 @@ SampleStrobeGenRstDemux
 (
 	.Rst_i			(initRst),
 	.MuxCtrl_i		(muxCtrl2[4:0]),
-	.GenRst_i		(stopMeas),
+	// .GenRst_i		(stopMeas),
+	.GenRst_i		(sampleStrobeGenRst),
 	
 	.RstDemuxOut_o	(pGenMeasRst)
 );	

+ 676 - 0
S5443_M/S5443.srcs/sources_1/new/S5443TopPulseProfileHighResTb.v

@@ -0,0 +1,676 @@
+`timescale 1ns / 1ps
+
+//=============================================================================================================
+
+//	Тестовая конфигурация:
+//
+//	Режим измерения "Точка в импульсе".
+//	Количество измерений = 1.
+//	Выбраный фильтр = 2МГц.
+//
+//	PG1	->	Reference Sequense Generator.	|	Шаблон 1 имп.
+//	PG2	->	модулятор.						|	Шаблон 1 имп.
+//	PG3	->	Sample Strobe Generator.		|	Шаблон 1 имп.
+//	PG4	->	Gating Generator.				|	Шаблон 1 имп.
+//	
+//	Настройки мультиплексоров генераторов:
+//	PG1MUX_OUT	->	INT_TRIG.
+//	PG2MUX_OUT	->	PG1. Для всех генераторов кроме PG1 сигналом начала работы является выход PG1.
+//	PG3MUX_OUT	->	PG1.
+//	PG4MUX_OUT	->	PG1.
+//	PG5MUX_OUT	->	PG1.
+//	PG6MUX_OUT	->	PG1.
+//	PG7MUX_OUT	->	PG1.
+//	
+//	Настройки остальных мультиплексоров:
+//	MODMUX_OUT			->	PG2.
+//	GATINGMUX_OUT		->	PG4.
+//	SAMPLSTROBEMUX_OUT	->	PG3.
+//	EXTSTARTMUX			->	DSPSTART.
+
+//=============================================================================================================
+module S5443TopPulseProfileHighResTb;
+	
+	localparam	[4:0]	EP1MUXCMD	=	5'd14;
+	localparam	[4:0]	EP2MUXCMD	=	5'd1;
+	localparam	[4:0]	EP3MUXCMD	=	5'd1;
+	localparam	[4:0]	EP4MUXCMD	=	5'd1;
+	localparam	[4:0]	EP5MUXCMD	=	5'd1;
+	localparam	[4:0]	EP6MUXCMD	=	5'd1;
+	
+	localparam	[4:0]	PG1MUXCMD	=	5'd13;
+	localparam	[4:0]	PG2MUXCMD	=	5'd0;
+	localparam	[4:0]	PG3MUXCMD	=	5'd18;
+	localparam	[4:0]	PG4MUXCMD	=	5'd18;
+	localparam	[4:0]	PG5MUXCMD	=	5'd0;
+	localparam	[4:0]	PG6MUXCMD	=	5'd0;
+	localparam	[4:0]	PG7MUXCMD	=	5'd0;
+	
+	localparam	[2:0]	PG1MODE	=	3'd5;
+	localparam	[2:0]	PG2MODE	=	3'd1;
+	localparam	[2:0]	PG3MODE	=	3'd4;
+	localparam	[2:0]	PG4MODE	=	3'd4;
+	localparam	[2:0]	PG5MODE	=	3'd0;
+	localparam	[2:0]	PG6MODE	=	3'd0;
+	localparam	[2:0]	PG7MODE	=	3'd0;
+	
+	localparam	PG1POL	=	1'b0;
+	localparam	PG2POL	=	1'b0;
+	localparam	PG3POL	=	1'b0;
+	localparam	PG4POL	=	1'b0;
+	localparam	PG5POL	=	1'b0;
+	localparam	PG6POL	=	1'b0;
+	localparam	PG7POL	=	1'b0;
+	
+	localparam	[4:0]	EXTTRIGMUXCMD	=	5'd15;
+	localparam	[4:0]	DSPTRIGINCMD	=	5'h8;
+	localparam	[4:0]	MUXSLOWMODCMD	=	5'd1;
+	localparam	[4:0]	MUXFASTMODCMD	=	5'd18;
+	localparam	[4:0]	GATINGMUXCMD	=	5'd3;
+	localparam	[4:0]	SMPLSTRBMUXCMD	=	5'd2;
+	
+	//COMMANDS	FOR REG_MAP
+	parameter	[31:0]	MeasCmdBypass	=	{8'h11,8'h0,8'h63,8'h1};
+	// parameter	[31:0]	MeasCmdFft 		=	{8'h11,8'h0,8'h63,7'h3,1'b1};
+	// parameter	[31:0]	MeasCmd 		=	{8'h11,8'h0,8'h53,8'h0};
+	parameter	[31:0]	MeasCmd =	{8'h11,8'h3e,8'h45,8'h0};
+	parameter	[31:0]	AdcCtrl =	{8'h12,24'h2};
+	parameter	[31:0]	SensCtrlCmd =	{1'b0,27'h0,4'b1};
+	// parameter	[31:0]	DitherCmd 	= {8'h0E,24'h100192};
+	parameter	[31:0]	DitherCmd 	= {8'h0E,8'd9,4'h0,4'h1,4'd11,4'h3};
+	parameter	[31:0]	IfFtwH 	=	{8'h15,16'h0,8'h3e};
+	parameter	[31:0]	IfFtwL 	=	{8'h16,24'hb851eb};
+	parameter	[31:0]	FilterCorrCmdH 		=	{8'h17,24'hD70A3D};
+	parameter	[31:0]	FilterCorrCmdL 		=	{8'h18,24'hD70A3D};
+	
+	//PG1 Cmd
+	parameter	[31:0]	PG1P1DelayRegCmd	=	{8'h28,24'd0};
+	parameter	[31:0]	PG1P2DelayRegCmd	=	{8'h29,24'd95};
+	parameter	[31:0]	PG1P3DelayRegCmd	=	{8'h2a,24'd0};
+	parameter	[31:0]	PG1P123DelayRegCmd	=	{8'h2b,24'd0};
+	parameter	[31:0]	PG1P1WidthRegCmd	=	{8'h2c,24'd5};
+	parameter	[31:0]	PG1P2WidthRegCmd	=	{8'h2d,24'd0};
+	parameter	[31:0]	PG1P3WidthRegCmd	=	{8'h2e,24'd0};
+	parameter	[31:0]	PG1P123WidthRegCmd	=	{8'h2f,24'd0};
+	
+	//PG2 Cmd
+	parameter	[31:0]	PG2P1DelayRegCmd	=	{8'h30,24'd0};
+	parameter	[31:0]	PG2P2DelayRegCmd	=	{8'h31,24'd0};
+	parameter	[31:0]	PG2P3DelayRegCmd	=	{8'h32,24'd0};
+	parameter	[31:0]	PG2P123DelayRegCmd	=	{8'h33,24'd0};
+	parameter	[31:0]	PG2P1WidthRegCmd	=	{8'h34,24'd50};
+	parameter	[31:0]	PG2P2WidthRegCmd	=	{8'h35,24'd0};
+	parameter	[31:0]	PG2P3WidthRegCmd	=	{8'h36,24'd0};
+	parameter	[31:0]	PG2P123WidthRegCmd	=	{8'h37,24'd0};
+	
+	//PG3 Cmd
+	parameter	[31:0]	PG3P1DelayRegCmd	=	{8'h38,24'd0};
+	parameter	[31:0]	PG3P2DelayRegCmd	=	{8'h39,24'd900};
+	parameter	[31:0]	PG3P3DelayRegCmd	=	{8'h3a,24'd0};
+	parameter	[31:0]	PG3P123DelayRegCmd	=	{8'h3b,24'd0};
+	parameter	[31:0]	PG3P1WidthRegCmd	=	{8'h3c,24'd5};
+	parameter	[31:0]	PG3P2WidthRegCmd	=	{8'h3d,24'd21};
+	parameter	[31:0]	PG3P3WidthRegCmd	=	{8'h3e,24'd0};
+	parameter	[31:0]	PG3P123WidthRegCmd	=	{8'h3f,24'd0};
+	
+	//PG4 Cmd
+	parameter	[31:0]	PG4P1DelayRegCmd	=	{8'h40,24'd0};
+	parameter	[31:0]	PG4P2DelayRegCmd	=	{8'h41,24'd90};
+	parameter	[31:0]	PG4P3DelayRegCmd	=	{8'h42,24'd0};
+	parameter	[31:0]	PG4P123DelayRegCmd	=	{8'h43,24'd0};
+	parameter	[31:0]	PG4P1WidthRegCmd	=	{8'h44,24'd10};
+	parameter	[31:0]	PG4P2WidthRegCmd	=	{8'h45,24'd8};
+	parameter	[31:0]	PG4P3WidthRegCmd	=	{8'h46,24'd0};
+	parameter	[31:0]	PG4P123WidthRegCmd	=	{8'h47,24'd0};
+	
+	//PG5 Cmd
+	parameter	[31:0]	PG5P1DelayRegCmd	=	{8'h48,24'd0};
+	parameter	[31:0]	PG5P2DelayRegCmd	=	{8'h49,24'd0};
+	parameter	[31:0]	PG5P3DelayRegCmd	=	{8'h4a,24'd0};
+	parameter	[31:0]	PG5P123DelayRegCmd	=	{8'h4b,24'd0};
+	parameter	[31:0]	PG5P1WidthRegCmd	=	{8'h4c,24'd0};
+	parameter	[31:0]	PG5P2WidthRegCmd	=	{8'h4d,24'd0};
+	parameter	[31:0]	PG5P3WidthRegCmd	=	{8'h4e,24'd0};
+	parameter	[31:0]	PG5P123WidthRegCmd	=	{8'h4f,24'd0};
+	
+	//PG6 Cmd
+	parameter	[31:0]	PG6P1DelayRegCmd	=	{8'h50,24'd0};
+	parameter	[31:0]	PG6P2DelayRegCmd	=	{8'h51,24'd5};
+	parameter	[31:0]	PG6P3DelayRegCmd	=	{8'h52,24'd15};
+	parameter	[31:0]	PG6P123DelayRegCmd	=	{8'h53,24'd0};
+	parameter	[31:0]	PG6P1WidthRegCmd	=	{8'h54,24'd1};
+	parameter	[31:0]	PG6P2WidthRegCmd	=	{8'h55,24'd3};
+	parameter	[31:0]	PG6P3WidthRegCmd	=	{8'h56,24'd5};
+	parameter	[31:0]	PG6P123WidthRegCmd	=	{8'h57,24'd0};
+	
+	//PG7 Cmd
+	parameter	[31:0]	PG7P1DelayRegCmd	=	{8'h20,24'd0};
+	parameter	[31:0]	PG7P2DelayRegCmd	=	{8'h21,24'd1};
+	parameter	[31:0]	PG7P3DelayRegCmd	=	{8'h22,24'd5};
+	parameter	[31:0]	PG7P123DelayRegCmd	=	{8'h23,24'd15};
+	parameter	[31:0]	PG7P1WidthRegCmd	=	{8'h24,24'd1};
+	parameter	[31:0]	PG7P2WidthRegCmd	=	{8'h25,24'd3};
+	parameter	[31:0]	PG7P3WidthRegCmd	=	{8'h26,24'd5};
+	parameter	[31:0]	PG7P123WidthRegCmd	=	{8'h27,24'd0};
+
+	
+	parameter	[31:0]	MeasNum0RegCmd		=	{8'h58,24'd21};
+	parameter	[31:0]	MeasNum1RegCmd		=	{8'h59,MUXSLOWMODCMD,MUXFASTMODCMD,DSPTRIGINCMD,25'd0};
+	parameter	[31:0]	PGMode0RegCmd		=	{8'h0b,3'b0,PG7MODE,PG6MODE,PG5MODE,PG4MODE,PG3MODE,PG2MODE,PG1MODE};
+	parameter	[31:0]	PGMode1RegCmd		=	{8'h1b,7'b0000000,PG7POL,PG6POL,PG5POL,PG4POL,PG3POL,PG2POL,PG1POL,10'h0};
+	
+	parameter	[31:0]	MuxCtrl1RegCmd	=	{8'h1c,4'h0,PG7MUXCMD,PG6MUXCMD,PG5MUXCMD,PG4MUXCMD};
+	parameter	[31:0]	MuxCtrl2RegCmd	=	{8'h1d,4'h0,PG3MUXCMD,PG2MUXCMD,PG1MUXCMD,SMPLSTRBMUXCMD};
+	parameter	[31:0]	MuxCtrl3RegCmd	=	{8'h1e,4'h0,GATINGMUXCMD,EXTTRIGMUXCMD,EP2MUXCMD,EP1MUXCMD};
+	parameter	[31:0]	MuxCtrl4RegCmd	=	{8'h1f,4'h0,EP6MUXCMD,EP5MUXCMD,EP4MUXCMD,EP3MUXCMD};
+	
+	//=================================================================================================================================================================================================================
+	
+	reg		Clk41;
+	reg		Clk50;
+	reg		Clk70;
+	
+	reg	[31:0]	tb_cnt=4'd0;
+	reg	rst;
+	reg	mosi_i	=	1'b0;
+	reg	Miso_i	=	1'b0;
+	reg	ss_i;
+	reg	clk_i	=	1'b0;
+	
+	
+	reg	[31:0]	DspSpiData;
+	reg		startCalcCmdReg;
+						
+	wire	[17:0]	cos_value;	
+	wire	[17:0]	sin_value;				
+
+	wire	ExtDspTrigPos0	=	(tb_cnt	>=	180	&&	tb_cnt	<=	181)?	1'b1:1'b0;
+	wire	ExtDspTrigNeg0	=	(tb_cnt	>=	180	&&	tb_cnt	<=	181)?	1'b0:1'b1;
+	
+	wire	ExtTrigger0		=	ExtDspTrigNeg0;
+	
+	wire	TrigFromDsp		=	(tb_cnt	>=	1100	&&	tb_cnt	<=	1101)?	1'b1:1'b0;
+	wire	endMeas;
+	reg	[31:0]	cmdCnt;
+	
+	reg	trig0;
+	reg	trig1;
+	
+	wire	trig0R;
+    wire	trig1R;
+	
+	assign	trig0R	=	trig0;
+    assign	trig1R	=	trig1;
+	
+//==========================================================================================
+//clocks gen
+	always	#10 Clk50	=	~Clk50;
+	always	#(14.285714285714/2) Clk70	=	~Clk70;
+	always	#10 clk_i	=	~clk_i;
+	always	#(24.390243902439/2)	Clk41	=	~Clk41;
+	
+	wire	sck_i;	
+//==========================================================================================
+initial begin
+	Clk50	=	1'b1;
+	Clk70	=	1'b1;
+	rst		=	1'b1;
+	Clk41	=	1'b0;
+	trig0	=	1'b0;
+	trig1	=	1'b0;
+#100;
+	rst		=	1'b0;
+#400;
+	Clk41	=	1'b0;
+end		
+	
+reg	endMeasReg;
+always	@(posedge	Clk41)	begin
+	endMeasReg	<=	endMeas;
+end
+
+wire	endMeasNeg	=	!endMeas&endMeasReg;
+
+always	@(posedge	Clk70)	begin
+	if	(!rst)	begin
+		if	(!endMeas)	begin
+			if	(tb_cnt	==	3550	|	tb_cnt	==	3950	|tb_cnt	==	4505)	begin
+				startCalcCmdReg	<=	1'b1;
+			end	
+		end	else	begin
+			startCalcCmdReg	<=	1'b0;
+		end
+	end	else	begin
+		startCalcCmdReg	<=	1'b0;
+	end
+end
+
+always	@(negedge	Clk41)	begin
+	if	(!rst)		begin
+		tb_cnt	<=	tb_cnt+1;
+	end	else	begin
+		tb_cnt	<=	0;
+	end
+end
+
+wire	Adc1DataDa0P;
+wire	Adc1DataDa1P;
+
+// wire	[31:0]	test	=	32'h2351eb85;
+wire	[31:0]	test	=	32'h3eb851eb;
+CordicNco		
+#(	.ODatWidth	(18),
+	.PhIncWidth	(32),
+	.IterNum	(10),
+	.EnSinN		(0))
+ncoInst
+(
+	.Clk_i				(Clk50),
+	.Rst_i				(rst),
+	.Val_i				(1'b1),
+	.PhaseInc_i			(test),
+	.WindVal_i			(1'b1),
+	.WinType_i			(),
+	.Wind_o				(),
+	.Sin_o				(sin_value),
+	.Cos_o				(cos_value),
+	.Val_o				()
+);
+
+
+S5443Top MasterFpga 
+(
+	.Clk_i				(Clk50),
+	.Led_o				(),
+//------------------------------------------	
+    .Adc1FclkP_i		(),		
+    .Adc1FclkN_i		(),		
+
+    .Adc1DataDa0P_i		(Adc1DataDa0P),
+	.Adc1DataDa0N_i		(~Adc1DataDa0P),		
+    .Adc1DataDa1P_i		(Adc1DataDa1P),
+    .Adc1DataDa1N_i		(~Adc1DataDa1P),
+
+	.Adc1DataDb0P_i		(Adc1DataDa0P),
+    .Adc1DataDb0N_i		(~Adc1DataDa0P),		
+    .Adc1DataDb1P_i		(Adc1DataDa1P),
+    .Adc1DataDb1N_i		(~Adc1DataDa1P),
+//------------------------------------------	
+    .Adc2FclkP_i		(),		
+    .Adc2FclkN_i		(),		
+
+    .Adc2DataDa0P_i		(1'b1),
+    .Adc2DataDa0N_i		(1'b0),		
+    .Adc2DataDa1P_i		(1'b1),
+    .Adc2DataDa1N_i		(1'b0),
+  
+	.Adc2DataDb0P_i		(1'b1),
+    .Adc2DataDb0N_i		(1'b0),		
+    .Adc2DataDb1P_i		(1'b1),
+    .Adc2DataDb1N_i		(1'b0),
+//------------------------------------------
+	.AdcInitMosi_o		(),
+	.AdcInitClk_o		(),			
+	.Adc1InitCs_o		(),
+	.Adc2InitCs_o		(),
+	.AdcInitRst_o		(),
+//------------------------------------------	
+	
+	.Mosi_i				(mosi_i),
+	.Sck_i				(~sck_i),
+	.Ss_i				(ss_i),
+
+	.LpOutClk_o			(),
+	.LpOutFs_o			(),			
+	.LpOutData_o		(),
+	
+	//fpga-dsp signals
+	.StartMeas_i		(startCalcCmdReg),
+	.StartMeasEvent_o	(startMeasS),
+	.EndMeas_o			(endMeas),
+	.TimersClk_o		(),
+	
+	.Trig6to1_io		(),	
+	.Trig6to1Dir_o		(),	
+	
+	.DspTrigOut_i		(Clk41),				//Trig from DSP
+	.DspTrigIn_o		(),				//Trig To DSP
+	
+	.OverloadS_i		(1'b0),
+	.Overload_o			(),
+	
+	.PortSel_o			(),
+	.PortSelDir_o		(),
+	
+	//mod out line
+	
+	.Mod_o				(),	
+	
+	//gain lines
+	.DspReadyForRx_i		(1'b0),
+	.DspReadyForRxToFpgaS_o	(),
+	.AmpEn_o				(),	//	0-adc1ChA 1-adc1ChB 2-adc2ChA 3-adc2ChB
+	.AdcData_i				(sin_value[17-:14])
+	// .AdcData_i			(Data_i)
+);
+
+parameter	IDLE	=	2'h0;
+parameter	CMD		=	2'h1;
+parameter	TX		=	2'h2;
+parameter	PAUSE	=	2'h3;
+
+reg	[1:0]	txCurrState;
+reg	[1:0]	txNextState;
+
+wire	txWork	=	tb_cnt	>=	23;
+// wire	txStop	=	(cmdCnt	>=	90)	&	(cmdCnt	>=	70)	&	(cmdCnt	>=	71);
+wire	txStop	=	(cmdCnt	>=	251);
+
+
+reg	[6:0]	txCnt;
+reg	[3:0]	pauseCnt;
+
+always	@(posedge	Clk41)	begin
+	if	(!rst)	begin
+		if	(txCurrState	==	CMD)	begin
+			if	(!txStop)	begin
+				cmdCnt	<=	cmdCnt+1;
+			end
+		end
+	end	else	begin
+		cmdCnt	<=	0;
+	end
+end
+
+always	@(posedge	Clk41)	begin
+	if	(!rst)	begin
+		if	(txCurrState	==	TX)	begin
+			txCnt	<=	txCnt+1;
+		end	else	begin
+			txCnt	<=	0;
+		end
+	end	else	begin
+		txCnt	<=	0;
+	end
+end
+
+always	@(posedge	Clk41)	begin
+	if	(!rst)	begin
+		if	(txCurrState	==	PAUSE)	begin
+			pauseCnt	<=	pauseCnt+1;
+		end	else	begin
+			pauseCnt	<=	0;
+		end
+	end	else	begin
+		pauseCnt	<=	0;
+	end
+end
+	
+
+always	@(posedge	Clk41)	begin
+	if	(txCurrState	==	CMD)	begin
+		if	(cmdCnt	==	0)	begin
+			DspSpiData		<=	MeasCmd;
+		end	else	if	(cmdCnt	==	1)	begin
+			DspSpiData		<=	IfFtwH;
+		end	else	if	(cmdCnt	==	2)	begin
+			DspSpiData		<=	IfFtwL;
+		end	else	if	(cmdCnt	==	3)	begin
+			DspSpiData		<=	FilterCorrCmdH;
+		end	else	if	(cmdCnt	==	4)	begin
+			DspSpiData		<=	FilterCorrCmdL;
+		end	else	if	(cmdCnt	==	5)	begin
+			DspSpiData		<=	PG1P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	6)	begin
+			DspSpiData		<=	PG1P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	7)	begin
+			DspSpiData		<=	PG1P3DelayRegCmd;
+		end	else	if	(cmdCnt	==	8)	begin
+			DspSpiData		<=	PG1P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	9)	begin
+			DspSpiData		<=	PG1P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	10)	begin
+			DspSpiData		<=	PG1P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	11)	begin
+			DspSpiData		<=	PG1P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	12)	begin
+			DspSpiData		<=	PG1P123WidthRegCmd;
+		end	else	if	(cmdCnt	==	13)	begin
+			DspSpiData		<=	PG2P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	14)	begin
+			DspSpiData		<=	PG2P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	15)	begin
+			DspSpiData		<=	PG2P3DelayRegCmd;	
+		end	else	if	(cmdCnt	==	16)	begin
+			DspSpiData		<=	PG2P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	17)	begin
+			DspSpiData		<=	PG2P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	18)	begin
+			DspSpiData		<=	PG2P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	19)	begin
+			DspSpiData		<=	PG2P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	20)	begin
+			DspSpiData		<=	PG2P123WidthRegCmd;
+		end	else	if	(cmdCnt	==	21)	begin
+			DspSpiData		<=	PG3P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	22)	begin
+			DspSpiData		<=	PG3P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	23)	begin
+			DspSpiData		<=	PG3P3DelayRegCmd;	
+		end	else	if	(cmdCnt	==	24)	begin
+			DspSpiData		<=	PG3P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	25)	begin
+			DspSpiData		<=	PG3P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	26)	begin
+			DspSpiData		<=	PG3P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	27)	begin
+			DspSpiData		<=	PG3P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	28)	begin
+			DspSpiData		<=	PG3P123WidthRegCmd;
+		end	else	if	(cmdCnt	==	29)	begin
+			DspSpiData		<=	PG4P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	30)	begin
+			DspSpiData		<=	PG4P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	31)	begin
+			DspSpiData		<=	PG4P3DelayRegCmd;	
+		end	else	if	(cmdCnt	==	32)	begin
+			DspSpiData		<=	PG4P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	33)	begin
+			DspSpiData		<=	PG4P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	34)	begin
+			DspSpiData		<=	PG4P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	35)	begin
+			DspSpiData		<=	PG4P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	36)	begin
+			DspSpiData		<=	PG4P123WidthRegCmd;
+		end	else	if	(cmdCnt	==	37)	begin
+			DspSpiData		<=	PG5P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	38)	begin
+			DspSpiData		<=	PG5P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	39)	begin
+			DspSpiData		<=	PG5P3DelayRegCmd;	
+		end	else	if	(cmdCnt	==	40)	begin
+			DspSpiData		<=	PG5P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	41)	begin
+			DspSpiData		<=	PG5P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	42)	begin
+			DspSpiData		<=	PG5P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	43)	begin
+			DspSpiData		<=	PG5P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	44)	begin
+			DspSpiData		<=	PG5P123WidthRegCmd;
+		end	else	if	(cmdCnt	==	45)	begin
+			DspSpiData		<=	PG6P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	46)	begin
+			DspSpiData		<=	PG6P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	47)	begin
+			DspSpiData		<=	PG6P3DelayRegCmd;	
+		end	else	if	(cmdCnt	==	48)	begin
+			DspSpiData		<=	PG6P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	49)	begin
+			DspSpiData		<=	PG6P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	50)	begin
+			DspSpiData		<=	PG6P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	51)	begin
+			DspSpiData		<=	PG6P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	52)	begin
+			DspSpiData		<=	PG6P123WidthRegCmd;
+		end	else	if	(cmdCnt	==	53)	begin
+			DspSpiData		<=	PG7P1DelayRegCmd;
+		end	else	if	(cmdCnt	==	54)	begin
+			DspSpiData		<=	PG7P2DelayRegCmd;
+		end	else	if	(cmdCnt	==	55)	begin
+			DspSpiData		<=	PG7P3DelayRegCmd;	
+		end	else	if	(cmdCnt	==	56)	begin
+			DspSpiData		<=	PG7P123DelayRegCmd;
+		end	else	if	(cmdCnt	==	57)	begin
+			DspSpiData		<=	PG7P1WidthRegCmd;
+		end	else	if	(cmdCnt	==	58)	begin
+			DspSpiData		<=	PG7P2WidthRegCmd;
+		end	else	if	(cmdCnt	==	59)	begin
+			DspSpiData		<=	PG7P3WidthRegCmd;
+		end	else	if	(cmdCnt	==	60)	begin
+			DspSpiData		<=	DitherCmd;
+		end	else	if	(cmdCnt	==	61)	begin
+			DspSpiData		<=	MeasNum0RegCmd;
+		end else	if	(cmdCnt	==	62)	begin
+			DspSpiData		<=	MeasNum1RegCmd;
+		end else	if	(cmdCnt	==	63)	begin
+			DspSpiData		<=	PGMode0RegCmd;
+		end	else	if	(cmdCnt	==	64)	begin
+			DspSpiData		<=	PGMode1RegCmd;
+		end	else	if	(cmdCnt	==	65)	begin
+			DspSpiData		<=	MuxCtrl1RegCmd;
+		end	else	if	(cmdCnt	==	66)	begin
+			DspSpiData		<=	MuxCtrl2RegCmd;
+		end	else	if	(cmdCnt	==	67)	begin
+			DspSpiData		<=	MuxCtrl3RegCmd;
+		end	else	if	(cmdCnt	==	68)	begin
+			DspSpiData		<=	AdcCtrl;
+		// end	else	if	(cmdCnt	==	99)	begin
+			// DspSpiData		<=	{8'h58,24'd100};
+		end	else	begin
+			DspSpiData	<=	32'hfffffff;
+		end
+	end	else	if	(txCurrState	==	TX)	begin
+		DspSpiData	<=	DspSpiData<<1;
+	end
+end
+
+always	@(posedge Clk41)	begin
+	if	(txCurrState	==	TX)	begin
+		if	(txCnt	>=	7'd0)	begin
+			mosi_i	<=	DspSpiData[31];
+		end	else	begin
+			mosi_i	<=	1'b1;
+		end
+	end	else	begin
+		mosi_i	<=	1'b1;
+	end
+end
+
+always	@(posedge	Clk41)	begin
+	if	(txCurrState	==	TX)	begin
+		ss_i	<=	1'b0;
+	end	else	begin
+		ss_i	<=	1'b1;
+	end
+end
+
+assign	sck_i	=	Clk41;
+
+always	@(posedge	Clk41)	begin
+	if	(rst)	begin
+		txCurrState	<=	IDLE;
+	end	else	begin
+		txCurrState	<=	txNextState;
+	end
+end
+
+
+always @(*) begin
+	txNextState	=	IDLE;
+	case(txCurrState)
+	IDLE	:	begin
+					if (txWork)	begin
+						txNextState = CMD;
+					end	else begin
+						txNextState = IDLE;
+					end
+				end
+				
+	CMD	:		begin
+					if (!txStop)	begin
+						txNextState = TX;
+					end	else begin
+						txNextState = IDLE;
+					end
+				end
+
+	TX		:	begin
+					if (txCnt==6'd31) begin
+						txNextState  = PAUSE;
+					end	else begin
+						txNextState  = TX;
+					end
+				end
+        
+	PAUSE	:	begin
+					if (pauseCnt==4'd10) begin
+						txNextState  = CMD;
+					end	else begin
+						txNextState  = PAUSE;
+					end
+				end
+	endcase
+end
+
+	reg [13:0] Data_i;
+	real pi = 3.14159265358;
+	real phase = 0;
+	real phaseInc = 0.001;
+	real signal;
+	always @ (posedge Clk50)
+		begin
+			if (tb_cnt >= 4505)
+				begin
+					phase = phase + phaseInc;
+					phaseInc <= phaseInc + 0.0005;
+					signal = $sin(2*pi*phase);
+					Data_i = 2**12 * signal;
+				end
+			else
+				Data_i = 0;
+		end
+		
+endmodule
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 4 - 4
S5443_M/S5443.srcs/sources_1/new/S5443TopPulseProfileTb.v

@@ -71,7 +71,7 @@ module S5443TopPulseProfileTb;
 	
 	//COMMANDS	FOR REG_MAP
 	parameter	[31:0]	MeasCmdBypass	=	{8'h11,8'h0,8'h63,8'h1};
-	parameter	[31:0]	MeasCmdFft 		=	{8'h11,8'h0,8'h63,4'h0,3'd3,1'b1};
+	parameter	[31:0]	MeasCmdFft 		=	{8'h11,8'h0,8'h63,7'h5,1'b1};
 	// parameter	[31:0]	MeasCmd 		=	{8'h11,8'h0,8'h53,8'h0};
 	parameter	[31:0]	MeasCmd =	{8'h11,8'h3e,8'h63,8'h0};
 	parameter	[31:0]	AdcCtrl =	{8'h12,24'h2};
@@ -256,7 +256,7 @@ wire	Adc1DataDa0P;
 wire	Adc1DataDa1P;
 
 // wire	[31:0]	test	=	32'h2351eb85;
-wire	[31:0]	test	=	32'h31eb851e;
+wire	[31:0]	test	=	32'h40000000;
 CordicNco		
 #(	.ODatWidth	(18),
 	.PhIncWidth	(32),
@@ -349,8 +349,8 @@ S5443Top MasterFpga
 	.DspReadyForRx_i		(1'b0),
 	.DspReadyForRxToFpgaS_o	(),
 	.AmpEn_o				(),	//	0-adc1ChA 1-adc1ChB 2-adc2ChA 3-adc2ChB
-	// .AdcData_i				(sin_value[17-:14])
-	.AdcData_i			(Data_i)
+	.AdcData_i				(sin_value[17-:14])
+	// .AdcData_i			(Data_i)
 );
 
 parameter	IDLE	=	2'h0;

+ 28 - 25
S5443_S/S5443.srcs/sources_1/new/InternalDsp/InternalDsp.v

@@ -84,7 +84,8 @@ module InternalDsp
 	
 	output	wire	MeasDataRdy_o,
 	output	wire	MeasWind_o,
-	output	wire	MeasEnd_o
+	output	wire	MeasEnd_o,
+	output	wire	SampleStrobeGenRst_o
 );
 
 //================================================================================
@@ -143,6 +144,7 @@ module InternalDsp
 	wire	[CorrAdcDataWidth-1:0]	adc2ChT2DataGated	=	(GatingPulse_i)?	adcDataBusExt[ChNum-1]:{CorrAdcDataWidth{1'b0}};	
 	
 	wire	[WindNcoPhIncWidth-1:0]	ncoPhInc = {ifFtwHReg[0+:WindNcoPhIncWidth-CmdDataRegWith],ifFtwLReg};
+	
 //================================================================================
 //  ASSIGNMENTS
 	
@@ -226,30 +228,31 @@ MeasCtrlModule
 )
 MeasCtrlModule	
 (
-	.Clk_i				(Clk_i),
-	.Rst_i				(Rst_i),
-	.OscWind_o			(OscWind_o),
-	.FilterCmd_i		(measCtrlReg[15-:8]),
-	
-	.MeasNum_i			(measNumReg),
-	.StartMeas_i		(StartMeas_i),
-	.StartMeasDsp_i		(StartMeasDsp_i),
-	.Mode_i				(measCtrlReg[0]),
-	.OscDataRdFlag_i	(OscDataRdFlag_i),
-	
-	.WindPointsNum_i	(windPointsNumReg),
-	
-	.WindPhInc_i		(windPhInc),
-	.WindPhIncStart_i	(winPhIncStart),
-	.WindArg_o			(windArg),
-	
-	.StartFpConv_o		(StartFpConv),
-	.MeasWind_o			(measWind),
-	.MeasWindDel_o		(measWindDelayed),
-	.StopMeas_o			(stopMeas),
-	.MeasEnd_o			(MeasEnd_o),
-	.WinCtrl_o			(winCtrl),
-	.TukeyCtrl_o		(tukeyCtrl)
+	.Clk_i					(Clk_i),
+	.Rst_i					(Rst_i),
+	.OscWind_o				(OscWind_o),
+	.FilterCmd_i			(measCtrlReg[15-:8]),
+		
+	.MeasNum_i				(measNumReg),
+	.StartMeas_i			(StartMeas_i),
+	.StartMeasDsp_i			(StartMeasDsp_i),
+	.Mode_i					(measCtrlReg[0]),
+	.OscDataRdFlag_i		(OscDataRdFlag_i),
+		
+	.WindPointsNum_i		(windPointsNumReg),
+		
+	.WindPhInc_i			(windPhInc),
+	.WindPhIncStart_i		(winPhIncStart),
+	.WindArg_o				(windArg),
+		
+	.StartFpConv_o			(StartFpConv),
+	.MeasWind_o				(measWind),
+	.MeasWindDel_o			(measWindDelayed),
+	.StopMeas_o				(stopMeas),
+	.MeasEnd_o				(MeasEnd_o),
+	.WinCtrl_o				(winCtrl),
+	.TukeyCtrl_o			(tukeyCtrl),
+	.SampleStrobeGenRst_o	(SampleStrobeGenRst_o)
 );	
 
 //----------------------------------------------

+ 25 - 10
S5443_S/S5443.srcs/sources_1/new/InternalDsp/MeasCtrlModule.v

@@ -48,6 +48,7 @@ module MeasCtrlModule
 	output	StopMeas_o,
 	output	MeasEnd_o,
 	output	WinCtrl_o,
+	output	SampleStrobeGenRst_o,
 	output	[1:0]	TukeyCtrl_o
 );
 
@@ -102,21 +103,35 @@ module MeasCtrlModule
 	wire	decrPhase	=	(pNumCnt	>=	tukeySecondCosValues-1	&	pNumCnt	<=	WindPointsNum_i-1);
 	
 	wire	wideFilterFlag	=	(FilterCmd_i>=8'h54	&	FilterCmd_i!=8'h70);
-
+	
+	reg		sampleStrobeGenRst;
 //================================================================================
 //  ASSIGNMENTS
-	assign	StartFpConv_o		=	startFpConvPipe	[2];
-	assign	MeasWind_o			=	measWind;
-	assign	MeasWindDel_o		=	measWindR;
-	assign	StopMeas_o			=	pMeasEnd;
-	assign	MeasEnd_o			=	stopMeasCmd;
-	assign	WindArg_o			=	windArg;
-	assign	OscWind_o			=	oscWind;
-	assign	TukeyCtrl_o			=	tukeyCtrl;
-	assign	WinCtrl_o			=	(pNumCnt<=tukeyFirstCosValuesDiv2+1|pNumCnt>tukeySecondCosValuesDiv2);
+	assign	StartFpConv_o			=	startFpConvPipe	[2];
+	assign	MeasWind_o				=	measWind;
+	assign	MeasWindDel_o			=	measWindR;
+	assign	StopMeas_o				=	pMeasEnd;
+	assign	MeasEnd_o				=	stopMeasCmd;
+	assign	WindArg_o				=	windArg;
+	assign	OscWind_o				=	oscWind;
+	assign	TukeyCtrl_o				=	tukeyCtrl;
+	assign	WinCtrl_o				=	(pNumCnt<=tukeyFirstCosValuesDiv2+1|pNumCnt>tukeySecondCosValuesDiv2);
+	assign	SampleStrobeGenRst_o	=	sampleStrobeGenRst;
 //================================================================================
 //  CODING
 	
+	always	@(posedge	Clk_i)	begin
+		if	(!Rst_i)	begin
+			if	(measCnt	==	MeasNum_i-1	&	measWind)	begin
+				sampleStrobeGenRst	<=	1'b1;
+			end	else	begin
+				sampleStrobeGenRst	<=	1'b0;
+			end
+		end	else	begin
+			sampleStrobeGenRst	<=	1'b0;
+		end
+	end
+	
 	always	@(*)	begin
 		if	(!Rst_i)	begin
 			if	(measWind)	begin

+ 4 - 2
S5443_S/S5443.srcs/sources_1/new/S5443Top.v

@@ -370,6 +370,7 @@ module	S5443Top
 	wire	dspBusy;
 	wire	fifoEn;
 	reg		dspReadyForRxReg;
+	wire	sampleStrobeGenRst;
 //================================================================================
 //  assignments
 //================================================================================	
@@ -798,7 +799,8 @@ InternalDsp
 	.MeasDataRdy_o		(measDataRdy),
 	.EndMeas_o			(stopMeas),
 	.MeasWind_o			(measWind),
-	.MeasEnd_o			(measEnd)
+	.MeasEnd_o			(measEnd),
+	.SampleStrobeGenRst_o	(sampleStrobeGenRst)
 ); 
 
 //--------------------------------------------------------------------------------
@@ -1203,7 +1205,7 @@ SampleStrobeGenRstDemux
 (
 	.Rst_i			(initRst),
 	.MuxCtrl_i		(muxCtrl2[4:0]),
-	.GenRst_i		(stopMeas),
+	.GenRst_i		(sampleStrobeGenRst),
 	
 	.RstDemuxOut_o	(pGenMeasRst)
 );