Quellcode durchsuchen

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

ChStepan vor 1 Jahr
Ursprung
Commit
72f29c1486

+ 10 - 9
src/src/FftDataFiltering/DecimFilterWrapper.v

@@ -72,9 +72,9 @@ module	DecimFilterWrapper
 	localparam	extendBitNum	=	FilteredDataWidth-AdcDataWidth;
 	
 	localparam	maxWidthForR1	=	10'd16;	//msb for R = 2;
-	localparam	maxWidthForR2	=	10'd21;	//msb for R = 2;
+	localparam	maxWidthForR2	=	10'd23;	//msb for R = 2;
 	localparam	maxWidthForR3	=	10'd26;	//msb for R = 3;
-	localparam	maxWidthForR4	=	10'd28;	//msb for R = 4;
+	localparam	maxWidthForR4	=	10'd30;	//msb for R = 4;
 	localparam	maxWidthForR5	=	10'd31;	//msb for R = 5;
 	localparam	maxWidthForR6	=	10'd33;	//msb for R = 6;
 	localparam	maxWidthForR7	=	10'd34;	//msb for R = 7;
@@ -89,8 +89,9 @@ module	DecimFilterWrapper
 //	ASSIGNMENTS
 //================================================================================
 
-	assign	FilteredAdcDataI_o	=	outDataI;
+	// assign	FilteredAdcDataI_o	=	outDataI;
 	// assign	FilteredAdcDataI_o	=	(bypassData)?{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i}:firData[33-:16];
+	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;
@@ -112,28 +113,28 @@ always	@(posedge	Clk_i)	begin
 					end
 			3'd1:	begin
 						// outDataI	<=	{{2{AdcData_i[AdcDataWidth-1]}},AdcData_i};
-						outDataI	<=	decimDataI[maxWidthForR1-:16];
+						outDataI	<=	decimDataI[maxWidthForR1-1-:16];
 						decimDataValIR	<=	OscWind_i;
 					end
 			3'd2:	begin
-						outDataI	<=	decimDataI[maxWidthForR2-:16];
+						outDataI	<=	decimDataI[maxWidthForR2-1-:16];
 						// decimDataValIR	<=	1'b1;
 						decimDataValIR	<=	decimDataValI;
 					end
 			3'd3:	begin
-						outDataI	<=	decimDataI[maxWidthForR3-:16];
+						outDataI	<=	decimDataI[maxWidthForR3-1-:16];
 						decimDataValIR	<=	decimDataValI;
 					end
 			3'd4:	begin
-						outDataI	<=	decimDataI[maxWidthForR4-:16];
+						outDataI	<=	decimDataI[maxWidthForR4-1-:16];
 						decimDataValIR	<=	decimDataValI;
 					end
 			3'd5:	begin
-						outDataI	<=	decimDataI[maxWidthForR5-:16];
+						outDataI	<=	decimDataI[maxWidthForR5-1-:16];
 						decimDataValIR	<=	decimDataValI;
 					end
 			3'd6:	begin
-						outDataI	<=	decimDataI[maxWidthForR6-:16];
+						outDataI	<=	decimDataI[maxWidthForR6-1-:16];
 						decimDataValIR	<=	decimDataValI;
 					end
 			3'd7:	begin

+ 1 - 0
src/src/FftDataFiltering/cicFilter.v

@@ -47,6 +47,7 @@ generate
 		intFilterWrapperInst
 		(
 			.Clk_i		(Clk_i),
+			.Rst_i		(Rst_i),
 			.Data_i		(inData[i]),
 			.DataNd_i	(intDataVal[i]),
 			.Data_o		(intFilteredData[i]),

+ 21 - 7
src/src/FftDataFiltering/intFilterBlock.v

@@ -4,6 +4,7 @@ module intFilterBlock
 )
 (
 	input Clk_i,
+	input Rst_i,
 	input [inOutDataWidth-1:0] Data_i,
 	input DataNd_i,
 	output [filteredDataWidth-1:0] Data_o,
@@ -12,23 +13,36 @@ module intFilterBlock
 
 	reg [1:0] ndShReg;
 	
-	always @ (posedge Clk_i)
-		ndShReg <= {ndShReg[0:0], DataNd_i};
+	always @ (posedge Clk_i)	begin
+		if	(!Rst_i)	begin
+			ndShReg <= {ndShReg[0:0], DataNd_i};
+		end	else	begin
+			ndShReg <= 2'h0;
+		end
+	end
 	
 	reg signed [inOutDataWidth-1:0] inReg;
 	reg signed [filteredDataWidth-1:0] sumResult;
 	
 	always	@(posedge	Clk_i)	begin
-		if (DataNd_i)	begin
-			inReg <= Data_i;
+		if (!Rst_i)	begin
+			if (DataNd_i)	begin
+				inReg <= Data_i;
+			end
+		end	else	begin
+			inReg	<= 0;
 		end
 	end
 	
 	always @ (posedge Clk_i)	begin
-		if (ndShReg[0])	begin
-			sumResult <= inReg + sumResult;
+		if (!Rst_i)	begin
+			if (ndShReg[0])	begin
+				sumResult <= inReg + sumResult;
+			end	else	begin
+				sumResult <= 0;
+			end
 		end	else	begin
-			sumResult <= 0;
+			sumResult	<=	0;
 		end
 	end
 

+ 2 - 0
src/src/FftDataFiltering/intFilterWrapper.v

@@ -24,6 +24,7 @@ module intFilterWrapper
 )
 (
 	input Clk_i,
+	input Rst_i,
 	input [inOutDataWidth-1:0] Data_i,
 	input DataNd_i,
 	output [inOutDataWidth-1:0] Data_o,
@@ -40,6 +41,7 @@ module intFilterWrapper
 	intFilterBlockInst
 	(
 		.Clk_i(Clk_i),
+		.Rst_i(Rst_i),
 		.Data_i(Data_i),
 		.DataNd_i(DataNd_i),
 		.Data_o(Data_o),

+ 1 - 1
src/src/Sim/CicTest.m

@@ -2,7 +2,7 @@ FormatSpec = '%d';
 PointsNum = 2000;
 N = 8;
 R = 2;
-B = 14;
+B = 16;
 M = 1;
 
 Bmax = ceil(log2(((R*M)^N)/R)+B);

+ 11 - 0
src/src/Sim/CicTestMatlab.m

@@ -0,0 +1,11 @@
+m = 2;  % Differential delays in the filter.
+n = 4;  % Filter sections
+r = 8;   % Decimation factor
+x = int16(zeros(160,1)); x(1) = 1;    % Create a 160-point
+                                      % impulse signal.
+hm = mfilt.cicdecim(r,m,n); % Expects 16-bit input
+                            % by default.
+y = filter(hm,x);
+stem(double(y));    % Plot output as a stem plot.
+xlabel('Samples'); ylabel('Amplitude');
+title('Decimated Signal');

+ 82 - 20
src/src/Sim/DecimFilterWrapperTb.v

@@ -16,20 +16,21 @@ real	signal;
 
 reg		[31:0]	tbCnt;
 reg		[31:0]	pNumCnt;
-// wire	oscWind	=	(tbCnt>=4500&tbCnt<=5499)?	1'b1:1'b0;
+// wire	oscWind	=	(tbCnt==4505)?	1'b1:1'b0;
 wire	oscWind	=	(tbCnt>=4500&tbCnt<=6499)?	1'b1:1'b0;
+// wire	oscWind	=	(tbCnt>=1&)?	1'b1:1'b0;
 
 wire	signed	[13:0]	ncoSin1;
 wire	signed	[13:0]	ncoCos1;
 wire	signed	[13:0]	ncoSin2;
 wire	signed	[13:0]	ncoCos2;
 
-wire	signed	[15:0]	resultI;
-wire	signed	[15:0]	resultQ;
+wire	signed	[15:0]	filteredDataOut;
+wire	signed	[15:0]	impResponse;
+
 wire	resultVal;
+wire	respVal;
 
-wire	signed	[13:0]	resultICut	=	resultI[0+:14];
-wire	signed	[13:0]	resultQCut	=	resultQ[0+:14];
 
 // wire	signed	[27:0]	adcDataMixed	=	oscWind?(ncoSin1*ncoSin2):28'd0;
 wire	signed	[27:0]	adcDataMixed	=	(ncoSin1*ncoSin2);
@@ -37,10 +38,12 @@ wire	signed	[13:0]	adcDataMixedCut	=	adcDataMixed[27-:14];
 
 wire	signed	[13:0]	sinAdd	=	(ncoSin1>>>1)+(ncoSin2>>>1);
 
+reg		signed	[13:0]	currTestData;
+
 wire	signed	[17:0]	wind;
 
-wire	signed	[13:0]	singlePulse	=	(tbCnt>=4500&tbCnt<=4532)?	14'h1fff:14'h0;
-// wire	signed	[13:0]	singlePulse	=	(tbCnt==4505)?	14'h1fff:14'h0;
+// wire	signed	[13:0]	singlePulse	=	(tbCnt>=4500&tbCnt<=4550)?	14'h1fff:14'h0;
+wire	signed	[13:0]	singlePulse	=	(tbCnt==4500)?	14'h1fff:14'h0;
 //==========================================================================================
 //clocks gen
 always	#10 Clk50	=	~Clk50;
@@ -50,7 +53,7 @@ always	#10 Clk50	=	~Clk50;
 parameter	N	=	8;
 parameter	M	=	1;
 
-parameter	MaxWidth	=	38;
+parameter	MaxWidth	=	23;
 
 initial begin
 	Clk50		=	1'b1;
@@ -60,6 +63,8 @@ initial begin
 	Rst		=	1'b0;
 end	
 
+
+
 always	@(posedge	Clk50)	begin
 	if	(!Rst)	begin
 		tbCnt	<=	tbCnt+32'd1;
@@ -68,6 +73,16 @@ always	@(posedge	Clk50)	begin
 	end
 end
 
+reg	[10:0]	oscWindDelay;
+
+always	@(posedge	Clk50)	begin
+	if	(!Rst)	begin
+		oscWindDelay	<=	{oscWindDelay[20:0],oscWind};
+	end	else	begin
+		oscWindDelay	<= 22'd0;
+	end
+end
+
 always	@(posedge	Clk50)	begin
 	if	(!Rst)	begin
 		if	(oscWind)	begin
@@ -103,7 +118,7 @@ ncoInst1
 	.Clk_i		(Clk50),
 	.Rst_i		(Rst),
 	.Val_i		(1'b1),
-	.PhaseInc_i	(32'h19999999),
+	.PhaseInc_i	(32'h20000000),
 	.WindVal_i	(1'b1),
 	.WinType_i	(),
 	.Wind_o		(),
@@ -124,7 +139,7 @@ ncoInst2
 	.Clk_i		(Clk50),
 	.Rst_i		(Rst),
 	.Val_i		(1'b1),
-	.PhaseInc_i	(32'h428f5c28),
+	.PhaseInc_i	(32'h3851eb85),
 	.WindVal_i	(1'b1),
 	.WinType_i	(),
 	.Wind_o		(),
@@ -153,15 +168,40 @@ DecimFilter
 	.IfFtwL_i		(24'h51eb85),
 	.IfFtwH_i		(24'h23),
 	
-	.AdcData_i		(singlePulse),
 	// .AdcData_i		(sinAdd),
-	// .AdcData_i		(adcDataMixedCut),
+	.AdcData_i		(adcData),
 	
-	.FilteredAdcDataI_o	(resultI),
-	.FilteredAdcDataQ_o	(resultQ),
+	.FilteredAdcDataI_o	(filteredDataOut),
+	.FilteredAdcDataQ_o	(),
 	.FilteredDataVal_o	(resultVal)
 );
 
+DecimFilterWrapper	
+#(	
+	.AdcDataWidth	(14),
+	.N	(N),
+	.M	(M),
+	.FilteredDataWidth	(MaxWidth),
+	.FirOutDataWidth	(48),
+	.FirOutCutBit		(42)
+)
+ImpulseResponseFilter
+(
+	.Clk_i			(Clk50),
+	.DecimFactor_i	(decimFactor),
+	.Rst_i			(Rst),
+	.OscWind_i		(oscWind),
+	
+	.IfFtwL_i		(24'h51eb85),
+	.IfFtwH_i		(24'h23),
+	
+	.AdcData_i		(singlePulse),
+	
+	.FilteredAdcDataI_o	(impResponse),
+	.FilteredAdcDataQ_o	(),
+	.FilteredDataVal_o	()
+);
+
 reg		[32-1:0]	windArg;
 wire	[31:0]	WindPhInc		=	32'h418937<<<decimFactor-2;
 
@@ -191,7 +231,7 @@ reg	windResultVal;
 always	@(posedge	Clk50)	begin
 	if	(!Rst)	begin
 		if	(valReg[1])	begin
-			windResult	<=	wind*resultI;
+			windResult	<=	wind*filteredDataOut;
 			windResultVal	<=	1'b1;
 		end	else	begin
 			windResultVal	<=	1'b0;
@@ -217,7 +257,7 @@ wire	signed	[15:0]	windResultCut	=	windResult[32-:16];
 	// .win_o			(wind)
 // );
 
-integer inSignal,filteredData;
+integer inSignal,filteredData, impResp;
 parameter	PNum	=	5000;
 
 always	@(posedge	Clk50)	begin
@@ -226,22 +266,44 @@ always	@(posedge	Clk50)	begin
 	end	else	begin
 		if	(oscWind)	begin
 			// $display("AdcData is %d", sinAdd);
-			// $fwrite(inSignal,"%d\n",   sinAdd);
-			$fwrite(inSignal,"%d\n",   singlePulse);
+			$fwrite(inSignal,"%d\n",   sinAdd);
 		end	
 	end	
 end
 
+reg	[31:0]	testCnt;
+
+always	@(posedge	Clk50)begin
+	if	(!Rst)	begin
+		if	(oscWindDelay[6])	begin
+			testCnt	<=	testCnt	+1;
+		end
+	end	else	begin
+		testCnt	<=	0;
+	end
+end
+
 always	@(posedge	Clk50)	begin
 	if	(Rst)	begin
 		filteredData = $fopen("C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt","w");
 	end	else	begin
-		if	(resultVal)	begin
-			$fwrite(filteredData,"%d\n",   resultI);
+		if	(oscWindDelay[6]	&testCnt<=999)	begin
+			$fwrite(filteredData,"%d\n",   filteredDataOut);
 		end	
 	end	
 end
  
+
+always	@(posedge	Clk50)	begin
+	if	(Rst)	begin
+		impResp = $fopen("C:/S5243_FFT_REPO/src/src/Sim/ImpResp.txt","w");
+	end	else	begin
+		if	(oscWindDelay[6]	&testCnt<=999)	begin
+			$fwrite(impResp,"%d\n",   impResponse);
+		end	
+	end
+end 
+
 // always	@(posedge	Clk50)	begin
 	// if	(Rst)	begin
 		// filteredData = $fopen("C:/Users/Stepan/Desktop/4portCompact/S5443Current/S5443_M/S5443.srcs/sources_1/new/filteredData.txt","w");

+ 83 - 37
src/src/Sim/FFTTest.m

@@ -1,20 +1,23 @@
 FormatSpec = '%d';
-PointsNum = 2000;
+
 N = 8;
 R = 2;
-B = 14;
+B = 16;
 M = 1;
 
-K = N*(20*log10(R));
-Knew = 10^(K/20);
+PointsNum = 1000;
+FilteredDataPNum    =   PointsNum/R;
+
+Bmax = ceil(log2(((R*M)^N)/R)+B)
+MaxWidthR2 = ceil(log2(((2*M)^N)/2)+B)
+MaxWidthR4 = ceil(log2(((4*M)^N)/4)+B)
 
-BitGrowth = log2(Knew);
 
-Bmax = ceil(log2(((R*M)^N)/R)+B);
 x = 1:1:PointsNum;
 xDecim = 1:1:PointsNum/R;
 Fs = 50;
 
+#########################################################################################################################
 ReadInDataId = fopen('C:/S5243_FFT_REPO/src/src/Sim/InputSignal.txt','r');
 InDataSignal = fscanf(ReadInDataId,FormatSpec);
 fclose(ReadInDataId);
@@ -23,51 +26,94 @@ ReadFilteredDataId = fopen('C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt','r')
 FilteredData = fscanf(ReadFilteredDataId,FormatSpec);
 fclose(ReadFilteredDataId);
 
+ReadImpulseRestId = fopen('C:\S5243_FFT_REPO\src\src\Sim\ImpResp.txt','r');
+ImpulseResp = fscanf(ReadImpulseRestId,FormatSpec);
+fclose(ReadImpulseRestId);
+
 ReadFilterCoefsId = fopen('C:\S5243_FFT_REPO\src\src\Sim\CorrFilterCoefs.txt','r');
 FilterCoefs = fscanf(ReadFilterCoefsId,FormatSpec);
 fclose(ReadFilterCoefsId);
 
-InDataFft = fft(InDataSignal);
-InDataFft = InDataFft(1:PointsNum/2);
-InDataDataAbs = abs(InDataFft);
-
-FilteredDataPNum    =   PointsNum/R;
-
-FilteredDataFft = fft(FilteredData);
-FilteredDataFft = FilteredDataFft(1:FilteredDataPNum/2);
-FilteredDataAbs = 20*log10(abs(FilteredDataFft));
 
-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")
+#########################################################################################################################
+
+FreqBandOrig = Fs/2*(1:(PointsNum))/PointsNum;
+FreqbandDecim = (Fs/2*R)*(1:(PointsNum))/PointsNum;
+
+InDataFft = abs(fft(InDataSignal+randn(size(InDataSignal)))/PointsNum);
+InDataFftDb = 20*log10(InDataFft);
+
+FilteredDataFft = abs(fft(FilteredData+randn(size(FilteredData)))/PointsNum);
+FilteredDataFftDb = 20*log10(FilteredDataFft);
+
+ImpuseRespFft = abs(fft(ImpulseResp));
+ImpuseRespFftDb = 20*log10(ImpuseRespFft);
+ImpuseRespFftDb = ImpuseRespFftDb-max(ImpuseRespFftDb);
+
+
+
+#########################################################################################################################
+##figure('name','In Data Time/Freq', 'Numbertitle', 'off')
+##subplot(2,1,1)
+##plot(x, InDataSignal)
+##grid on;
+##grid minor;
+##title("In Signal")
+##xlabel("Time")
+##ylabel("Amp")
+##
+##subplot(2,1,2)
+##plot(FreqsDecim,InDataFftDb)
+##grid on;
+##grid minor;
+##title("Single-Sided Amplitude Spectrum of InData")
+##xlabel("f (Hz)")
+##ylabel("Amp")
+##
+figure('name','Frequency compare', 'Numbertitle', 'off')
+subplot(3,1,1)
+plot(InDataFftDb)
+grid on;
+grid minor;
+##axis([0 25 -70 80]);
+title("Single-Sided Amplitude Spectrum of Data before filter")
 xlabel("Time")
 ylabel("Amp")
 
-subplot(2,1,2)
-plot(Freqs,InDataDataAbs)
-title("Single-Sided Amplitude Spectrum of InData")
+subplot(3,1,2)
+plot(ImpuseRespFftDb)
+grid on;
+grid minor;
+##axis([0 50 -60 1]);
+title("Cic Frequency response")
 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,FilteredDataAbs)
-title("Single-Sided Amplitude Spectrum of FilteredData")
+subplot(3,1,3)
+plot(FilteredDataFftDb)
+grid on;
+grid minor;
+##axis([0 25 -70 80]);
+title("Single-Sided Amplitude Spectrum of Data after filter")
 xlabel("f (Hz)")
 ylabel("Amp")
 
-
-
+##figure('name','Impulse Response Time/Freq', 'Numbertitle', 'off')
+##subplot(2,1,1)
+##plot(x, ImpulseResp)
+##grid on;
+##grid minor;
+##title("In Signal")
+##xlabel("Time")
+##ylabel("Amp")
+##
+##subplot(2,1,2)
+##plot(Freqs,ImpuseRespFftDb)
+##grid on;
+##grid minor;
+##title("Single-Sided Amplitude Spectrum of InData")
+##xlabel("f (Hz)")
+##ylabel("Amp")
 
 
 

Datei-Diff unterdrückt, da er zu groß ist
+ 1000 - 1000
src/src/Sim/FilteredData.txt


Datei-Diff unterdrückt, da er zu groß ist
+ 1000 - 0
src/src/Sim/ImpResp.txt


Datei-Diff unterdrückt, da er zu groß ist
+ 2000 - 2000
src/src/Sim/InputSignal.txt


+ 20 - 32
src/src/Sim/KapitanovScriptForCicComp.m

@@ -53,7 +53,7 @@ clear all;
 %  ------------------------------------------------------------------------
 
 R = 2;         % Decimation factor
-N = 1;         % Number of stages
+N = 2;         % Number opkg f stages
 M = 1;         % Differential delay (only 1)
 
 %% ------------------------------------------------------------------------
@@ -173,25 +173,25 @@ 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('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')
@@ -264,16 +264,4 @@ if (IS_HDR == 'Y')
   fclose(fid);
 end
 
-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;