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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [src/] [axis_fanout.sv] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2019 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_fanout #(F)
30
  (
31
    axis_if axis_in,
32
    axis_if axis_out[F],
33
    input   aclk,
34
    input   aresetn
35
  );
36
 
37
  // --------------------------------------------------------------------
38
  wire [F-1:0] handshake;
39
  wire [F-1:0] stalled;
40
  reg [F-1:0] transfer_stalled;
41
  wire [F-1:0] out_tready;
42
  wire all_ready = &out_tready;
43
  wire [F-1:0] done;
44
  wire all_done = &done;
45
 
46
  // --------------------------------------------------------------------
47
  enum reg [1:0]
48
    {
49
      FANOUT  = 2'b01,
50
      STALL   = 2'b10
51
    } state, next_state;
52
 
53
  // --------------------------------------------------------------------
54
  always_ff @(posedge aclk)
55
    if(~aresetn)
56
      state <= FANOUT;
57
    else
58
      state <= next_state;
59
 
60
  // --------------------------------------------------------------------
61
  always_comb
62
    case(state)
63
      FANOUT:   if(~axis_in.tvalid)
64
                  next_state = FANOUT;
65
                else if(all_ready)
66
                  next_state = FANOUT;
67
                else
68
                  next_state = STALL;
69
 
70
      STALL:    if(all_done)
71
                  next_state = FANOUT;
72
                else
73
                  next_state = STALL;
74
 
75
      default:  next_state = FANOUT;
76
    endcase
77
 
78
  // --------------------------------------------------------------------
79
  generate
80
    for(genvar j = 0; j < F; j++)
81
    begin: tready_gen
82
      // --------------------------------------------------------------------
83
      assign handshake[j] = axis_in.tvalid &  axis_out[j].tready;
84
      assign stalled[j]   = axis_in.tvalid & ~axis_out[j].tready;
85
      assign done[j]      = ~transfer_stalled[j] | handshake[j];
86
 
87
      always_ff @(posedge aclk)
88
        if(handshake[j])
89
          transfer_stalled[j] <= 0;
90
        else if(stalled[j])
91
          transfer_stalled[j] <= 1;
92
 
93
      // --------------------------------------------------------------------
94
      assign out_tready[j]      = axis_out[j].tready;
95
      assign axis_out[j].tlast  = axis_in.tlast;
96
      assign axis_out[j].tuser  = axis_in.tuser;
97
      assign axis_out[j].tdata  = axis_in.tdata;
98
      assign axis_out[j].tstrb  = axis_in.tstrb;
99
      assign axis_out[j].tkeep  = axis_in.tkeep;
100
      assign axis_out[j].tid    = axis_in.tid;
101
      assign axis_out[j].tdest  = axis_in.tdest;
102
      assign axis_out[j].tvalid = (state == FANOUT) ? axis_in.tvalid : transfer_stalled[j];
103
    end
104
  endgenerate
105
 
106
  // --------------------------------------------------------------------
107
  assign axis_in.tready = (state == FANOUT) ? all_ready : (next_state == FANOUT);
108
 
109
// --------------------------------------------------------------------
110
endmodule

powered by: WebSVN 2.1.0

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