data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v
1: b'%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:144: Operator ADD expects 4 bits on the RHS, but RHS\'s SEL generates 1 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n        s_axis_tdata_len = s_axis_tdata_len + s_axis_tkeep[idx];\n                                            ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:245: Operator LT expects 16 bits on the LHS, but LHS\'s VARREF \'len_capture\' generates 11 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n            if (len_capture < max_len_capture_i) begin\n                            ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:264: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s VARREF \'max_len_capture_i\' generates 16 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n                nxt_meta_len_capture = max_len_capture_i;\n                                     ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:266: Operator ADD expects 11 bits on the RHS, but RHS\'s VARREF \'s_axis_tdata_len\' generates 4 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n                nxt_meta_len_capture = len_capture + s_axis_tdata_len;\n                                                   ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:263: Operator ADD expects 16 bits on the LHS, but LHS\'s VARREF \'len_capture\' generates 11 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin\n                               ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:263: Operator ADD expects 16 bits on the RHS, but RHS\'s VARREF \'s_axis_tdata_len\' generates 4 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin\n                               ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:268: Operator ADD expects 11 bits on the RHS, but RHS\'s VARREF \'s_axis_tdata_len\' generates 4 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n              nxt_meta_len_wire = len_wire + s_axis_tdata_len;\n                                           ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:279: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s VARREF \'max_len_capture_i\' generates 16 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n                nxt_len_capture = max_len_capture_i;\n                                ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:281: Operator ADD expects 11 bits on the RHS, but RHS\'s VARREF \'s_axis_tdata_len\' generates 4 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n                nxt_len_capture = len_capture + s_axis_tdata_len;\n                                              ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:278: Operator ADD expects 16 bits on the LHS, but LHS\'s VARREF \'len_capture\' generates 11 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin\n                               ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:278: Operator ADD expects 16 bits on the RHS, but RHS\'s VARREF \'s_axis_tdata_len\' generates 4 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin\n                               ^\n%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_capture/hdl/nt_recv_capture_rx.v:283: Operator ADD expects 11 bits on the RHS, but RHS\'s VARREF \'s_axis_tdata_len\' generates 4 bits.\n                                                                                                             : ... In instance nt_recv_capture_rx\n              nxt_len_wire = len_wire + s_axis_tdata_len;\n                                      ^\n%Error: Exiting due to 12 warning(s)\n'
module nt_recv_capture_rx
(

  input wire          clk,
  input wire          rstn,
  input wire          rst_sw,


  input wire [63:0]   s_axis_tdata,
  input wire          s_axis_tvalid,
  input wire          s_axis_tlast,
  input wire [7:0]    s_axis_tkeep,
  input wire [52:0]   s_axis_tuser,
  output reg          s_axis_tready,


  input wire          active_i,
  input wire [15:0]   max_len_capture_i,


  output reg [74:0]   fifo_meta_din_o,
  output reg          fifo_meta_wr_en_o,
  input wire          fifo_meta_full_i,


  output reg [63:0]   fifo_data_din_o,
  output reg          fifo_data_wr_en_o,
  input wire          fifo_data_full_i,


  output reg          active_o,


  output reg [31:0]   pkt_cnt_o,


  output reg          err_meta_fifo_full_o,
  output reg          err_data_fifo_full_o
);


  always @(posedge clk) s_axis_tready <= 1'b1;



  reg s_axis_active;



  always @(posedge clk) begin
    if (~rstn | rst_sw) begin

      s_axis_active <= 1'b0;
    end else begin
      if (s_axis_tvalid & s_axis_tready) begin

        s_axis_active <= ~s_axis_tlast;
      end else begin

        s_axis_active <= s_axis_active;
      end
    end
  end


  reg [3:0] s_axis_tdata_len;

  integer idx;
  always @(*) begin
    if (~s_axis_tlast) begin

      s_axis_tdata_len = 8;
    end else begin


      s_axis_tdata_len = 4'b0;
      for (idx = 0; idx < 8; idx = idx + 1) begin
        s_axis_tdata_len = s_axis_tdata_len + s_axis_tkeep[idx];
      end
    end
  end


  parameter FSM_DATA_RST    = 3'b000,
            FSM_DATA_IDLE   = 3'b001,
            FSM_DATA_START  = 3'b010,
            FSM_DATA_RECORD = 3'b011,
            FSM_DATA_ERR    = 3'b100;

  reg [2:0]   state_fsm_data, nxt_state_fsm_data;
  reg         meta_wr, nxt_meta_wr;
  reg [23:0]  meta_latency, nxt_meta_latency;
  reg         meta_latency_valid, nxt_meta_latency_valid;
  reg [27:0]  meta_interpackettime, nxt_meta_interpackettime;
  reg [10:0]  meta_len_capture, nxt_meta_len_capture;
  reg [10:0]  meta_len_wire, nxt_meta_len_wire;
  reg [10:0]  len_capture, nxt_len_capture;
  reg [10:0]  len_wire, nxt_len_wire;
  reg         nxt_fifo_data_wr_en;
  reg [31:0]  nxt_pkt_cnt;


  always @(posedge clk) begin
    if (~rstn | rst_sw) begin
      state_fsm_data <= FSM_DATA_RST;
    end else begin
      state_fsm_data <= nxt_state_fsm_data;
    end

    meta_wr <= nxt_meta_wr;
    meta_latency <= nxt_meta_latency;
    meta_latency_valid <= nxt_meta_latency_valid;
    meta_interpackettime <= nxt_meta_interpackettime;
    meta_len_capture <= nxt_meta_len_capture;
    meta_len_wire <= nxt_meta_len_wire;
    len_capture <= nxt_len_capture;
    len_wire <= nxt_len_wire;
    fifo_data_wr_en_o <= nxt_fifo_data_wr_en;
    fifo_data_din_o <= s_axis_tdata;
    pkt_cnt_o <= nxt_pkt_cnt;
  end


  always @(*) begin
    nxt_state_fsm_data = state_fsm_data;
    nxt_meta_wr = 1'b0;
    nxt_meta_latency = meta_latency;
    nxt_meta_latency_valid = meta_latency_valid;
    nxt_meta_interpackettime = meta_interpackettime;
    nxt_meta_len_capture = meta_len_capture;
    nxt_meta_len_wire = meta_len_wire;
    nxt_len_capture = len_capture;
    nxt_len_wire = len_wire;
    nxt_fifo_data_wr_en = 1'b0;
    nxt_pkt_cnt = pkt_cnt_o;

    case (state_fsm_data)

      FSM_DATA_RST: begin

        nxt_pkt_cnt = 32'b0;


        nxt_state_fsm_data = FSM_DATA_IDLE;
      end

      FSM_DATA_IDLE: begin
        if (active_i) begin

          nxt_state_fsm_data = FSM_DATA_START;
        end
      end

      FSM_DATA_START: begin

        nxt_len_capture = 11'b0;
        nxt_len_wire = 11'b0;


        nxt_pkt_cnt = 32'b0;




        if (~s_axis_active) begin
          nxt_state_fsm_data = FSM_DATA_RECORD;
        end
      end

      FSM_DATA_RECORD: begin
        if (~active_i & ~s_axis_active) begin


          nxt_state_fsm_data = FSM_DATA_IDLE;
        end else begin
          if (s_axis_tvalid & s_axis_tready) begin


            if (len_capture < max_len_capture_i) begin

              nxt_fifo_data_wr_en = 1'b1;

              if (fifo_data_full_i) begin

                nxt_state_fsm_data = FSM_DATA_ERR;
              end
            end

            if (s_axis_tlast) begin

              nxt_meta_wr = 1'b1;


              nxt_meta_latency = s_axis_tuser[23:0];
              nxt_meta_latency_valid = s_axis_tuser[24:24];
              nxt_meta_interpackettime = s_axis_tuser[52:25];
              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin
                nxt_meta_len_capture = max_len_capture_i;
              end else begin
                nxt_meta_len_capture = len_capture + s_axis_tdata_len;
              end
              nxt_meta_len_wire = len_wire + s_axis_tdata_len;


              nxt_pkt_cnt = pkt_cnt_o + 1;


              nxt_len_capture = 11'b0;
              nxt_len_wire = 11'b0;
            end else begin

              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin
                nxt_len_capture = max_len_capture_i;
              end else begin
                nxt_len_capture = len_capture + s_axis_tdata_len;
              end
              nxt_len_wire = len_wire + s_axis_tdata_len;
            end
          end
        end
      end

      FSM_DATA_ERR: begin

      end

    endcase
  end


  parameter FSM_META_ACTIVE = 1'b0,
            FSM_META_ERR    = 1'b1;

  reg         state_fsm_meta, nxt_state_fsm_meta;
  reg         nxt_fifo_meta_wr_en;
  reg [74:0]  nxt_fifo_meta_din;


  always @(posedge clk) begin
    if (~rstn | rst_sw) begin
      state_fsm_meta <= FSM_META_ACTIVE;
    end else begin
      state_fsm_meta <= nxt_state_fsm_meta;
    end

    fifo_meta_wr_en_o <= nxt_fifo_meta_wr_en;
    fifo_meta_din_o <= nxt_fifo_meta_din;
  end


  always @(*) begin
    nxt_state_fsm_meta = state_fsm_meta;
    nxt_fifo_meta_wr_en = 1'b0;
    nxt_fifo_meta_din = fifo_meta_din_o;

    case (state_fsm_meta)

      FSM_META_ACTIVE: begin
        if (meta_wr) begin

          nxt_fifo_meta_wr_en = 1'b1;
          nxt_fifo_meta_din[23:0] = meta_latency;
          nxt_fifo_meta_din[24:24] = meta_latency_valid;
          nxt_fifo_meta_din[52:25] = meta_interpackettime;
          nxt_fifo_meta_din[63:53] = meta_len_wire;
          nxt_fifo_meta_din[74:64] = meta_len_capture;

          if (fifo_meta_full_i) begin

            nxt_state_fsm_meta = FSM_META_ERR;
          end
        end
      end

      FSM_META_ERR: begin

      end

    endcase
  end


  always @(posedge clk) begin
    if (~rstn | rst_sw) begin
      active_o <= 1'b0;
      err_meta_fifo_full_o <= 1'b0;
      err_data_fifo_full_o <= 1'b0;
    end else begin
      active_o <= (state_fsm_data == FSM_DATA_RECORD);
      err_data_fifo_full_o <= (state_fsm_data == FSM_DATA_ERR);
      err_meta_fifo_full_o <= (state_fsm_meta == FSM_META_ERR);
    end
  end

endmodule
module nt_recv_capture_rx
(

  input wire          clk,
  input wire          rstn,
  input wire          rst_sw,


  input wire [63:0]   s_axis_tdata,
  input wire          s_axis_tvalid,
  input wire          s_axis_tlast,
  input wire [7:0]    s_axis_tkeep,
  input wire [52:0]   s_axis_tuser,
  output reg          s_axis_tready,


  input wire          active_i,
  input wire [15:0]   max_len_capture_i,


  output reg [74:0]   fifo_meta_din_o,
  output reg          fifo_meta_wr_en_o,
  input wire          fifo_meta_full_i,


  output reg [63:0]   fifo_data_din_o,
  output reg          fifo_data_wr_en_o,
  input wire          fifo_data_full_i,


  output reg          active_o,


  output reg [31:0]   pkt_cnt_o,


  output reg          err_meta_fifo_full_o,
  output reg          err_data_fifo_full_o
);



  always @(posedge clk) s_axis_tready <= 1'b1;



  reg s_axis_active;



  always @(posedge clk) begin
    if (~rstn | rst_sw) begin

      s_axis_active <= 1'b0;
    end else begin
      if (s_axis_tvalid & s_axis_tready) begin

        s_axis_active <= ~s_axis_tlast;
      end else begin

        s_axis_active <= s_axis_active;
      end
    end
  end


  reg [3:0] s_axis_tdata_len;

  integer idx;
  always @(*) begin
    if (~s_axis_tlast) begin

      s_axis_tdata_len = 8;
    end else begin


      s_axis_tdata_len = 4'b0;
      for (idx = 0; idx < 8; idx = idx + 1) begin
        s_axis_tdata_len = s_axis_tdata_len + s_axis_tkeep[idx];
      end
    end
  end


  parameter FSM_DATA_RST    = 3'b000,
            FSM_DATA_IDLE   = 3'b001,
            FSM_DATA_START  = 3'b010,
            FSM_DATA_RECORD = 3'b011,
            FSM_DATA_ERR    = 3'b100;

  reg [2:0]   state_fsm_data, nxt_state_fsm_data;
  reg         meta_wr, nxt_meta_wr;
  reg [23:0]  meta_latency, nxt_meta_latency;
  reg         meta_latency_valid, nxt_meta_latency_valid;
  reg [27:0]  meta_interpackettime, nxt_meta_interpackettime;
  reg [10:0]  meta_len_capture, nxt_meta_len_capture;
  reg [10:0]  meta_len_wire, nxt_meta_len_wire;
  reg [10:0]  len_capture, nxt_len_capture;
  reg [10:0]  len_wire, nxt_len_wire;
  reg         nxt_fifo_data_wr_en;
  reg [31:0]  nxt_pkt_cnt;


  always @(posedge clk) begin
    if (~rstn | rst_sw) begin
      state_fsm_data <= FSM_DATA_RST;
    end else begin
      state_fsm_data <= nxt_state_fsm_data;
    end

    meta_wr <= nxt_meta_wr;
    meta_latency <= nxt_meta_latency;
    meta_latency_valid <= nxt_meta_latency_valid;
    meta_interpackettime <= nxt_meta_interpackettime;
    meta_len_capture <= nxt_meta_len_capture;
    meta_len_wire <= nxt_meta_len_wire;
    len_capture <= nxt_len_capture;
    len_wire <= nxt_len_wire;
    fifo_data_wr_en_o <= nxt_fifo_data_wr_en;
    fifo_data_din_o <= s_axis_tdata;
    pkt_cnt_o <= nxt_pkt_cnt;
  end


  always @(*) begin
    nxt_state_fsm_data = state_fsm_data;
    nxt_meta_wr = 1'b0;
    nxt_meta_latency = meta_latency;
    nxt_meta_latency_valid = meta_latency_valid;
    nxt_meta_interpackettime = meta_interpackettime;
    nxt_meta_len_capture = meta_len_capture;
    nxt_meta_len_wire = meta_len_wire;
    nxt_len_capture = len_capture;
    nxt_len_wire = len_wire;
    nxt_fifo_data_wr_en = 1'b0;
    nxt_pkt_cnt = pkt_cnt_o;

    case (state_fsm_data)

      FSM_DATA_RST: begin

        nxt_pkt_cnt = 32'b0;


        nxt_state_fsm_data = FSM_DATA_IDLE;
      end

      FSM_DATA_IDLE: begin
        if (active_i) begin

          nxt_state_fsm_data = FSM_DATA_START;
        end
      end

      FSM_DATA_START: begin

        nxt_len_capture = 11'b0;
        nxt_len_wire = 11'b0;


        nxt_pkt_cnt = 32'b0;




        if (~s_axis_active) begin
          nxt_state_fsm_data = FSM_DATA_RECORD;
        end
      end

      FSM_DATA_RECORD: begin
        if (~active_i & ~s_axis_active) begin


          nxt_state_fsm_data = FSM_DATA_IDLE;
        end else begin
          if (s_axis_tvalid & s_axis_tready) begin


            if (len_capture < max_len_capture_i) begin

              nxt_fifo_data_wr_en = 1'b1;

              if (fifo_data_full_i) begin

                nxt_state_fsm_data = FSM_DATA_ERR;
              end
            end

            if (s_axis_tlast) begin

              nxt_meta_wr = 1'b1;


              nxt_meta_latency = s_axis_tuser[23:0];
              nxt_meta_latency_valid = s_axis_tuser[24:24];
              nxt_meta_interpackettime = s_axis_tuser[52:25];
              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin
                nxt_meta_len_capture = max_len_capture_i;
              end else begin
                nxt_meta_len_capture = len_capture + s_axis_tdata_len;
              end
              nxt_meta_len_wire = len_wire + s_axis_tdata_len;


              nxt_pkt_cnt = pkt_cnt_o + 1;


              nxt_len_capture = 11'b0;
              nxt_len_wire = 11'b0;
            end else begin

              if ((len_capture + s_axis_tdata_len) > max_len_capture_i) begin
                nxt_len_capture = max_len_capture_i;
              end else begin
                nxt_len_capture = len_capture + s_axis_tdata_len;
              end
              nxt_len_wire = len_wire + s_axis_tdata_len;
            end
          end
        end
      end

      FSM_DATA_ERR: begin

      end

    endcase
  end


  parameter FSM_META_ACTIVE = 1'b0,
            FSM_META_ERR    = 1'b1;

  reg         state_fsm_meta, nxt_state_fsm_meta;
  reg         nxt_fifo_meta_wr_en;
  reg [74:0]  nxt_fifo_meta_din;


  always @(posedge clk) begin
    if (~rstn | rst_sw) begin
      state_fsm_meta <= FSM_META_ACTIVE;
    end else begin
      state_fsm_meta <= nxt_state_fsm_meta;
    end

    fifo_meta_wr_en_o <= nxt_fifo_meta_wr_en;
    fifo_meta_din_o <= nxt_fifo_meta_din;
  end


  always @(*) begin
    nxt_state_fsm_meta = state_fsm_meta;
    nxt_fifo_meta_wr_en = 1'b0;
    nxt_fifo_meta_din = fifo_meta_din_o;

    case (state_fsm_meta)

      FSM_META_ACTIVE: begin
        if (meta_wr) begin

          nxt_fifo_meta_wr_en = 1'b1;
          nxt_fifo_meta_din[23:0] = meta_latency;
          nxt_fifo_meta_din[24:24] = meta_latency_valid;
          nxt_fifo_meta_din[52:25] = meta_interpackettime;
          nxt_fifo_meta_din[63:53] = meta_len_wire;
          nxt_fifo_meta_din[74:64] = meta_len_capture;

          if (fifo_meta_full_i) begin

            nxt_state_fsm_meta = FSM_META_ERR;
          end
        end
      end

      FSM_META_ERR: begin

      end

    endcase
  end


  always @(posedge clk) begin
    if (~rstn | rst_sw) begin
      active_o <= 1'b0;
      err_meta_fifo_full_o <= 1'b0;
      err_data_fifo_full_o <= 1'b0;
    end else begin
      active_o <= (state_fsm_data == FSM_DATA_RECORD);
      err_data_fifo_full_o <= (state_fsm_data == FSM_DATA_ERR);
      err_meta_fifo_full_o <= (state_fsm_meta == FSM_META_ERR);
    end
  end

endmodule