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 37

Go to most recent revision | 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
 
29
module
30
  axis_catenate
31
  #(
32
    N, // data bus width in bytes
33
    I = 1, // TID width
34
    D = 1, // TDEST width
35
    U = 1, // TUSER width
36
    U_IS_EOP = -1
37
  )
38
  (
39
    axis_if axis_in [1:0],
40
    axis_if axis_out,
41
    input   aclk,
42
    input   aresetn
43
  );
44
 
45
  // --------------------------------------------------------------------
46
  //
47
  wire select;
48
  wire axis_eop;
49
 
50
  defparam axis_eop_mux_i.U_IS_EOP = U_IS_EOP; // why are needed these for recursive modules?
51
  defparam axis_eop_mux_i.MA = 1;
52
  axis_eop_mux
53
  // axis_eop_mux #(.U_IS_EOP(U_IS_EOP), .MA(1))
54
    axis_eop_mux_i(.axis_in(axis_in), .*);
55
 
56
 
57
  // --------------------------------------------------------------------
58
  //  state machine binary definitions
59
  enum reg [1:0]
60
    {
61
      HEAD  = 2'b01,
62
      TAIL  = 2'b10
63
    } state, next_state;
64
 
65
 
66
  // --------------------------------------------------------------------
67
  //  state machine flop
68
  always_ff @(posedge aclk)
69
    if(~aresetn)
70
      state <= HEAD;
71
    else
72
      state <= next_state;
73
 
74
 
75
  // --------------------------------------------------------------------
76
  //  state machine
77
  always_comb
78
    case(state)
79
      HEAD:     if(axis_eop)
80
                  next_state <= TAIL;
81
                else
82
                  next_state <= HEAD;
83
 
84
      TAIL:     if(axis_eop)
85
                  next_state <= HEAD;
86
                else
87
                  next_state <= TAIL;
88
 
89
      default:  next_state <= HEAD;
90
    endcase
91
 
92
 
93
  // --------------------------------------------------------------------
94
  //
95 37 qaztronic
  axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_bus[1:0](.*);
96
  genvar j;
97
 
98
  generate
99
    if(U_IS_EOP > -1)
100
    begin: u_is_eop_gen
101
      for(j = 0; j < U; j++)
102
      begin: for_tuser_gen
103
        if(j == U_IS_EOP)
104
        begin: choped_tuser_gen
105
          assign axis_bus[0].tuser[j] = 0;
106
        end
107
        else
108
        begin: tuser_gen
109
          assign axis_bus[0].tuser[j] = axis_in[0].tuser[j];
110
        end
111
      end
112
    end
113
    else
114
    if(U_IS_EOP > -1)
115
    begin: tlast_gen
116
      assign axis_bus[0].tlast = axis_in[0].tlast;
117
    end
118
    else
119
    begin: choped_tlast_gen
120
      assign axis_bus[0].tlast = 0;
121
    end
122
  endgenerate
123
 
124
 
125
  // --------------------------------------------------------------------
126
  //
127
  assign axis_in[0].tready  = axis_bus[0].tready;
128
  assign axis_bus[0].tvalid = axis_in[0].tvalid;
129
  assign axis_bus[0].tdata  = axis_in[0].tdata;
130
  assign axis_bus[0].tstrb  = axis_in[0].tstrb;
131
  assign axis_bus[0].tkeep  = axis_in[0].tkeep;
132
  assign axis_bus[0].tid    = axis_in[0].tid;
133
  assign axis_bus[0].tdest  = axis_in[0].tdest;
134
 
135
 
136
  // --------------------------------------------------------------------
137
  //
138
  axis_alias
139
    axis_alias_i(axis_in[1], axis_bus[1]);
140
 
141
 
142
  // --------------------------------------------------------------------
143
  //
144 36 qaztronic
  defparam axis_mux_i.N = N; // why are needed these for recursive modules?
145
  defparam axis_mux_i.I = I;
146
  defparam axis_mux_i.D = D;
147
  defparam axis_mux_i.U = U;
148
  axis_mux
149
  // axis_mux #(.N(N), .I(I), .D(D), .U(U))
150 37 qaztronic
    axis_mux_i(.axis_in(axis_bus), .*);
151 36 qaztronic
 
152
 
153
  // --------------------------------------------------------------------
154
  //
155
  assign select = (state == HEAD) ? 0 : 1;
156
 
157
 
158
// --------------------------------------------------------------------
159
//
160
endmodule
161
 

powered by: WebSVN 2.1.0

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