cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hexuyangguang
Observer
Observer
479 Views
Registered: ‎04-29-2021

FIR 7.2 coefficients reload question

Jump to solution

I'm trying to use the FIR 7.2 coefficients reload function.but I didn't get the expected result.

1.just check the result in matlab below(wave1):

                  wave1:

5.png

2. I use the input data and coffecient data exported form the matlab, as show below(wave2,wave3),I didn't get the result as expected;

                 wave2:

4.png

                 wave3:

3.png

 

 

3. IP Configuration

6.png

 

7.png

 

8.png

 

9.png

 

10.png

 

11.png

 

4. testbench

    please reference to below or the attachment!

`timescale 1ns / 1ps
module fir_tb(

);

reg aclk_0;
wire M_AXIS_DATA_0_tvalid;
wire m_axis_data_tvalid_0;

wire [41:0]m_axis_data_tdata_0;
reg [15:0]outData;

wire [15:0]S_0;
reg [15:0]s_axis_data_tdata_0;
reg s_axis_data_tvalid_0;
wire s_axis_data_tready_0;

reg [7:0]s_axis_config_tdata_0;
wire s_axis_config_tready_0;
reg s_axis_config_tvalid_0;

reg [15:0]s_axis_reload_tdata_0;
reg s_axis_reload_tlast_0;
wire s_axis_reload_tready_0;
reg s_axis_reload_tvalid_0;


wire [47 : 42] m_axis_data_null = 0;



integer k = 0;
integer j = 0;
integer m = 0;
integer n = 360;
reg[15:0] coeffData [1023:0];

parameter DATA_NUM = 2048;


///////////////////////////////////////////////////////////////////////
//fir IP Core
dds_fir dds_fir_i
(.S_0(S_0),
.aclk_0(aclk_0),
.m_axis_data_tdata_0({m_axis_data_null,m_axis_data_tdata_0}),
.m_axis_data_tvalid_0(m_axis_data_tvalid_0),
.s_axis_config_tdata_0(s_axis_config_tdata_0),
.s_axis_config_tready_0(s_axis_config_tready_0),
.s_axis_config_tvalid_0(s_axis_config_tvalid_0),
.s_axis_data_tdata_0(s_axis_data_tdata_0),
.s_axis_data_tready_0(s_axis_data_tready_0),
.s_axis_data_tvalid_0(s_axis_data_tvalid_0),
.s_axis_reload_tdata_0(s_axis_reload_tdata_0),
.s_axis_reload_tlast_0(s_axis_reload_tlast_0),
.s_axis_reload_tready_0(s_axis_reload_tready_0),
.s_axis_reload_tvalid_0(s_axis_reload_tvalid_0));
///////////////////////////////////////////////////////////////////////


integer i;

reg[15:0] data_mem [DATA_NUM-1:0];

initial #500 $readmemh("./OriginalSignal.txt", data_mem);

initial #600 $readmemh("./coeffData_250~400.txt", coeffData);

initial
begin
aclk_0 = 0;

s_axis_config_tdata_0 = 8'd0;
s_axis_config_tvalid_0 = 1'b0;
s_axis_reload_tvalid_0 <= 1'b0;

s_axis_data_tvalid_0 = 1'b0;
s_axis_data_tdata_0 = 16'd0;


#1000;
@(posedge aclk_0);

i <= 1;
k<=1;
#10000;

@(posedge aclk_0);
#400_000;

$fclose(w1_file);
#1000;
$stop;

end

//update fir coefficients
always @(posedge aclk_0) begin
          if(k == 0)
                k <= 0;
          else if(k <= n) begin
               if(s_axis_reload_tready_0 && s_axis_reload_tvalid_0)
                     k <= k+1;
              else ;
              end
          else if(k < n+26)
                k <= k+1;
          else ;
end

always @(*) begin
          if((k>0) && (k<=n))
                s_axis_reload_tdata_0 <= coeffData[k-1];
          else
                s_axis_reload_tdata_0 <= 16'd0;
end

always @(posedge aclk_0) begin
          if((k>=1) && (k<n-1))
          begin
                s_axis_reload_tvalid_0 <= 1'b1;
                s_axis_reload_tlast_0 <= 1'b0;
          end
          else if(k == n-1)
                s_axis_reload_tlast_0 <= 1'b1;
          else if(k == n)
          begin
                s_axis_reload_tvalid_0 <= 1'b0;
                s_axis_reload_tlast_0 <= 1'b0;
          end
          else if(k == n+3)
          begin
                s_axis_config_tvalid_0 = 1'b1;
                s_axis_config_tdata_0 = 8'h00;
               @(posedge aclk_0);
               s_axis_config_tvalid_0 = 1'b0;
         end
end
/////////////////////////////////////////////////////////////////////////////

always @(*) begin
               if((i>0) && (i<DATA_NUM+1))
                     s_axis_data_tdata_0 <= data_mem[i-1];
               else
                     s_axis_data_tdata_0 <= 16'd0;

end

always @(posedge aclk_0) begin
               if(i == 0)
                     i <= 0;
               else if(i <= DATA_NUM) begin
                     if(s_axis_data_tready_0 && s_axis_data_tvalid_0)
                     i <= i+1;
               else ;
               end
               else if(i < DATA_NUM+26)
                     i <= i+1;
               else ;
end

always @(posedge aclk_0) begin
          if((i>=1) && (i<=DATA_NUM-1))
                s_axis_data_tvalid_0 <= 1'b1;
          else
                s_axis_data_tvalid_0 <= 1'b0;
end

always #5 aclk_0 = ~aclk_0; //100M

integer w1_file;

initial w1_file = $fopen("./fir_result.txt","w");

always @(posedge aclk_0) begin
               if(m_axis_data_tvalid_0)
               begin
                     $fwrite(w1_file, "%x\n", m_axis_data_tdata_0);
               end
end

endmodule

5. In my simulation result,the timing is not same with the pg149,especially the s_axis_reload_tready_0 .

3.png

 

12.png

 

6. I may understand something wrong so that I didn't get what I want.But I couldn't figure out where i made a mistake ?!

    I hope someone can help!

    Thanks!

 

 

0 Kudos
1 Solution

Accepted Solutions
vkanchan
Xilinx Employee
Xilinx Employee
383 Views
Registered: ‎09-18-2018

Hi @hexuyangguang ,

Please check if the sequence of reload coefficient matches with the reload index sequence shown in the FIR GUI's "coefficient reload" tab.

View solution in original post

fir_coeff_reload.jpg
0 Kudos
3 Replies
hexuyangguang
Observer
Observer
425 Views
Registered: ‎04-29-2021

hexuyangguang_0-1621308802855.png

1.Whether I should pay attention to the reload_order ? but I can find the file reload_order.txt?!

2.what is the normal steps about the coefficients reload ?

0 Kudos
vkanchan
Xilinx Employee
Xilinx Employee
384 Views
Registered: ‎09-18-2018

Hi @hexuyangguang ,

Please check if the sequence of reload coefficient matches with the reload index sequence shown in the FIR GUI's "coefficient reload" tab.

View solution in original post

fir_coeff_reload.jpg
0 Kudos
hexuyangguang
Observer
Observer
360 Views
Registered: ‎04-29-2021

oh,you are right,I didn't re-arrange the coefficients before I sent them to the core and that is the problem.

Thanks so much!

0 Kudos