2017-02-27 2 views
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; 

答えて

0

私はフィルターには専門家だが、私は、係数を初期化するために使用されるコードのブロック内の潜在的な問題のカップルを参照してください。最初に、私はこれを最初のブロックにすることを提案したい。第2に、符号付き16ビット値の場合、-32767〜+32768の範囲がありますが、係数の1つは87720で、範囲外です。 VerilogはVHDLのように強く型付けされていないので、これを行うことができますが、結果はあなたが望むものではありません。その係数値を変更するか、係数のビット幅を増やして、増加した幅で動作するように乗数コードを変更する必要があります。最後に201個の係数が指定されていますが、代入ロジックはcoeffs 0〜92に値を代入するだけです。これはシミュレーションで「X」の束として表示されるはずです(シミュレーションでこれを試しましたか? )。あなたのデザインを合成するとき、あなたのツールは不平を言わなければなりませんが、初期化された場所にゼロの値を割り当てるだけです(ザイリンクスのVivadoはこれを行います、他のツールについてはわかりません)。いずれにしても、達成したいと思うものとツールが作り出すものとの間には違いが生じます。