URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [src/] [axis_fanout.sv] - Rev 50
Go to most recent revision | Compare with Previous | Blame | View Log
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2019 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_fanout #(F)
(
axis_if axis_in,
axis_if axis_out[F],
input aclk,
input aresetn
);
// --------------------------------------------------------------------
wire [F-1:0] handshake;
wire [F-1:0] stalled;
reg [F-1:0] transfer_stalled;
wire [F-1:0] out_tready;
wire all_ready = &out_tready;
wire [F-1:0] done;
wire all_done = &done;
// --------------------------------------------------------------------
enum reg [1:0]
{
FANOUT = 2'b01,
STALL = 2'b10
} state, next_state;
// --------------------------------------------------------------------
always_ff @(posedge aclk)
if(~aresetn)
state <= FANOUT;
else
state <= next_state;
// --------------------------------------------------------------------
always_comb
case(state)
FANOUT: if(~axis_in.tvalid)
next_state = FANOUT;
else if(all_ready)
next_state = FANOUT;
else
next_state = STALL;
STALL: if(all_done)
next_state = FANOUT;
else
next_state = STALL;
default: next_state = FANOUT;
endcase
// --------------------------------------------------------------------
generate
for(genvar j = 0; j < F; j++)
begin: tready_gen
// --------------------------------------------------------------------
assign handshake[j] = axis_in.tvalid & axis_out[j].tready;
assign stalled[j] = axis_in.tvalid & ~axis_out[j].tready;
assign done[j] = ~transfer_stalled[j] | handshake[j];
always_ff @(posedge aclk)
if(handshake[j])
transfer_stalled[j] <= 0;
else if(stalled[j])
transfer_stalled[j] <= 1;
// --------------------------------------------------------------------
assign out_tready[j] = axis_out[j].tready;
assign axis_out[j].tlast = axis_in.tlast;
assign axis_out[j].tuser = axis_in.tuser;
assign axis_out[j].tdata = axis_in.tdata;
assign axis_out[j].tstrb = axis_in.tstrb;
assign axis_out[j].tkeep = axis_in.tkeep;
assign axis_out[j].tid = axis_in.tid;
assign axis_out[j].tdest = axis_in.tdest;
assign axis_out[j].tvalid = (state == FANOUT) ? axis_in.tvalid : transfer_stalled[j];
end
endgenerate
// --------------------------------------------------------------------
assign axis_in.tready = (state == FANOUT) ? all_ready : (next_state == FANOUT);
// --------------------------------------------------------------------
endmodule
Go to most recent revision | Compare with Previous | Blame | View Log