data/full_repos/permissive/136197078/hardware/ip/nt_recv_latency/hdl/nt_recv_latency.v
1: b'%Warning-WIDTH: data/full_repos/permissive/136197078/hardware/ip/nt_recv_latency/hdl/nt_recv_latency.v:111: Operator ASSIGNW expects 8 bits on the Assign RHS, but Assign RHS\'s SHIFTR generates 11 bits.\n                                                                                                          : ... In instance nt_recv_latency\n  assign axis_word_select = pos_i >> 3;  \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_latency/hdl/nt_recv_latency.v:116: Operator ASSIGNW expects 3 bits on the Assign RHS, but Assign RHS\'s SUB generates 11 bits.\n                                                                                                          : ... In instance nt_recv_latency\n  assign axis_word_pos = pos_i - (pos_i & 11\'h7F8);  \n                       ^\n%Error: Exiting due to 2 warning(s)\n'
module nt_recv_latency (

  input wire clk156,
  input wire rstn156,
  input wire rst_sw156,


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


  output reg [63:0]    m_axis_tdata,
  output reg [7:0]     m_axis_tkeep,
  output reg           m_axis_tvalid,
  output reg           m_axis_tlast,
  input wire           m_axis_tready,
  output reg [24:0]    m_axis_tuser,


  input wire [1:0]  mode_i,
  input wire [10:0] pos_i,
  input wire        width_i,


  input wire [23:0] timestamp_i
);

  localparam [1:0] MODE_DISABLED  = 2'b00,
                   MODE_FIXED_POS = 2'b01,
                   MODE_HEADER    = 2'b10;


  reg [15:0] ethertype;



  reg [7:0] axis_word_cntr;


  assign s_axis_tready = m_axis_tready;



  wire [7:0] axis_word_select;
  assign axis_word_select = pos_i >> 3;



  wire [2:0] axis_word_pos;
  assign axis_word_pos = pos_i - (pos_i & 11'h7F8);

  reg [15:0] timestamp_fixed_pos16;
  always @(*) begin
    case (axis_word_pos)
      3'h0: timestamp_fixed_pos16 = s_axis_tdata[0+:16];
      3'h1: timestamp_fixed_pos16 = s_axis_tdata[8+:16];
      3'h2: timestamp_fixed_pos16 = s_axis_tdata[16+:16];
      3'h3: timestamp_fixed_pos16 = s_axis_tdata[24+:16];
      3'h4: timestamp_fixed_pos16 = s_axis_tdata[32+:16];
      3'h5: timestamp_fixed_pos16 = s_axis_tdata[40+:16];
      3'h6: timestamp_fixed_pos16 = s_axis_tdata[48+:16];
      default: timestamp_fixed_pos16 = 16'b0;
    endcase
  end

  reg [23:0] timestamp_fixed_pos24;
  always @(*) begin
    case (axis_word_pos)
      3'h0: timestamp_fixed_pos24 = s_axis_tdata[0+:24];
      3'h1: timestamp_fixed_pos24 = s_axis_tdata[8+:24];
      3'h2: timestamp_fixed_pos24 = s_axis_tdata[16+:24];
      3'h3: timestamp_fixed_pos24 = s_axis_tdata[24+:24];
      3'h4: timestamp_fixed_pos24 = s_axis_tdata[32+:24];
      3'h5: timestamp_fixed_pos24 = s_axis_tdata[40+:24];
      default: timestamp_fixed_pos24 = 24'b0;
    endcase
  end



  reg timestamp_fixed_pos_valid;
  always @(*) begin

    if (~width_i) begin

      timestamp_fixed_pos_valid = s_axis_tkeep[axis_word_pos+1];
    end else begin

      timestamp_fixed_pos_valid = s_axis_tkeep[axis_word_pos+2];
    end
  end


  wire [15:0] latency_header;
  assign latency_header = (timestamp_i[15:0] >= s_axis_tdata[15:0]) ?
                            (timestamp_i[15:0] - s_axis_tdata[15:0])
                          : (16'hFFFF - s_axis_tdata[15:0] + timestamp_i[15:0] +
                              16'b1);



  wire [15:0] latency_fixed16;
  assign latency_fixed16 = (timestamp_i[15:0] >= timestamp_fixed_pos16) ?
                              (timestamp_i[15:0] - timestamp_fixed_pos16)
                            : (16'hFFFF - timestamp_fixed_pos16 +
                              timestamp_i[15:0] + 16'b1);



  wire [23:0] latency_fixed24;
  assign latency_fixed24 = (timestamp_i >= timestamp_fixed_pos24) ?
                              (timestamp_i - timestamp_fixed_pos24)
                            : (24'hFFFFFF - timestamp_fixed_pos24 +
                              timestamp_i + 24'b1);

  reg [23:0] latency;
  reg        latency_valid;



  always @(posedge clk156) begin
    if (~rstn156 | rst_sw156) begin
      m_axis_tdata <= 64'b0;
      m_axis_tkeep <= 8'b0;
      m_axis_tvalid <= 1'b0;
      m_axis_tlast <= 1'b0;
      m_axis_tuser <= 25'b0;
      ethertype <= 16'b0;
      latency <= 24'b0;
      latency_valid <= 1'b0;
      axis_word_cntr <= 8'b0;
    end else begin
      if (m_axis_tready) begin

        if (mode_i == MODE_HEADER) begin




          if (axis_word_cntr == 1) begin

            ethertype <= s_axis_tdata[47:32];
            m_axis_tuser <= 25'b0;
            latency <= 24'b0;
            latency_valid <= 1'b0;
          end else if (axis_word_cntr == 2) begin

            if (ethertype == 16'hdd86) begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {1'b1, 8'b0, latency_header};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= {8'b0, latency_header};
                latency_valid <= 1'b1;
              end
            end else begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {latency_valid, latency};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= latency;
                latency_valid <= latency_valid;
              end
            end
          end else if (axis_word_cntr == 3) begin

            if (ethertype == 16'h0008) begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {1'b1, 8'b0, latency_header};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= {8'b0, latency_header};
                latency_valid <= 1'b1;
              end
            end else begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {latency_valid, latency};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= latency;
                latency_valid <= latency_valid;
              end
            end
          end else begin
            if (s_axis_tlast) begin
              m_axis_tuser <= {latency_valid, latency};
              latency <= 24'b0;
              latency_valid <= 1'b0;
            end else begin
              m_axis_tuser <= 25'b0;
              latency <= latency;
              latency_valid <= latency_valid;
            end
          end
        end else if (mode_i == MODE_FIXED_POS) begin


          if (axis_word_cntr == axis_word_select) begin



            if (timestamp_fixed_pos_valid) begin
              if (~width_i) begin

                if (s_axis_tlast) begin
                  m_axis_tuser <= {1'b1, 8'b0, latency_fixed16};
                  latency <= 24'b0;
                  latency_valid <= 1'b0;
                end else begin
                  m_axis_tuser <= 25'b0;
                  latency <= {8'b0, latency_fixed16};
                  latency_valid <= 1'b1;
                end
              end else begin

                if (s_axis_tlast) begin
                  m_axis_tuser <= {1'b1, latency_fixed24};
                  latency <= 24'b0;
                  latency_valid <= 1'b0;
                end else begin
                  m_axis_tuser <= 25'b0;
                  latency <= latency_fixed24;
                  latency_valid <= 1'b1;
                end
              end
            end else begin

              m_axis_tuser <= 25'b0;
              latency <= 24'b0;
              latency_valid <= 1'b0;
            end
          end else begin



            if (s_axis_tlast) begin
              m_axis_tuser <= {latency_valid, latency};
              latency <= 24'b0;
              latency_valid <= 1'b0;
            end else begin
              m_axis_tuser <= 25'b0;
              latency <= latency;
              latency_valid <= latency_valid;
            end
          end
        end else begin

          m_axis_tuser <= 25'b0;
          latency <= 24'b0;
          latency_valid <= 1'b0;
        end


        m_axis_tdata <= s_axis_tdata;
        m_axis_tkeep <= s_axis_tkeep;
        m_axis_tvalid <= s_axis_tvalid;
        m_axis_tlast <= s_axis_tlast;


        if (s_axis_tvalid) begin
          axis_word_cntr <= s_axis_tlast ? 8'b0 : (axis_word_cntr + 1);
        end else begin
          axis_word_cntr <= axis_word_cntr;
        end
      end else begin
        m_axis_tdata <= m_axis_tdata;
        m_axis_tkeep <= m_axis_tkeep;
        m_axis_tvalid <= m_axis_tvalid;
        m_axis_tlast <= m_axis_tlast;
        m_axis_tuser <= m_axis_tuser;

        ethertype <= ethertype;

        latency <= latency;
        latency_valid <= latency_valid;

        axis_word_cntr <= axis_word_cntr;
      end
    end
  end

endmodule
module nt_recv_latency (

  input wire clk156,
  input wire rstn156,
  input wire rst_sw156,


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


  output reg [63:0]    m_axis_tdata,
  output reg [7:0]     m_axis_tkeep,
  output reg           m_axis_tvalid,
  output reg           m_axis_tlast,
  input wire           m_axis_tready,
  output reg [24:0]    m_axis_tuser,


  input wire [1:0]  mode_i,
  input wire [10:0] pos_i,
  input wire        width_i,


  input wire [23:0] timestamp_i
);


  localparam [1:0] MODE_DISABLED  = 2'b00,
                   MODE_FIXED_POS = 2'b01,
                   MODE_HEADER    = 2'b10;


  reg [15:0] ethertype;



  reg [7:0] axis_word_cntr;


  assign s_axis_tready = m_axis_tready;



  wire [7:0] axis_word_select;
  assign axis_word_select = pos_i >> 3;



  wire [2:0] axis_word_pos;
  assign axis_word_pos = pos_i - (pos_i & 11'h7F8);

  reg [15:0] timestamp_fixed_pos16;
  always @(*) begin
    case (axis_word_pos)
      3'h0: timestamp_fixed_pos16 = s_axis_tdata[0+:16];
      3'h1: timestamp_fixed_pos16 = s_axis_tdata[8+:16];
      3'h2: timestamp_fixed_pos16 = s_axis_tdata[16+:16];
      3'h3: timestamp_fixed_pos16 = s_axis_tdata[24+:16];
      3'h4: timestamp_fixed_pos16 = s_axis_tdata[32+:16];
      3'h5: timestamp_fixed_pos16 = s_axis_tdata[40+:16];
      3'h6: timestamp_fixed_pos16 = s_axis_tdata[48+:16];
      default: timestamp_fixed_pos16 = 16'b0;
    endcase
  end

  reg [23:0] timestamp_fixed_pos24;
  always @(*) begin
    case (axis_word_pos)
      3'h0: timestamp_fixed_pos24 = s_axis_tdata[0+:24];
      3'h1: timestamp_fixed_pos24 = s_axis_tdata[8+:24];
      3'h2: timestamp_fixed_pos24 = s_axis_tdata[16+:24];
      3'h3: timestamp_fixed_pos24 = s_axis_tdata[24+:24];
      3'h4: timestamp_fixed_pos24 = s_axis_tdata[32+:24];
      3'h5: timestamp_fixed_pos24 = s_axis_tdata[40+:24];
      default: timestamp_fixed_pos24 = 24'b0;
    endcase
  end



  reg timestamp_fixed_pos_valid;
  always @(*) begin

    if (~width_i) begin

      timestamp_fixed_pos_valid = s_axis_tkeep[axis_word_pos+1];
    end else begin

      timestamp_fixed_pos_valid = s_axis_tkeep[axis_word_pos+2];
    end
  end


  wire [15:0] latency_header;
  assign latency_header = (timestamp_i[15:0] >= s_axis_tdata[15:0]) ?
                            (timestamp_i[15:0] - s_axis_tdata[15:0])
                          : (16'hFFFF - s_axis_tdata[15:0] + timestamp_i[15:0] +
                              16'b1);



  wire [15:0] latency_fixed16;
  assign latency_fixed16 = (timestamp_i[15:0] >= timestamp_fixed_pos16) ?
                              (timestamp_i[15:0] - timestamp_fixed_pos16)
                            : (16'hFFFF - timestamp_fixed_pos16 +
                              timestamp_i[15:0] + 16'b1);



  wire [23:0] latency_fixed24;
  assign latency_fixed24 = (timestamp_i >= timestamp_fixed_pos24) ?
                              (timestamp_i - timestamp_fixed_pos24)
                            : (24'hFFFFFF - timestamp_fixed_pos24 +
                              timestamp_i + 24'b1);

  reg [23:0] latency;
  reg        latency_valid;



  always @(posedge clk156) begin
    if (~rstn156 | rst_sw156) begin
      m_axis_tdata <= 64'b0;
      m_axis_tkeep <= 8'b0;
      m_axis_tvalid <= 1'b0;
      m_axis_tlast <= 1'b0;
      m_axis_tuser <= 25'b0;
      ethertype <= 16'b0;
      latency <= 24'b0;
      latency_valid <= 1'b0;
      axis_word_cntr <= 8'b0;
    end else begin
      if (m_axis_tready) begin

        if (mode_i == MODE_HEADER) begin




          if (axis_word_cntr == 1) begin

            ethertype <= s_axis_tdata[47:32];
            m_axis_tuser <= 25'b0;
            latency <= 24'b0;
            latency_valid <= 1'b0;
          end else if (axis_word_cntr == 2) begin

            if (ethertype == 16'hdd86) begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {1'b1, 8'b0, latency_header};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= {8'b0, latency_header};
                latency_valid <= 1'b1;
              end
            end else begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {latency_valid, latency};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= latency;
                latency_valid <= latency_valid;
              end
            end
          end else if (axis_word_cntr == 3) begin

            if (ethertype == 16'h0008) begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {1'b1, 8'b0, latency_header};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= {8'b0, latency_header};
                latency_valid <= 1'b1;
              end
            end else begin
              if (s_axis_tlast) begin
                m_axis_tuser <= {latency_valid, latency};
                latency <= 24'b0;
                latency_valid <= 1'b0;
              end else begin
                m_axis_tuser <= 25'b0;
                latency <= latency;
                latency_valid <= latency_valid;
              end
            end
          end else begin
            if (s_axis_tlast) begin
              m_axis_tuser <= {latency_valid, latency};
              latency <= 24'b0;
              latency_valid <= 1'b0;
            end else begin
              m_axis_tuser <= 25'b0;
              latency <= latency;
              latency_valid <= latency_valid;
            end
          end
        end else if (mode_i == MODE_FIXED_POS) begin


          if (axis_word_cntr == axis_word_select) begin



            if (timestamp_fixed_pos_valid) begin
              if (~width_i) begin

                if (s_axis_tlast) begin
                  m_axis_tuser <= {1'b1, 8'b0, latency_fixed16};
                  latency <= 24'b0;
                  latency_valid <= 1'b0;
                end else begin
                  m_axis_tuser <= 25'b0;
                  latency <= {8'b0, latency_fixed16};
                  latency_valid <= 1'b1;
                end
              end else begin

                if (s_axis_tlast) begin
                  m_axis_tuser <= {1'b1, latency_fixed24};
                  latency <= 24'b0;
                  latency_valid <= 1'b0;
                end else begin
                  m_axis_tuser <= 25'b0;
                  latency <= latency_fixed24;
                  latency_valid <= 1'b1;
                end
              end
            end else begin

              m_axis_tuser <= 25'b0;
              latency <= 24'b0;
              latency_valid <= 1'b0;
            end
          end else begin



            if (s_axis_tlast) begin
              m_axis_tuser <= {latency_valid, latency};
              latency <= 24'b0;
              latency_valid <= 1'b0;
            end else begin
              m_axis_tuser <= 25'b0;
              latency <= latency;
              latency_valid <= latency_valid;
            end
          end
        end else begin

          m_axis_tuser <= 25'b0;
          latency <= 24'b0;
          latency_valid <= 1'b0;
        end


        m_axis_tdata <= s_axis_tdata;
        m_axis_tkeep <= s_axis_tkeep;
        m_axis_tvalid <= s_axis_tvalid;
        m_axis_tlast <= s_axis_tlast;


        if (s_axis_tvalid) begin
          axis_word_cntr <= s_axis_tlast ? 8'b0 : (axis_word_cntr + 1);
        end else begin
          axis_word_cntr <= axis_word_cntr;
        end
      end else begin
        m_axis_tdata <= m_axis_tdata;
        m_axis_tkeep <= m_axis_tkeep;
        m_axis_tvalid <= m_axis_tvalid;
        m_axis_tlast <= m_axis_tlast;
        m_axis_tuser <= m_axis_tuser;

        ethertype <= ethertype;

        latency <= latency;
        latency_valid <= latency_valid;

        axis_word_cntr <= axis_word_cntr;
      end
    end
  end

endmodule