module combFilterBlock 
#(
	parameter	M=4,
	parameter	inOutDataWidth	=	18,
	parameter	filteredDataWidth	=	25
)
(
	input Clk_i,
	input Rst_i,
	input [inOutDataWidth-1:0] Data_i,
	input DataNd_i,
	output [inOutDataWidth-1:0] Data_o,
	output DataValid_o
);

reg ndReg;
reg	signed	[inOutDataWidth-1:0]	inReg;
reg signed	[inOutDataWidth-1:0]	sumResult;
reg	dataValid;
reg	signed	[inOutDataWidth-1:0] delData	[M-1:0];

	always	@(posedge Clk_i)	begin
		if	(!Rst_i)	begin
			ndReg <= DataNd_i;
			if	(DataNd_i)	begin
				inReg	<=	Data_i;
			end
		end	else	begin
			ndReg	<=	0;
			inReg	<=	0;
		end
	end

genvar i;
generate 
	for (i=0; i<M; i=i+1)	begin:combGen
		always	@(posedge	Clk_i)	begin
			if	(i==0)	begin
				delData	[i]	<=	inReg;
			end	else	begin
				delData	[i]	<=	delData[i-1];
			end
		end
	end
	
	always	@(posedge	Clk_i)	begin
		if	(!Rst_i)	begin
			if	(ndReg)	begin
				sumResult	<=	inReg+-delData[M-1];
				dataValid	<=	1'b1;
			end	else	begin
				dataValid	<=	1'b0;
			end
		end	else	begin
			sumResult	<=	0;
			dataValid	<=	1'b0;
		end
	end
endgenerate

assign	Data_o	=	sumResult;
assign	DataValid_o	=	dataValid;
endmodule