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] - Blame information for rev 51

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2017 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
module
29
  axis_catenate
30
  #(
31
    N, // data bus width in bytes
32
    I = 1, // TID width
33
    D = 1, // TDEST width
34
    U = 1, // TUSER width
35
    U_IS_EOP = -1
36
  )
37
  (
38
    axis_if axis_in [1:0],
39
    axis_if axis_out,
40
    input   aclk,
41
    input   aresetn
42
  );
43
  // --------------------------------------------------------------------
44
  wire select;
45
  wire axis_eop;
46
 
47 38 qaztronic
  defparam axis_eop_mux_i.U_IS_EOP = U_IS_EOP; // why are these needed for recursive modules?
48 36 qaztronic
  defparam axis_eop_mux_i.MA = 1;
49
  axis_eop_mux
50
  // axis_eop_mux #(.U_IS_EOP(U_IS_EOP), .MA(1))
51
    axis_eop_mux_i(.axis_in(axis_in), .*);
52
 
53
  // --------------------------------------------------------------------
54
  enum reg [1:0]
55 51 qaztronic
    { HEAD  = 2'b01,
56 36 qaztronic
      TAIL  = 2'b10
57
    } state, next_state;
58
 
59
  // --------------------------------------------------------------------
60
  always_ff @(posedge aclk)
61
    if(~aresetn)
62
      state <= HEAD;
63
    else
64
      state <= next_state;
65
 
66
  // --------------------------------------------------------------------
67
  always_comb
68
    case(state)
69
      HEAD:     if(axis_eop)
70
                  next_state <= TAIL;
71
                else
72
                  next_state <= HEAD;
73
 
74
      TAIL:     if(axis_eop)
75
                  next_state <= HEAD;
76
                else
77
                  next_state <= TAIL;
78
 
79
      default:  next_state <= HEAD;
80
    endcase
81
 
82
  // --------------------------------------------------------------------
83 37 qaztronic
  axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_bus[1:0](.*);
84
  genvar j;
85
 
86
  generate
87 51 qaztronic
    if(U_IS_EOP > -1) begin: u_is_eop_gen
88
      for(j = 0; j < U; j++) begin: for_tuser_gen
89
        if(j == U_IS_EOP) begin: choped_tuser_gen
90 37 qaztronic
          assign axis_bus[0].tuser[j] = 0;
91
        end
92 51 qaztronic
        else begin: tuser_gen
93 37 qaztronic
          assign axis_bus[0].tuser[j] = axis_in[0].tuser[j];
94
        end
95
      end
96
    end
97 51 qaztronic
    else begin: u_not_eop_gen
98
      assign axis_bus[0].tuser = axis_in[0].tuser;
99
    end
100
 
101
    if(U_IS_EOP > -1) begin: tlast_gen
102 37 qaztronic
      assign axis_bus[0].tlast = axis_in[0].tlast;
103
    end
104 51 qaztronic
    else begin: choped_tlast_gen
105 37 qaztronic
      assign axis_bus[0].tlast = 0;
106
    end
107
  endgenerate
108
 
109
  // --------------------------------------------------------------------
110 51 qaztronic
  axis_alias #(.CONNECT_TLAST(0), .CONNECT_TUSER(0))
111
    axis_alias(axis_in[0], axis_bus[0]);
112 37 qaztronic
 
113
  // --------------------------------------------------------------------
114
  axis_alias
115 51 qaztronic
    axis_alias_hi(axis_in[1], axis_bus[1]);
116 37 qaztronic
 
117
  // --------------------------------------------------------------------
118 38 qaztronic
  defparam axis_mux_i.N = N; // why are these needed for recursive modules?
119 36 qaztronic
  defparam axis_mux_i.I = I;
120
  defparam axis_mux_i.D = D;
121
  defparam axis_mux_i.U = U;
122
  axis_mux
123
  // axis_mux #(.N(N), .I(I), .D(D), .U(U))
124 37 qaztronic
    axis_mux_i(.axis_in(axis_bus), .*);
125 36 qaztronic
 
126
  // --------------------------------------------------------------------
127
  assign select = (state == HEAD) ? 0 : 1;
128
 
129
// --------------------------------------------------------------------
130
endmodule

powered by: WebSVN 2.1.0

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