blob: 4c635a5bf196e18825c57536e89dbc8285527150 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright 2014 Ettus Research
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: LGPL-3.0-or-later
module axi_pipe
#(parameter STAGES=3)
(input clk, input reset, input clear,
input i_tlast, input i_tvalid, output i_tready,
output o_tlast, output o_tvalid, input o_tready,
output [STAGES-1:0] enables,
output reg [STAGES-1:0] valids);
assign o_tvalid = valids[STAGES-1];
assign i_tready = enables[0];
// //////////////////////////////
// Valids
genvar i;
generate
for(i=1; i<STAGES; i=i+1)
always @(posedge clk)
if(reset | clear)
valids[i] <= 1'b0;
else
valids[i] <= valids[i-1] | (valids[i] & ~enables[i]);
endgenerate
always @(posedge clk)
if(reset | clear)
valids[0] <= 1'b0;
else
valids[0] <= i_tvalid | (valids[0] & ~enables[0]);
// //////////////////////////////
// Enables
genvar j;
generate
for(j=0; j<STAGES; j=j+1)
assign enables[j] = o_tready | (|(~valids[STAGES-1:j]));
endgenerate
// /////////////////////////////
// tlast
reg [STAGES-1:0] tlast;
genvar k;
generate
for(k=1; k<STAGES; k=k+1)
always @(posedge clk)
if(reset | clear)
tlast[k] <= 1'b0;
else if(enables[k])
tlast[k] <= tlast[k-1];
endgenerate
always @(posedge clk)
if(reset | clear)
tlast[0] <= 1'b0;
else if(enables[0])
tlast[0] <= i_tlast;
assign o_tlast = tlast[STAGES-1];
endmodule // axi_pipe
|