浏览代码

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

ChStepan 1 年之前
父节点
当前提交
6cfaee92a1

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

@@ -89,11 +89,11 @@ module	DecimFilterWrapper
 //	ASSIGNMENTS
 //================================================================================
 
-	// assign	FilteredAdcDataI_o	=	outDataI;
-	assign	FilteredAdcDataI_o	=	(bypassData)?{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i}:firData[33-:16];
+	assign	FilteredAdcDataI_o	=	outDataI;
+	// assign	FilteredAdcDataI_o	=	(bypassData)?{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i}:firData[33-:16];
 
-	// assign	FilteredDataVal_o	=	decimDataValIR;
-	assign	FilteredDataVal_o	=	(bypassData)?1'b1:firDataVal;
+	assign	FilteredDataVal_o	=	decimDataValIR;
+	// assign	FilteredDataVal_o	=	(bypassData)?1'b1:firDataVal;
 
 
 // {{14{AdcData_i[AdcDataWidth-1]}},AdcData_i}

+ 27 - 42
src/src/Sim/CicTest.m

@@ -1,5 +1,5 @@
 FormatSpec = '%d';
-PointsNum = 500;
+PointsNum = 2000;
 N = 8;
 R = 2;
 B = 14;
@@ -24,7 +24,6 @@ FilterCoefs = fscanf(ReadFilterCoefsId,FormatSpec);
 fclose(ReadFilterCoefsId);
 
 
-
 InDataFft = fft(InDataSignal);
 InDataFft = InDataFft(1:PointsNum/2);
 
@@ -34,7 +33,7 @@ FilteredDataFft = fft(FilteredData);
 FilteredDataFft = FilteredDataFft(1:FilteredDataPNum/2);
 
 CicResp = 20*log10(abs(FilteredDataFft));
-CicResp = CicResp-max(CicResp)
+CicResp = CicResp - max(CicResp)
 
 Freqs = (Fs*(1:(PointsNum/2))/PointsNum);
 FreqsDecim = Fs/R*(1:(FilteredDataPNum/2))/FilteredDataPNum;
@@ -47,55 +46,41 @@ FirResponce = FirResponce-max(FirResponce)
 CicComp = CicResp + FirResponce;
 CicComp = CicComp - max(CicComp);
 
-HCIC = (R^-N*abs(1*M*sin(pi*M*R*FreqsDecim) ./ sin(pi*FreqsDecim)).^N);
-HCICdb = 20 * log10(abs(HCIC));
+##figure('name','CIC/FIR Frequency Response', 'Numbertitle', 'off')
+##  plot(FreqsDecim, FirResponce, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
+##  hold on;
+##
+##  plot(FreqsDecim, CicComp, '--', 'LineWidth', 2, 'Color',[0.2 0.5 0]);
+##  hold on;
+##
+##  plot(FreqsDecim, CicResp, '-', 'LineWidth', 2, 'Color',[1 0 0]);
+##  hold on;
+##
+##  title([{'CIC, Comp. FIR and Result'};{sprintf('Filter Order = %i',N)}]);
+##  xlabel ('Freq (\pi x rad / samples)');
+##  ylabel ('Magnitude (dB)');
+##  legend('Comp. FIR','Sum Response','CIC filter','location','northeast');
+##  grid on;
+
+Hcic = abs((sin(pi*M*R*NormFreqs) ./ sin(pi*NormFreqs))).^N;
+Hcicdb = 20 * log10(abs(Hcic));
+Hcicdb = Hcicdb - max(Hcicdb);
 
-figure('name','CIC/FIR Frequency Response', 'Numbertitle', 'off')
-  plot(FreqsDecim, FirResponce, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
-  hold on;
 
-  plot(FreqsDecim, CicComp, '--', 'LineWidth', 2, 'Color',[0.2 0.5 0]);
+figure('name','Cic Calc and Cic Real', 'Numbertitle', 'off')
+  plot( Hcicdb, '-.', 'LineWidth', 2, 'Color',[0 0 1]);
   hold on;
 
-  plot(FreqsDecim, CicResp, '-', 'LineWidth', 2, 'Color',[1 0 0]);
+  plot( CicResp, '--', 'LineWidth', 2, 'Color',[0.2 0.5 0]);
   hold on;
 
-  title([{'CIC, Comp. FIR and Result'};{sprintf('Filter Order = %i',N)}]);
+  title([{'CIC calc, CIC real'};{sprintf('Filter Order = %i',N)}]);
   xlabel ('Freq (\pi x rad / samples)');
   ylabel ('Magnitude (dB)');
-  legend('Comp. FIR','Sum Response','CIC filter','location','northeast');
+  axis([0 PointsNum/R]);
+  legend('CIC calc','CIC real','location','northeast');
   grid on;
 
-NFFT  = 2^14;  % FFT points for Freq Response (spectrum)
-STEP = 1/NFFT;   % Step size
-ff = 0:1/NFFT:1-1/NFFT;
-
-Hcic = abs((sin(pi*M*R*NormFreqs) ./ sin(pi*NormFreqs))).^N;
-Hcicdb = 20 * log10(abs(Hcic));
-Hcicdb = Hcicdb - max(Hcicdb);
-##figure('name','Cic Response', 'Numbertitle', 'off')
-##plot(FreqsDecim, CicResp - max(CicResp), '-.', 'LineWidth', 2, 'Color',[0 0 1]);
-##
-##title([{'Cic Response'}]);
-##xlabel ('Freq (\pi x rad / samples)');
-##ylabel ('Magnitude');
-##axis tight;
-##grid on;
-##
-##figure('name','CicResp', 'Numbertitle', 'off')
-##  plot(NormFreqs, CicResp, 'LineWidth', 2, 'Color',[0 0 1]);
-##  hold on;
-##
-##figure('name','HCICdb Frequency Response', 'Numbertitle', 'off')
-##  plot(NormFreqs, Hcicdb, 'LineWidth', 2, 'Color',[0.2 0.5 0]);
-##  hold on;
-
-figure('name','Resulting Frequency Response', 'Numbertitle', 'off')
-plot(FreqsDecim,20*log10(abs(FilteredDataFft)), 'LineWidth',2)
-title("Single-Sided Amplitude Spectrum of cic+fir filter")
-xlabel("f (Hz)")
-ylabel("Amp")
-
 
 
 

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

@@ -17,7 +17,7 @@ real	signal;
 reg		[31:0]	tbCnt;
 reg		[31:0]	pNumCnt;
 // wire	oscWind	=	(tbCnt>=4500&tbCnt<=5499)?	1'b1:1'b0;
-wire	oscWind	=	(tbCnt>=4500&tbCnt<=4999)?	1'b1:1'b0;
+wire	oscWind	=	(tbCnt>=4500&tbCnt<=6499)?	1'b1:1'b0;
 
 wire	signed	[13:0]	ncoSin1;
 wire	signed	[13:0]	ncoCos1;
@@ -55,7 +55,7 @@ parameter	MaxWidth	=	38;
 initial begin
 	Clk50		=	1'b1;
 	Rst			=	1'b1;
-	decimFactor	=	3'd1;
+	decimFactor	=	3'd2;
 #100;
 	Rst		=	1'b0;
 end	
@@ -153,8 +153,8 @@ DecimFilter
 	.IfFtwL_i		(24'h51eb85),
 	.IfFtwH_i		(24'h23),
 	
-	// .AdcData_i		(singlePulse),
-	.AdcData_i		(sinAdd),
+	.AdcData_i		(singlePulse),
+	// .AdcData_i		(sinAdd),
 	// .AdcData_i		(adcDataMixedCut),
 	
 	.FilteredAdcDataI_o	(resultI),

文件差异内容过多而无法显示
+ 7495 - 0
src/src/Sim/FilteredData.txt


文件差异内容过多而无法显示
+ 2000 - 0
src/src/Sim/InputSignal.txt


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

@@ -60,9 +60,9 @@ M = 1;         % Differential delay (only 1)
 %  ---- FIR filter parameters
 %  ------------------------------------------------------------------------
 
-NFIR  = 15;     % Filter order, must be odd when Fo = 0.5 !!!
+NFIR  = 16;     % Filter order, must be odd when Fo = 0.5 !!!
 Bc    = 16;     % Coef. Bit-width
-Fo    = 0.5;    % Normalized Cutoff: 0.2 < Fo < 0.5;
+Fo    = 0.4;    % Normalized Cutoff: 0.2 < Fo < 0.5;
 BETA  = 8;      % BETA parameter for Kaiser window (if IS_WIND = 'Y')
 
 %% ------------------------------------------------------------------------
@@ -73,8 +73,8 @@ IS_COE      = 'Y'; % create *.COE Xilinx file
 IS_HDR      = 'N'; % create *.H file (header)
 IS_WIND     = 'N'; % use Kaiser Window for FIR corrector
 
-IS_PLOT_IDL = 'Y'; % plot ideal response
-IS_PLOT_FIR = 'Y'; % plot FIR filter IR
+IS_PLOT_IDL = 'N'; % plot ideal response
+IS_PLOT_FIR = 'N'; % plot FIR filter IR
 IS_PLOT_ERR = 'N'; % plot total error response in passband
 
 %% ------------------------------------------------------------------------
@@ -173,28 +173,7 @@ end
 %  ------------------------------------------------------------------------
 
 ## ---- Figure #1
-figure('name','CIC/FIR Frequency Response', '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 ff(NFFT)/2 -100 5]);
-  line([Fr Fr], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [0 0 1]);
-  line([Fc Fc], [-400 200], 'LineWidth', 1, 'linestyle', '-.', 'Color', [0 0.4 0]);
-  line([2*Fc 2*Fc], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [1 0 0]);
-  legend('CIC filter','Comp. FIR','Sum Response','location','northeast');
-  grid on;
-
-## ---- Figure #2
-##figure('name', 'CIC/FIR Frequency Response (Zoom)', 'Numbertitle', 'off')
+##figure('name','CIC/FIR Frequency Response', 'Numbertitle', 'off')
 ##  plot(ff, HCICdb - max(HCICdb), '-.', 'LineWidth', 2, 'Color',[0 0 1]);
 ##  hold on;
 ##
@@ -207,10 +186,30 @@ figure('name','CIC/FIR Frequency Response', 'Numbertitle', 'off')
 ##  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*R) -7 1]);
-##  line([Fr Fr], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [0 0 0]);
+##  axis([0 ff(NFFT)/2 -100 5]);
+##  line([Fr Fr], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [0 0 1]);
+##  line([Fc Fc], [-400 200], 'LineWidth', 1, 'linestyle', '-.', 'Color', [0 0.4 0]);
+##  line([2*Fc 2*Fc], [-400 200], 'LineWidth', 1, 'linestyle', '--', 'Color', [1 0 0]);
+##  legend('CIC filter','Comp. FIR','Sum Response','location','northeast');
 ##  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;
+
 %% ------------------------------------------------------------------------
 % ---- Passband irregularity
 %  ------------------------------------------------------------------------