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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [src/] [axis_switch_allocator.sv] - Blame information for rev 36

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_switch_allocator
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, // set to -1 for tlast, else set to index of tuser
37
    SA, // select width
38
    SD = 2 ** SA
39
  )
40
  (
41
    axis_if axis_in,
42
    axis_if axis_out[SD-1:0],
43
    input   aclk,
44
    input   aresetn
45
  );
46
 
47
  // --------------------------------------------------------------------
48
  //
49
  wire eop_in;
50
 
51
  axis_eop_set #(U_IS_EOP)
52
    axis_eop_set_i
53
    (
54
      .axis_in(axis_in),
55
      .tready(axis_switch_in.tready),
56
      .tvalid(axis_in.tvalid),
57
      .axis_eop(eop_in),
58
      .*
59
    );
60
 
61
 
62
  // --------------------------------------------------------------------
63
  //
64
  wire eop_out_mux;
65
  reg [SA-1:0] select;
66
 
67
  axis_eop_mux #(.U_IS_EOP(U_IS_EOP), .MA(SA))
68
    axis_eop_mux_i
69
    (
70
      .axis_in(axis_out),
71
      .axis_eop(eop_out_mux),
72
      .*
73
    );
74
 
75
 
76
  // --------------------------------------------------------------------
77
  //
78
  axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_switch_in(.*);
79
 
80
  axis_alias #(.CONNECT_TREADY(0), .CONNECT_TVALID(0))
81
    axis_alias_i(.axis_out(axis_switch_in), .*);
82
 
83
 
84
  // --------------------------------------------------------------------
85
  //  state machine binary definitions
86
  enum reg [3:0]
87
    {
88
      ALLOT   = 4'b0001,
89
      FLUSH   = 4'b0010,
90
      SWITCH  = 4'b0100,
91
      SETTLE  = 4'b1000
92
    } state, next_state;
93
 
94
 
95
  // --------------------------------------------------------------------
96
  //  state machine flop
97
  always_ff @(posedge aclk)
98
    if(~aresetn)
99
      state <= ALLOT;
100
    else
101
      state <= next_state;
102
 
103
 
104
  // --------------------------------------------------------------------
105
  //  state machine
106
  always_comb
107
    case(state)
108
      ALLOT:    if(eop_in)
109
                  next_state <= FLUSH;
110
                else
111
                  next_state <= ALLOT;
112
 
113
      FLUSH:    if(eop_out_mux)
114
                  next_state <= SWITCH;
115
                else
116
                  next_state <= FLUSH;
117
 
118
      SWITCH:   next_state <= SETTLE;
119
 
120
      SETTLE:   next_state <= ALLOT;  // let select propagate to the switches
121
 
122
      default:  next_state <= ALLOT;
123
    endcase
124
 
125
 
126
  // --------------------------------------------------------------------
127
  //
128
  always_ff @(posedge aclk)
129
    if(~aresetn)
130
      select <= 0;
131
    else if(state == SWITCH)
132
      select <= select + 1;
133
 
134
 
135
  // --------------------------------------------------------------------
136
  //
137
  recursive_axis_switch #(.N(N), .I(I), .D(D), .U(U), .SA(SA))
138
    recursive_axis_switch_i(.axis_in(axis_switch_in), .*);
139
 
140
 
141
  // --------------------------------------------------------------------
142
  //
143
  assign axis_in.tready         = (state == ALLOT) & axis_switch_in.tready;
144
  assign axis_switch_in.tvalid  = (state == ALLOT) & axis_in.tvalid;
145
 
146
 
147
// --------------------------------------------------------------------
148
//
149
endmodule
150
 

powered by: WebSVN 2.1.0

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