We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for
Did you mean:
Participant
132 Views
Registered: ‎06-11-2019

## Coefficients of lowpass filter

Hello

I have written verilog code for lowpass filter with following coefficients, please check and let me know if its correct because not getting any output for it and not getting any error also. Not able to understand what is going wrong.

module lpfilter(clk,rst,in,out);
input [7:0]in;
input clk,rst;
output [15:0]out;
wire [15:0]j1,j2,j3,j4,j5,j6,j7,j8,j9;
wire [15:0]m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11;
wire [15:0]d11,d12,d13,d14,d15,d16,d17,d18,d19,d20;
parameter c0=0;
parameter c1=127;
parameter c2=-248;
parameter c3=-638;
parameter c4=2760;
parameter c5=5997;
parameter c6=2760;
parameter c7=-638;
parameter c8=-248;
parameter c9=127;
parameter c10=0;
assign m1=in*c0;
d_ff f1(clk,rst,in,d11);//1
assign m2=d11*c1;
assign j1=m1+m2;
d_ff f2(clk,rst,d11,d12);//2
assign m3=d12*c2;
assign j2=j1+m3;
d_ff f3(clk,rst,d12,d13);//3
assign m4=d13*c3;
assign j3=j2+m4;
d_ff f4(clk,rst,d13,d14);//4
assign m5=d14*c4;
assign j4=j3+m5;
d_ff f5(clk,rst,d14,d15);//5
assign m6=d15*c5;
assign j5=j4+m6;
d_ff f6(clk,rst,d15,d16);//6
assign m7=d16*c6;
assign j6=j5+m7;
d_ff f7(clk,rst,d16,d17);//7
assign m8=d17*c7;
assign j7=j6+m8;
d_ff f8(clk,rst,d17,d18);//8
assign m9=d18*c8;
assign j8=j7+m9;
d_ff f9(clk,rst,d18,d19);//9
assign m10=d19*c9;
assign j9=j8+m10;
d_ff f10(clk,rst,d19,d20);//10
assign m11=d20*c10;
assign out=j9+m11;
endmodule

test bench

module lpfilter_tb();
reg clk;
reg rst;
reg [7:0]in;
wire [15:0]out;
lpfilter uut(clk,rst,in,out);
initial
clk=0;
always
#5 clk=~clk;
initial
begin
rst=0;
in=0;
#10 in=91.033;
#10 in=93.37;
#10 in=91.7582;
#10 in=91.3553;
#10 in=91.9194;
#10 in=91.3553;
#10 in=91.8388;
#10 in=92.2418;
#10 in=91.7582;
#10 in=91.6777;
end
endmodule

D FF module

module d_ff(clk,rst,d,q);// sub module d flipflop
input clk,rst;
input [15:0]d;
output [15:0]q;
reg [15:0]q;
always@(posedge clk,negedge rst)
if(!rst)
q=0;
else
q<=d;
endmodule

The lowpass coefficients generated from matlab are -

0.0000 0.0127 -0.0248 -0.0638 0.2760 0.5997 0.2760 -0.0638 -0.0248  0.0127 0.0000

I multiplied these values with a constant and used in the lowpass filter code but still the code is not working.

Waiting for reply at the earliest.

Thank you

Scholar
105 Views
Registered: ‎09-16-2009

## Re: Coefficients of lowpass filter

What does "not getting any output for it" mean?  "Not working" doesn't help us - provide details!

Are you simulating, or testing on bench for an implemented design?

What does the output show?  All zeros?

Debugging DSP filters - an often used trick is to input a unit pulse - the output should be a copy of your coefficients.

Regards,

Mark