OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [src/] [axis_catenate.sv] - Rev 51

Compare with Previous | Blame | View Log

//////////////////////////////////////////////////////////////////////
////                                                              ////
//// Copyright (C) 2017 Authors and OPENCORES.ORG                 ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
//////////////////////////////////////////////////////////////////////

module
  axis_catenate
  #(
    N, // data bus width in bytes
    I = 1, // TID width
    D = 1, // TDEST width
    U = 1, // TUSER width
    U_IS_EOP = -1
  )
  (
    axis_if axis_in [1:0],
    axis_if axis_out,
    input   aclk,
    input   aresetn
  );
  // --------------------------------------------------------------------
  wire select;
  wire axis_eop;

  defparam axis_eop_mux_i.U_IS_EOP = U_IS_EOP; // why are these needed for recursive modules?
  defparam axis_eop_mux_i.MA = 1;
  axis_eop_mux
  // axis_eop_mux #(.U_IS_EOP(U_IS_EOP), .MA(1))
    axis_eop_mux_i(.axis_in(axis_in), .*);

  // --------------------------------------------------------------------
  enum reg [1:0]
    { HEAD  = 2'b01,
      TAIL  = 2'b10
    } state, next_state;

  // --------------------------------------------------------------------
  always_ff @(posedge aclk)
    if(~aresetn)
      state <= HEAD;
    else
      state <= next_state;

  // --------------------------------------------------------------------
  always_comb
    case(state)
      HEAD:     if(axis_eop)
                  next_state <= TAIL;
                else
                  next_state <= HEAD;

      TAIL:     if(axis_eop)
                  next_state <= HEAD;
                else
                  next_state <= TAIL;

      default:  next_state <= HEAD;
    endcase

  // --------------------------------------------------------------------
  axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_bus[1:0](.*);
  genvar j;

  generate
    if(U_IS_EOP > -1) begin: u_is_eop_gen
      for(j = 0; j < U; j++) begin: for_tuser_gen
        if(j == U_IS_EOP) begin: choped_tuser_gen
          assign axis_bus[0].tuser[j] = 0;
        end
        else begin: tuser_gen
          assign axis_bus[0].tuser[j] = axis_in[0].tuser[j];
        end
      end
    end
    else begin: u_not_eop_gen
      assign axis_bus[0].tuser = axis_in[0].tuser;
    end

    if(U_IS_EOP > -1) begin: tlast_gen
      assign axis_bus[0].tlast = axis_in[0].tlast;
    end
    else begin: choped_tlast_gen
      assign axis_bus[0].tlast = 0;
    end
  endgenerate

  // --------------------------------------------------------------------
  axis_alias #(.CONNECT_TLAST(0), .CONNECT_TUSER(0))
    axis_alias(axis_in[0], axis_bus[0]);

  // --------------------------------------------------------------------
  axis_alias
    axis_alias_hi(axis_in[1], axis_bus[1]);

  // --------------------------------------------------------------------
  defparam axis_mux_i.N = N; // why are these needed for recursive modules?
  defparam axis_mux_i.I = I;
  defparam axis_mux_i.D = D;
  defparam axis_mux_i.U = U;
  axis_mux
  // axis_mux #(.N(N), .I(I), .D(D), .U(U))
    axis_mux_i(.axis_in(axis_bus), .*);

  // --------------------------------------------------------------------
  assign select = (state == HEAD) ? 0 : 1;

// --------------------------------------------------------------------
endmodule

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.