data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/axi_ram_fifo_bist.v
 line:88: before: "if"
1: b"%Error: data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/axi_ram_fifo_bist.v:89: syntax error, unexpected '(', expecting IDENTIFIER\n    DATA_W_must_be_a_multiple_of_WORD_W();\n                                        ^\n%Error: data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/axi_ram_fifo_bist.v:94: syntax error, unexpected '(', expecting IDENTIFIER\n    WORD_W_not_supported();\n                         ^\n%Error: Exiting due to 2 error(s)\n"
module axi_ram_fifo_bist #(
  parameter DATA_W   = 64,
  parameter COUNT_W  = 48,
  parameter CLK_RATE = 200e6,
  parameter RAND     = 1
) (
  input clk,
  input rst,





  input  wire        s_ctrlport_req_wr,
  input  wire        s_ctrlport_req_rd,
  input  wire [19:0] s_ctrlport_req_addr,
  input  wire [31:0] s_ctrlport_req_data,
  output wire        s_ctrlport_resp_ack,
  output wire [31:0] s_ctrlport_resp_data,






  output wire [DATA_W-1:0] m_tdata,
  output reg               m_tvalid,
  input  wire              m_tready,


  input  wire [DATA_W-1:0] s_tdata,
  input  wire              s_tvalid,
  output wire              s_tready,





  output reg running

);







  localparam WORD_W = 32;


  localparam [WORD_W-1:0] SEED = 'h012345678;


  localparam [WORD_W-1:0] INIT = RAND ? SEED : 0;






  if (DATA_W % WORD_W != 0) begin
    DATA_W_must_be_a_multiple_of_WORD_W();
  end


  if (WORD_W != 32 && WORD_W != 16 && WORD_W != 8) begin
    WORD_W_not_supported();
  end






  function [WORD_W-1:0] lfsr(input [WORD_W-1:0] din);
    reg new_bit;
    begin
      case (WORD_W)
        8  : new_bit = din[7]  ^ din[5]  ^ din[4]  ^ din[3];
        16 : new_bit = din[15] ^ din[14] ^ din[12] ^ din[3];
        32 : new_bit = din[31] ^ din[21] ^ din[1]  ^ din[0];
      endcase
      lfsr = { din[WORD_W-2:0], new_bit };
    end
  endfunction

  function [WORD_W-1:0] next(input [WORD_W-1:0] din);
    next = RAND ? lfsr(din) : din + 1;
  endfunction






  reg [COUNT_W-1:0] tx_count;
  reg [COUNT_W-1:0] rx_count;
  reg [COUNT_W-1:0] error_count;

  reg [WORD_W-1:0]  tx_data = next(INIT);
  reg [DATA_W-1:0]  rx_data = INIT;
  reg [WORD_W-1:0]  exp_data;
  reg               rx_valid;

  wire [COUNT_W-1:0] num_words;
  reg  [COUNT_W-1:0] cycle_count;
  wire               start;
  wire               stop;
  wire               clear;
  wire               continuous;






  axi_ram_fifo_bist_regs #(
    .DATA_W   (DATA_W),
    .COUNT_W  (COUNT_W),
    .CLK_RATE (CLK_RATE)
  ) axi_ram_fifo_bist_regs_i (
    .clk                  (clk),
    .rst                  (rst),
    .s_ctrlport_req_wr    (s_ctrlport_req_wr),
    .s_ctrlport_req_rd    (s_ctrlport_req_rd),
    .s_ctrlport_req_addr  (s_ctrlport_req_addr),
    .s_ctrlport_req_data  (s_ctrlport_req_data),
    .s_ctrlport_resp_ack  (s_ctrlport_resp_ack),
    .s_ctrlport_resp_data (s_ctrlport_resp_data),
    .tx_count             (tx_count),
    .rx_count             (rx_count),
    .error_count          (error_count),
    .cycle_count          (cycle_count),
    .num_words            (num_words),
    .start                (start),
    .stop                 (stop),
    .clear                (clear),
    .continuous           (continuous),
    .running              (running)
  );






  localparam ST_IDLE      = 0;
  localparam ST_ACTIVE    = 1;
  localparam ST_WAIT_DONE = 2;

  reg [        1:0] state;
  reg [COUNT_W-1:0] num_words_m1;

  always @(posedge clk) begin
    if (rst) begin
      state    <= ST_IDLE;
      m_tvalid <= 0;
      running  <= 0;
    end else begin
      m_tvalid <= 0;

      case (state)
        ST_IDLE : begin
          num_words_m1 <= num_words-1;
          if (start) begin
            running <= 1;
            state   <= ST_ACTIVE;
          end
        end

        ST_ACTIVE : begin
          if (stop || (tx_count == num_words_m1 && m_tvalid && m_tready && !continuous)) begin
            m_tvalid <= 0;
            state    <= ST_WAIT_DONE;
          end else begin
            m_tvalid <= 1;
            running  <= 1;
          end
        end

        ST_WAIT_DONE : begin
          if (rx_count >= tx_count) begin
            running <= 0;
            state   <= ST_IDLE;
          end
        end
      endcase
    end
  end






  reg count_en;


  assign m_tdata = {(DATA_W/WORD_W){ tx_data }};


  assign s_tready = 1;

  always @(posedge clk) begin
    if (rst) begin
      tx_data     <= next(INIT);
      exp_data    <= INIT;
      rx_valid    <= 0;
      tx_count    <= 0;
      rx_count    <= 0;
      error_count <= 0;
      cycle_count <= 0;
      count_en    <= 0;
    end else begin



      if (m_tvalid && m_tready) begin
        tx_data  <= next(tx_data);
        tx_count <= tx_count + 1;
      end




      if (s_tvalid & s_tready) begin
        rx_valid <= 1;
        exp_data <= next(exp_data);
        rx_count <= rx_count + 1;
        rx_data  <= s_tdata;
      end else begin
        rx_valid <= 0;
      end




      if (rx_valid) begin
        if (rx_data !== {(DATA_W/WORD_W){exp_data}}) begin
          error_count <= error_count + 1;
        end
      end






      if (state == ST_IDLE) count_en <= 0;
      else if (s_tvalid) count_en <= 1;

      if (count_en) cycle_count <= cycle_count + 1; 




      if (clear) begin
        tx_count    <= 0;
        rx_count    <= 0;
        error_count <= 0;
        cycle_count <= 0;
      end
    end
  end

endmodule
module axi_ram_fifo_bist #(
  parameter DATA_W   = 64,
  parameter COUNT_W  = 48,
  parameter CLK_RATE = 200e6,
  parameter RAND     = 1
) (
  input clk,
  input rst,





  input  wire        s_ctrlport_req_wr,
  input  wire        s_ctrlport_req_rd,
  input  wire [19:0] s_ctrlport_req_addr,
  input  wire [31:0] s_ctrlport_req_data,
  output wire        s_ctrlport_resp_ack,
  output wire [31:0] s_ctrlport_resp_data,






  output wire [DATA_W-1:0] m_tdata,
  output reg               m_tvalid,
  input  wire              m_tready,


  input  wire [DATA_W-1:0] s_tdata,
  input  wire              s_tvalid,
  output wire              s_tready,





  output reg running

);








  localparam WORD_W = 32;


  localparam [WORD_W-1:0] SEED = 'h012345678;


  localparam [WORD_W-1:0] INIT = RAND ? SEED : 0;






  if (DATA_W % WORD_W != 0) begin
    DATA_W_must_be_a_multiple_of_WORD_W();
  end


  if (WORD_W != 32 && WORD_W != 16 && WORD_W != 8) begin
    WORD_W_not_supported();
  end






  function [WORD_W-1:0] lfsr(input [WORD_W-1:0] din);
    reg new_bit;
    begin
      case (WORD_W)
        8  : new_bit = din[7]  ^ din[5]  ^ din[4]  ^ din[3];
        16 : new_bit = din[15] ^ din[14] ^ din[12] ^ din[3];
        32 : new_bit = din[31] ^ din[21] ^ din[1]  ^ din[0];
      endcase
      lfsr = { din[WORD_W-2:0], new_bit };
    end
  endfunction

  function [WORD_W-1:0] next(input [WORD_W-1:0] din);
    next = RAND ? lfsr(din) : din + 1;
  endfunction






  reg [COUNT_W-1:0] tx_count;
  reg [COUNT_W-1:0] rx_count;
  reg [COUNT_W-1:0] error_count;

  reg [WORD_W-1:0]  tx_data = next(INIT);
  reg [DATA_W-1:0]  rx_data = INIT;
  reg [WORD_W-1:0]  exp_data;
  reg               rx_valid;

  wire [COUNT_W-1:0] num_words;
  reg  [COUNT_W-1:0] cycle_count;
  wire               start;
  wire               stop;
  wire               clear;
  wire               continuous;






  axi_ram_fifo_bist_regs #(
    .DATA_W   (DATA_W),
    .COUNT_W  (COUNT_W),
    .CLK_RATE (CLK_RATE)
  ) axi_ram_fifo_bist_regs_i (
    .clk                  (clk),
    .rst                  (rst),
    .s_ctrlport_req_wr    (s_ctrlport_req_wr),
    .s_ctrlport_req_rd    (s_ctrlport_req_rd),
    .s_ctrlport_req_addr  (s_ctrlport_req_addr),
    .s_ctrlport_req_data  (s_ctrlport_req_data),
    .s_ctrlport_resp_ack  (s_ctrlport_resp_ack),
    .s_ctrlport_resp_data (s_ctrlport_resp_data),
    .tx_count             (tx_count),
    .rx_count             (rx_count),
    .error_count          (error_count),
    .cycle_count          (cycle_count),
    .num_words            (num_words),
    .start                (start),
    .stop                 (stop),
    .clear                (clear),
    .continuous           (continuous),
    .running              (running)
  );






  localparam ST_IDLE      = 0;
  localparam ST_ACTIVE    = 1;
  localparam ST_WAIT_DONE = 2;

  reg [        1:0] state;
  reg [COUNT_W-1:0] num_words_m1;

  always @(posedge clk) begin
    if (rst) begin
      state    <= ST_IDLE;
      m_tvalid <= 0;
      running  <= 0;
    end else begin
      m_tvalid <= 0;

      case (state)
        ST_IDLE : begin
          num_words_m1 <= num_words-1;
          if (start) begin
            running <= 1;
            state   <= ST_ACTIVE;
          end
        end

        ST_ACTIVE : begin
          if (stop || (tx_count == num_words_m1 && m_tvalid && m_tready && !continuous)) begin
            m_tvalid <= 0;
            state    <= ST_WAIT_DONE;
          end else begin
            m_tvalid <= 1;
            running  <= 1;
          end
        end

        ST_WAIT_DONE : begin
          if (rx_count >= tx_count) begin
            running <= 0;
            state   <= ST_IDLE;
          end
        end
      endcase
    end
  end






  reg count_en;


  assign m_tdata = {(DATA_W/WORD_W){ tx_data }};


  assign s_tready = 1;

  always @(posedge clk) begin
    if (rst) begin
      tx_data     <= next(INIT);
      exp_data    <= INIT;
      rx_valid    <= 0;
      tx_count    <= 0;
      rx_count    <= 0;
      error_count <= 0;
      cycle_count <= 0;
      count_en    <= 0;
    end else begin



      if (m_tvalid && m_tready) begin
        tx_data  <= next(tx_data);
        tx_count <= tx_count + 1;
      end




      if (s_tvalid & s_tready) begin
        rx_valid <= 1;
        exp_data <= next(exp_data);
        rx_count <= rx_count + 1;
        rx_data  <= s_tdata;
      end else begin
        rx_valid <= 0;
      end




      if (rx_valid) begin
        if (rx_data !== {(DATA_W/WORD_W){exp_data}}) begin
          error_count <= error_count + 1;
        end
      end






      if (state == ST_IDLE) count_en <= 0;
      else if (s_tvalid) count_en <= 1;

      if (count_en) cycle_count <= cycle_count + 1; 




      if (clear) begin
        tx_count    <= 0;
        rx_count    <= 0;
        error_count <= 0;
        cycle_count <= 0;
      end
    end
  end

endmodule