0
我遇到了我的FIR信號輸出問題。信號不會被濾除,並且會有很多靜態信號。雖然我的實現似乎工作正常。我的乘數函數是從quartus軟件中的現有庫創建的,並被設置爲有符號乘法。我真的不知道發生了什麼,並會感謝任何幫助!謝謝!Verilog FIR濾波器代碼錯誤
代碼:
`timescale 1ns/1ps
module fir_filter (input sample_clock, input reset, input [15:0] input_sample1, output [15:0] output_sample1);
parameter N = 65; //Specify the number of taps
reg [15:0] delayholder[N-1:0];
wire [31:0] summation[N-1:0];
wire [15:0] finsummations[N-1:0];
wire [15:0] finsummation;
integer x;
integer z;
//Specifying our coefficients
reg signed[15:0] coeffs[200:0];
always @(*)
begin
for (x=0; x<N; x=x+31)
begin
coeffs[x+0] = 0;
coeffs[x+1] = 2267;
coeffs[x+2] = 0;
coeffs[x+3] = -3030;
coeffs[x+4] = 0;
coeffs[x+5] = 4621;
coeffs[x+6] = 0;
coeffs[x+7] = -6337;
coeffs[x+8] = 0;
coeffs[x+9] = 7985;
coeffs[x+10] = 0;
coeffs[x+11] = -9536;
coeffs[x+12] = 1;
coeffs[x+13] = 10265;
coeffs[x+14] = -1;
coeffs[x+15] = 87720;
coeffs[x+16] = -1;
coeffs[x+17] = 10265;
coeffs[x+18] = 1;
coeffs[x+19] = -9536;
coeffs[x+20] = 0;
coeffs[x+21] = 7985;
coeffs[x+22] = 0;
coeffs[x+23] = -6337;
coeffs[x+24] = 0;
coeffs[x+25] = 4621;
coeffs[x+26] = 0;
coeffs[x+27] = -3030;
coeffs[x+28] = 0;
coeffs[x+29] = 2267;
coeffs[x+30] = 0;
end
end
generate
genvar i;
for (i=0; i<N; i=i+1)
begin: mult1
multiplier mult1(.dataa(coeffs[i]), .datab(delayholder[i]),.result(summation[i]));
end
endgenerate
always @(posedge sample_clock or posedge reset)
begin
if(reset)
begin
output_sample1 = 0;
for (z=0; z<N; z=z+1)
begin
delayholder[z] = 0;
end
end
else
begin
for (z=N-1; z>0; z=z-1)
begin
delayholder[z] = delayholder[z-1];
end
delayholder[0] = input_sample1;
end
for (z=0; z<N; z=z+1)
begin
finsummations[z] = summation[z] >> 15; //{summation[z][15], summation[z][15], summation[z][15:2]}
end
finsummation = 0;
for (z=0; z<N; z=z+1)
begin
finsummation = finsummation + finsummations[z];
end
output_sample1 = finsummation;
end
endmodule
乘數代碼:
`timescale 1 ps/1 ps
module multiplier (dataa,datab,result);
input [15:0] dataa;
input [15:0] datab;
output [31:0] result;
wire [31:0] sub_wire0;
wire [31:0] result = sub_wire0[31:0];
lpm_mult lpm_mult_component (
.dataa (dataa),
.datab (datab),
.result (sub_wire0),
.aclr (1'b0),
.clken (1'b1),
.clock (1'b0),
.sum (1'b0));
defparam
lpm_mult_component.lpm_hint = "MAXIMIZE_SPEED=5",
lpm_mult_component.lpm_representation = "SIGNED",
lpm_mult_component.lpm_type = "LPM_MULT",
lpm_mult_component.lpm_widtha = 16,
lpm_mult_component.lpm_widthb = 16,
lpm_mult_component.lpm_widthp = 32;