Bläddra i källkod

Исправлена упаковка данных для режимов SA и OSC.

ChStepan 1 år sedan
förälder
incheckning
92a3534b53

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 18 - 19
src/constrs/S5243Top.xdc


+ 1 - 35
src/src/ExtDspInterface/DspInterface.v

@@ -247,47 +247,13 @@ 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}),
-	// .AdcData_i			({testPatternData,testPatternData}),
-	// .AdcDataVal_i		(filteredDecimDataVal),
-	
-	// .OscDataBus_o		(fftDataBus),
-	// .OscDataBusVal_o	(fftDataBusVal)
-// );
-
-// decimBlock	
-// #(	
-	// .inOutDataWidth	(14),
-	// .decimCntWidth	(8)
-// )
-// Decimator
-// (
-	// .Clk_i			(Clk_i),
-	// .Rst_i			(Rst_i),
-	// .DecimFactor_i	(DecimFactor_i),
-	// .Data_i			(currDataChannel),
-	// .DataNd_i		(1'b1),
-	// .Data_o			(currDataChannelDecim),
-	// .DataValid_o	(currDataChannelDecimVal)
-// );
-
 OscDataFormer	DecimDataFormer
 (
 	.Clk_i				(Clk_i), 
 	.Rst_i				(Rst_i),	
 	.OscWind_i			(OscWind_i),
 	.MeasNum_i			(MeasNum_i),
-	
-	// .AdcDataVal_i		(currDataChannelDecimVal),
-	// .AdcData_i			(currDataChannelDecim),
-	
+
 	.AdcDataVal_i		(filteredDecimDataVal),
 	.AdcData_i			(filteredDecimDataI),	
 	

+ 8 - 8
src/src/FftDataFiltering/DecimFilterWrapper.v

@@ -23,7 +23,7 @@ module	DecimFilterWrapper
 	parameter	AdcDataWidth		=	14,
 	parameter	N	=	8,
 	parameter	M	=	2,
-	parameter	FilteredDataWidth	=	46,
+	parameter	FilteredDataWidth	=	42,
 	parameter	FirOutDataWidth		=	48,
 	parameter	FirOutCutBit		=	42
 )
@@ -69,12 +69,12 @@ module	DecimFilterWrapper
 	reg		[15:0]	outDataI;
 	reg		[15:0]	outDataQ;
 	
-	localparam	maxWidthForR2	=	6'd29;	//msb for R = 2;
-	localparam	maxWidthForR3	=	6'd34;	//msb for R = 3;
-	localparam	maxWidthForR4	=	6'd36;	//msb for R = 4;
-	localparam	maxWidthForR5	=	6'd39;	//msb for R = 5;
-	localparam	maxWidthForR6	=	6'd41;	//msb for R = 6;
-	localparam	maxWidthForR7	=	6'd42;	//msb for R = 7;
+	localparam	maxWidthForR2	=	6'd28;	//msb for R = 2;
+	localparam	maxWidthForR3	=	6'd33;	//msb for R = 3;
+	localparam	maxWidthForR4	=	6'd35;	//msb for R = 4;
+	localparam	maxWidthForR5	=	6'd38;	//msb for R = 5;
+	localparam	maxWidthForR6	=	6'd40;	//msb for R = 6;
+	localparam	maxWidthForR7	=	6'd41;	//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;
@@ -168,7 +168,7 @@ cicFilterInstI
 	.Clk_i			(Clk_i),
 	.Rst_i			(Rst_i),
 	.DecimFactor_i	(DecimFactor_i),
-	.Data_i			({{32{AdcData_i[AdcDataWidth-1]}},AdcData_i}),
+	.Data_i			({{28{AdcData_i[AdcDataWidth-1]}},AdcData_i}),
 	.DataNd_i		(OscWind_i),
 	.Data_o			(decimDataI),
 	.DataValid_o	(decimDataValI)

+ 14 - 14
src/src/MeasDataFifo/MeasDataFifoWrapper.v

@@ -77,24 +77,24 @@ always	@(posedge	Clk_i)	begin
 	end
 end
 
-MeasDataFifoExtender	MeasDataFifoExtender
-(
-	.clk	(Clk_i),
-	.srst	(Rst_i|startMeasDspPos),
-	.din	(MeasDataBus_i),
-	.wr_en	(wrEn),
-	.rd_en	(writeEn),
-	.dout	(measDataBus),
-	.full	(fullFlagExt),
-	.empty	(emptyFlagExt)
-);
+// MeasDataFifoExtender	MeasDataFifoExtender
+// (
+	// .clk	(Clk_i),
+	// .srst	(Rst_i|startMeasDspPos),
+	// .din	(MeasDataBus_i),
+	// .wr_en	(wrEn),
+	// .rd_en	(writeEn),
+	// .dout	(measDataBus),
+	// .full	(fullFlagExt),
+	// .empty	(emptyFlagExt)
+// );
 
 MeasDataFifo	MeasDataFifo
 (
 	.clk	(Clk_i),
 	.srst	(Rst_i|startMeasDspPos),
-	.din	(measDataBus),
-	.wr_en	(writeEn),
+	.din	(MeasDataBus_i),
+	.wr_en	(wrEn),
 	.rd_en	(rdEn),
 	.dout	(MeasDataBus_o),
 	.full	(fullFlag),
@@ -110,7 +110,7 @@ FifoController	FifoController
 	.PpiBusy_i			(PpiBusy_i),	
 	.MeasNum_i			(MeasNum_i),	
 	.MeasDataVal_i		(MeasDataVal_i),
-	.FullFlag_i			(fullFlagExt),
+	.FullFlag_i			(fullFlag),
 	.EmptyFlag_i		(emptyFlag),
 	
 	.MeasDataVal_o		(),

+ 4 - 2
src/src/MeasDataFifo/OscDataFormer.v

@@ -67,8 +67,11 @@ module OscDataFormer
 		if	(!Rst_i)	begin
 			if	(OscWind_i)	begin
 				if	(oscDataBusValReg)	begin
-					oscDataBusRegReg	<=	{oscDataBusReg[127:0], oscDataBusReg[OutDataWidth-1:128]};
+					oscDataBusRegReg	<=	{oscDataBusReg[16*12-1-:64],oscDataBusReg[16*4-1-:64],oscDataBusReg[16*16-1-:64],oscDataBusReg[16*8-1-:64]};
+					// oscDataBusRegReg	<=	{oscDataBusReg[127:0], oscDataBusReg[OutDataWidth-1:128]};
+					// oscDataBusRegReg	<=	oscDataBusReg;
 					// oscDataBusRegReg	<=	{16'h7,16'h6,16'h5,16'h4,16'h3,16'h2,16'h1,16'h0,16'hF,16'hE,16'hD,16'hC,16'hB,16'hA,16'h9,16'h8};
+					// oscDataBusRegReg	<=	{16'hB,16'hA,16'h9,16'h8,      16'h3,16'h2,16'h1,16'h0,         16'hF,16'hE,16'hD,16'hC,       16'h7,16'h6,16'h5,16'h4};
 				end	
 			end	else	begin
 				oscDataBusRegReg	<=	0;
@@ -112,7 +115,6 @@ module OscDataFormer
 		if	(!Rst_i)	begin
 			if	(OscWind_i)	begin
 				if	(AdcDataVal_i)	begin
-					// oscDataBusReg	<=	{adcDataExt,oscDataBusReg[OutDataWidth-1:AdcDataWidth+2]};	//first points
 					oscDataBusReg	<=	{AdcData_i,oscDataBusReg[OutDataWidth-1:AdcDataWidth]};	//first points
 				end
 			end	else	begin

+ 1 - 1
src/src/Sim/DecimFilterWrapperTb.v

@@ -53,7 +53,7 @@ parameter	M	=	2;
 initial begin
 	Clk50		=	1'b1;
 	Rst			=	1'b1;
-	decimFactor	=	3'd2;
+	decimFactor	=	3'd4;
 #100;
 	Rst		=	1'b0;
 end	

+ 28 - 31
src/src/Sim/FFTTest.m

@@ -1,16 +1,16 @@
 FormatSpec = '%d';
 PointsNum = 500;
-N = 4;
-R = 4;
+N = 8;
+R = 7;
 B = 14;
-M = 1;
+M = 2;
 
 K = N*(20*log10(R));
 Knew = 10^(K/20);
 
 BitGrowth = log2(Knew);
 
-Bmax = ceil(log2(18));
+Bmax = ceil(log2(((R*M)^N)/R)+B);
 x = 1:1:PointsNum;
 xDecim = 1:1:PointsNum/R;
 Fs = 50;
@@ -34,30 +34,27 @@ FilteredDataFft = FilteredDataFft(1:FilteredDataPNum/2);
 Freqs = Fs*(1:(PointsNum/2))/PointsNum;
 FreqsDecim = Fs/R*(1:(FilteredDataPNum/2))/FilteredDataPNum;
 
-figure(1)
-subplot(2,1,1)
-plot(x, InDataSignal) 
-title("In Signal")
-xlabel("Time")
-ylabel("Amp")
-
-
-subplot(2,1,2)
-plot(Freqs,abs(InDataFft)) 
-title("Single-Sided Amplitude Spectrum of InData")
-xlabel("f (Hz)")
-ylabel("Amp")
-
-figure(2)
-subplot(2,1,1)
-plot(xDecim, FilteredData) 
-title("FilteredData")
-xlabel("Time")
-ylabel("Amp")
-
-subplot(2,1,2)
-plot(FreqsDecim,10*log10(FilteredDataFft)) 
-% plot(FreqsDecim,abs(FilteredDataFft)) 
-title("Single-Sided Amplitude Spectrum of FilteredData")
-xlabel("f (Hz)")
-ylabel("Amp")
+##figure(1)
+##subplot(4,1,1)
+##plot(x, InDataSignal)
+##title("In Signal")
+##xlabel("Time")
+##ylabel("Amp")
+##
+##subplot(4,1,2)
+##plot(Freqs,abs(InDataFft))
+##title("Single-Sided Amplitude Spectrum of InData")
+##xlabel("f (Hz)")
+##ylabel("Amp")
+##
+##subplot(4,1,3)
+##plot(xDecim, FilteredData)
+##title("FilteredData")
+##xlabel("Time")
+##ylabel("Amp")
+##
+##subplot(4,1,4)
+##plot(FreqsDecim,abs(FilteredDataFft))
+##title("Single-Sided Amplitude Spectrum of FilteredData")
+##xlabel("f (Hz)")
+##ylabel("Amp")

+ 105 - 230
src/src/Sim/FilteredData.txt

@@ -1,250 +1,125 @@
     -1
-   -15
-   -47
-   -42
-   -32
-   -38
-   -14
-   -16
-    -1
-    15
-    13
-    37
-    31
-    41
-    47
-    34
-    46
-    28
-    25
-    20
-    -3
-     2
+    -7
+   -40
+   -70
+   -56
    -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
-    -1
-    15
-    13
-    37
-    31
-    41
-    47
-    34
-    46
-    28
-    25
     20
-    -3
-     2
-   -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
+    55
+    77
+    79
+    62
+    29
+   -11
+   -48
+   -74
+   -82
+   -69
+   -40
     -1
-    15
-    13
-    37
-    31
-    41
+    39
+    68
+    81
+    73
     47
-    34
-    46
-    28
-    25
-    20
-    -3
-     2
+    10
+   -30
+   -63
+   -80
+   -78
+   -56
    -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
-    -1
-    15
-    13
-    37
-    31
-    41
-    47
-    34
-    46
-    28
-    25
     20
-    -3
-     2
-   -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
+    55
+    77
+    79
+    62
+    29
+   -11
+   -48
+   -74
+   -82
+   -69
+   -40
     -1
-    15
-    13
-    37
-    31
-    41
+    39
+    68
+    81
+    73
     47
-    34
-    46
-    28
-    25
-    20
-    -3
-     2
+    10
+   -30
+   -63
+   -80
+   -78
+   -56
    -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
-    -1
-    15
-    13
-    37
-    31
-    41
-    47
-    34
-    46
-    28
-    25
     20
-    -3
-     2
-   -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
+    55
+    77
+    79
+    62
+    29
+   -11
+   -48
+   -74
+   -82
+   -69
+   -40
     -1
-    15
-    13
-    37
-    31
-    41
+    39
+    68
+    81
+    73
     47
-    34
-    46
-    28
-    25
-    20
-    -3
-     2
+    10
+   -30
+   -63
+   -80
+   -78
+   -56
    -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
-    -1
-    15
-    13
-    37
-    31
-    41
-    47
-    34
-    46
-    28
-    25
     20
-    -3
-     2
-   -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
+    55
+    77
+    79
+    62
+    29
+   -11
+   -48
+   -74
+   -82
+   -69
+   -40
     -1
-    15
-    13
-    37
-    31
-    41
+    39
+    68
+    81
+    73
     47
-    34
-    46
-    28
-    25
-    20
-    -3
-     2
+    10
+   -30
+   -63
+   -80
+   -78
+   -56
    -21
-   -26
-   -29
-   -47
-   -35
-   -49
-   -42
-   -32
-   -38
-   -14
-   -16
+    20
+    55
+    77
+    79
+    62
+    29
+   -11
+   -48
+   -74
+   -82
+   -69
+   -40
     -1
-    15
-    13
-    37
-    31
-    41
+    39
+    68
+    81
+    73
     47
-    34
-    46
-    28
-    25
-    20
-    -3
-     2
-   -21
-   -26
-   -29
+    10

+ 2 - 2
src/src/Sim/S5243TopSpectrumTb.v

@@ -41,7 +41,7 @@ module S5243TopSpectrumTb;
 	localparam	[1:0]	CURRADCCHANNEL	=	2'h3;
 	//COMMANDS	FOR REG_MAP
 	// parameter	[31:0]	MeasCmdBypass	=	{8'h11,8'h0,8'h63,7'h1,1'h1};
-	parameter	[31:0]	MeasCmdFft 		=	{8'h11,8'h0,8'h63,7'h4,1'b1};
+	parameter	[31:0]	MeasCmdFft 		=	{8'h11,8'h0,8'h63,7'h1,1'b1};
 	parameter	[31:0]	AdcCtrl =	{8'h12,24'h2};
 	parameter	[31:0]	SensCtrlCmd =	{1'b0,21'h0,CURRADCCHANNEL,4'h0,4'h1};
 	parameter	[31:0]	DitherCmd 	= {8'h0E,8'd9,4'h0,4'h1,4'd11,4'h3};
@@ -49,7 +49,7 @@ module S5243TopSpectrumTb;
 	parameter	[31:0]	IfFtwL 	=	{8'h16,24'h000000};
 	parameter	[31:0]	FilterCorrCmdH 		=	{8'h17,24'hD70A3D};
 	parameter	[31:0]	FilterCorrCmdL 		=	{8'h18,24'hD70A3D};
-	parameter	[31:0]	MeasNum0RegCmd		=	{8'h58,24'd10};
+	parameter	[31:0]	MeasNum0RegCmd		=	{8'h58,24'd1};
 	parameter	[31:0]	MeasNum1RegCmd		=	{8'h59,MUXSLOWMODCMD,MUXFASTMODCMD,DSPTRIGINCMD,25'd0};
 	//===========================================================================================
 	

+ 8 - 8
src/src/Top/S5243Top.v

@@ -679,20 +679,20 @@ ExternalDspInterface
 	
 	.OscDataRdFlag_o	(oscDataRdFlag),
 	
-	// .Adc1ChT1Data_i		(adc1ChT1Data),	
-	// .Adc1ChR1Data_i		(adc1ChR1Data),	
-	// .Adc2ChR2Data_i		(adc2ChT2Data),	
-	// .Adc2ChT2Data_i		(adc2ChR2Data),	
+	.Adc1ChT1Data_i		(adc1ChT1Data),	
+	.Adc1ChR1Data_i		(adc1ChR1Data),	
+	.Adc2ChR2Data_i		(adc2ChT2Data),	
+	.Adc2ChT2Data_i		(adc2ChR2Data),	
 
 	// .Adc1ChT1Data_i		(AdcData_i),	
 	// .Adc1ChR1Data_i		(AdcData_i),	
 	// .Adc2ChR2Data_i		(AdcData_i),	
 	// .Adc2ChT2Data_i		(AdcData_i),	
 	
-	.Adc1ChT1Data_i		(ncoCos[NcoWidth-1-:14]),	
-	.Adc1ChR1Data_i		(ncoCos[NcoWidth-1-:14]),	
-	.Adc2ChR2Data_i		(ncoCos[NcoWidth-1-:14]),	
-	.Adc2ChT2Data_i		(ncoCos[NcoWidth-1-:14]),	
+	// .Adc1ChT1Data_i		(sinAdd),	
+	// .Adc1ChR1Data_i		(sinAdd),	
+	// .Adc2ChR2Data_i		(sinAdd),	
+	// .Adc2ChT2Data_i		(sinAdd),	
 	
 	.Mosi_o				(adcInitMosi),
 	.Sck_o				(adcInitSck),