فهرست منبع

Тестовые изменения.

ChStepan 1 سال پیش
والد
کامیت
fcf3bc7949

+ 14 - 29
src/src/FftDataFiltering/DecimFilterWrapper.v

@@ -106,59 +106,44 @@ always	@(posedge	Clk_i)	begin
 	if	(!Rst_i)	begin
 		case(DecimFactor_i)
 			3'd0:	begin
-						outDataI	<=	{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i};
-						outDataQ	<=	AdcData_i;
+						// outDataI	<=	{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i};
+						outDataI	<=	AdcData_i;
 						decimDataValIR	<=	OscWind_i;
-						decimDataValQR	<=	OscWind_i;
 					end
 			3'd1:	begin
-						outDataI	<=	{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i};
-						// outDataI	<=	AdcData_i;
+						// outDataI	<=	{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i};
+						outDataI	<=	decimDataI[maxWidthForR1-:16];
 						decimDataValIR	<=	OscWind_i;
-						decimDataValQR	<=	OscWind_i;
 					end
 			3'd2:	begin
 						outDataI	<=	decimDataI[maxWidthForR2-:16];
-						outDataQ	<=	decimDataQ[maxWidthForR2-:16];
-						decimDataValIR	<=	1'b1;
-						decimDataValQR	<=	decimDataValQ;
+						// decimDataValIR	<=	1'b1;
+						decimDataValIR	<=	decimDataValI;
 					end
 			3'd3:	begin
 						outDataI	<=	decimDataI[maxWidthForR3-:16];
-						outDataQ	<=	decimDataQ[maxWidthForR3-:16];
 						decimDataValIR	<=	decimDataValI;
-						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd4:	begin
 						outDataI	<=	decimDataI[maxWidthForR4-:16];
-						outDataQ	<=	decimDataQ[maxWidthForR4-:16];
 						decimDataValIR	<=	decimDataValI;
-						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd5:	begin
 						outDataI	<=	decimDataI[maxWidthForR5-:16];
-						outDataQ	<=	decimDataQ[maxWidthForR5-:16];
 						decimDataValIR	<=	decimDataValI;
-						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd6:	begin
 						outDataI	<=	decimDataI[maxWidthForR6-:16];
-						outDataQ	<=	decimDataQ[maxWidthForR6-:16];
 						decimDataValIR	<=	decimDataValI;
-						decimDataValQR	<=	decimDataValQ;
 					end
 			3'd7:	begin
 						outDataI	<=	decimDataI[maxWidthForR7-:16];
-						outDataQ	<=	decimDataQ[maxWidthForR7-:16];
 						decimDataValIR	<=	decimDataValI;
-						decimDataValQR	<=	decimDataValQ;
 					end
 		endcase
 	end	else	begin
 		outDataI	<=	16'd0;
-		outDataQ	<=	16'd0;
 		decimDataValIR	<=	1'b0;
-		decimDataValQR	<=	1'b0;
 	end
 end
 
@@ -181,14 +166,14 @@ cicFilterInstI
 	.DataValid_o	(decimDataValI)
 );
 
-FirFilter FirFilter (
-  .aclk(Clk_i),                              // input wire aclk
-  .s_axis_data_tvalid(decimDataValI),  // input wire s_axis_data_tvalid
-  .s_axis_data_tready(),  // output wire s_axis_data_tready
-  .s_axis_data_tdata(outDataI),    // input wire [15 : 0] s_axis_data_tdata
-  .m_axis_data_tvalid(firDataVal),  // output wire m_axis_data_tvalid
-  .m_axis_data_tdata(firData)    // output wire [39 : 0] m_axis_data_tdata
-);
+// FirFilter FirFilter (
+  // .aclk(Clk_i),                              // input wire aclk
+  // .s_axis_data_tvalid(decimDataValI),  // input wire s_axis_data_tvalid
+  // .s_axis_data_tready(),  // output wire s_axis_data_tready
+  // .s_axis_data_tdata(outDataI),    // input wire [15 : 0] s_axis_data_tdata
+  // .m_axis_data_tvalid(firDataVal),  // output wire m_axis_data_tvalid
+  // .m_axis_data_tdata(firData)    // output wire [39 : 0] m_axis_data_tdata
+// );
 
 endmodule
 

+ 13 - 9
src/src/Sim/CicTest.m

@@ -10,6 +10,7 @@ Bmax = ceil(log2(((R*M)^N)/R)+B);
 x = 1:1:PointsNum;
 xDecim = 1:1:PointsNum/R;
 Fs = 50;
+ff = 0:1/PointsNum*2:1-1/PointsNum*2;
 
 ReadInDataId = fopen('C:/S5243_FFT_REPO/src/src/Sim/InputSignal.txt','r');
 InDataSignal = fscanf(ReadInDataId,FormatSpec);
@@ -62,30 +63,33 @@ CicComp = CicComp - max(CicComp);
 ##  legend('Comp. FIR','Sum Response','CIC filter','location','northeast');
 ##  grid on;
 
-Hcic = abs((sin(pi*M*R*NormFreqs) ./ sin(pi*NormFreqs))).^N;
+
+
+Hcic = abs((sin(pi*M*R*ff) ./ sin(pi*ff))).^N;
 Hcicdb = 20 * log10(abs(Hcic));
 Hcicdb = Hcicdb - max(Hcicdb);
+HcicdbCut = Hcicdb(1:500);
 
 
 figure('name','Cic Calc and Cic Real', 'Numbertitle', 'off')
-  plot( Hcicdb, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
+  plot(FreqsDecim,HcicdbCut, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
   hold on;
 
-  plot( CicResp, '--', 'LineWidth', 2, 'Color',[0.2 0.5 0]);
+  plot(FreqsDecim,CicResp, '--', 'LineWidth', 2, 'Color',[0.2 0.5 0]);
   hold on;
 
   title([{'CIC calc, CIC real'};{sprintf('Filter Order = %i',N)}]);
   xlabel ('Freq (\pi x rad / samples)');
   ylabel ('Magnitude (dB)');
-  axis([0 PointsNum/R]);
   legend('CIC calc','CIC real','location','northeast');
   grid on;
 
-
-
-
-
-
+##figure(1)
+##plot(FreqsDecim,HcicdbCut, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
+##
+##figure(2)
+##plot(FreqsDecim,CicResp, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
+##
 
 
 

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

@@ -39,8 +39,8 @@ wire	signed	[13:0]	sinAdd	=	(ncoSin1>>>1)+(ncoSin2>>>1);
 
 wire	signed	[17:0]	wind;
 
-// wire	signed	[13:0]	singlePulse	=	(tbCnt>=4505&tbCnt<=4510)?	14'h1fff:14'h0;
-wire	signed	[13:0]	singlePulse	=	(tbCnt==4505)?	14'h1fff:14'h0;
+wire	signed	[13:0]	singlePulse	=	(tbCnt>=4500&tbCnt<=4532)?	14'h1fff:14'h0;
+// wire	signed	[13:0]	singlePulse	=	(tbCnt==4505)?	14'h1fff:14'h0;
 //==========================================================================================
 //clocks gen
 always	#10 Clk50	=	~Clk50;
@@ -124,7 +124,7 @@ ncoInst2
 	.Clk_i		(Clk50),
 	.Rst_i		(Rst),
 	.Val_i		(1'b1),
-	.PhaseInc_i	(32'h3d70a3d7),
+	.PhaseInc_i	(32'h428f5c28),
 	.WindVal_i	(1'b1),
 	.WinType_i	(),
 	.Wind_o		(),

+ 2 - 2
src/src/Sim/FFTTest.m

@@ -1,7 +1,7 @@
 FormatSpec = '%d';
-PointsNum = 500;
+PointsNum = 2000;
 N = 8;
-R = 4;
+R = 2;
 B = 14;
 M = 1;
 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 20 - 6515
src/src/Sim/FilteredData.txt


+ 32 - 32
src/src/Sim/InputSignal.txt

@@ -1,36 +1,36 @@
-     0
-     0
-     0
-     0
-     0
   8191
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
-     0
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
+  8191
      0
      0
      0

+ 28 - 28
src/src/Sim/KapitanovScriptForCicComp.m

@@ -53,7 +53,7 @@ clear all;
 %  ------------------------------------------------------------------------
 
 R = 2;         % Decimation factor
-N = 8;         % Number of stages
+N = 1;         % Number of stages
 M = 1;         % Differential delay (only 1)
 
 %% ------------------------------------------------------------------------
@@ -194,21 +194,21 @@ end
 ##  grid on;
 
 ## ---- Figure #2
-figure('name', 'CIC/FIR Frequency Response (Zoom)', 'Numbertitle', 'off')
-  plot(ff, HCICdb - max(HCICdb), '-.', 'LineWidth', 2, 'Color',[0 0 1]);
-  hold on;
-
-  plot(ff, H_amp, '--', 'LineWidth', 2, 'Color',[0 0.4 0]);
-  hold on;
-
-  plot(ff, H_comp, '-', 'LineWidth', 2, 'Color',[1 0 0]);
-  hold on;
-
-  title([{'CIC, Comp. FIR and Result'};{sprintf('Filter Order = %i, Coef. width = %i',NFIR,Bc)}]);
-  xlabel ('Freq (\pi x rad / samples)');
-  ylabel ('Magnitude (dB)');
-  axis([0 1 -300 0]);
-  grid on;
+##figure('name', 'CIC/FIR Frequency Response (Zoom)', 'Numbertitle', 'off')
+##  plot(ff, HCICdb - max(HCICdb), '-.', 'LineWidth', 2, 'Color',[0 0 1]);
+##  hold on;
+##
+##  plot(ff, H_amp, '--', 'LineWidth', 2, 'Color',[0 0.4 0]);
+##  hold on;
+##
+##  plot(ff, H_comp, '-', 'LineWidth', 2, 'Color',[1 0 0]);
+##  hold on;
+##
+##  title([{'CIC, Comp. FIR and Result'};{sprintf('Filter Order = %i, Coef. width = %i',NFIR,Bc)}]);
+##  xlabel ('Freq (\pi x rad / samples)');
+##  ylabel ('Magnitude (dB)');
+##  axis([0 1 -300 0]);
+##  grid on;
 
 %% ------------------------------------------------------------------------
 % ---- Passband irregularity
@@ -264,16 +264,16 @@ if (IS_HDR == 'Y')
   fclose(fid);
 end
 
-##figure('name','CIC/FIR Frequency Response', 'Numbertitle', 'off')
-##
-##  plot(ff, H_amp, '--', 'LineWidth', 2, 'Color',[0 0.4 0]);
-##  hold on;
-##
-##  title([{'CIC, Comp. FIR and Result'};{sprintf('Filter Order = %i, Coef. width = %i',NFIR,Bc)}]);
-##  xlabel ('Freq (\pi x rad / samples)');
-##  ylabel ('Magnitude (dB)');
-##  axis([0 ff(NFFT)/2 -100 5]);
-##  line([Fr Fr], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [0 0 0]);
-##  legend('Comp. FIR','location','northeast');
-##  grid on;
+figure('name','CIC/FIR Frequency Response', 'Numbertitle', 'off')
+
+  plot(ff,  HCICdb - max(HCICdb), '--', 'LineWidth', 2, 'Color',[0 0.4 0]);
+  hold on;
+
+  title([{'CIC, Comp. FIR and Result'};{sprintf('Filter Order = %i, Coef. width = %i',NFIR,Bc)}]);
+  xlabel ('Freq (\pi x rad / samples)');
+  ylabel ('Magnitude (dB)');
+  axis([0 ff(NFFT)/2 -100 5]);
+  line([Fr Fr], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [0 0 0]);
+  legend('Comp. FIR','location','northeast');
+  grid on;