File: axis_monitor.sv

package info (click to toggle)
uhd 4.9.0.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 184,180 kB
  • sloc: cpp: 262,887; python: 112,011; ansic: 102,670; vhdl: 57,031; tcl: 19,924; xml: 8,581; makefile: 3,028; sh: 2,812; pascal: 230; javascript: 120; csh: 94; asm: 20; perl: 11
file content (76 lines) | stat: -rw-r--r-- 2,077 bytes parent folder | download
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
68
69
70
71
72
73
74
75
76
//
// Copyright 2025 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Module: axis_monitor
//
// Description:
//
//   This module monitors an AXI-Stream bus and outputs some signals useful for
//   debugging.
//
// Parameters:
//
//   COUNT_W : The width in bits of the counter outputs.
//
// Signals:
//
//   i_t*       : The AXI-Stream bus to monitor. Note that i_tdata is not
//                needed, so there is no port for it.
//   xfer       : Transfer indicator. This output will be high in the clock
//                cycles during which a transfer occurs on the bus (i.e., when
//                i_tvalid and i_tready are both asserted).
//   sop        : Start-of-packet indicator. Asserts high for one clock cycle
//                during the first transfer of the packet.
//   eop        : End-of-packet indicator. Asserts high for one clock cycle
//                during the last transfer of the packet.
//   xfer_count : Counts the number of transfers that have occurred.
//   pkt_count  : Counts the number of packets that have been transferred.
//

`default_nettype none


module axis_monitor #(
  parameter int COUNT_W = 32
) (
  input  wire                clk,
  input  wire                rst,

  input  wire                i_tlast,
  input  wire                i_tvalid,
  input  wire                i_tready,

  output logic               xfer,
  output logic               sop,
  output logic               eop,
  output logic [COUNT_W-1:0] xfer_count = '0,
  output logic [COUNT_W-1:0] pkt_count  = '0
);
  logic sop_reg = 1'b1;

  assign xfer = i_tvalid && i_tready;
  assign sop  = xfer && sop_reg;
  assign eop  = xfer && i_tlast;

  always_ff @(posedge clk) begin
    if (xfer) begin
      sop_reg    <= i_tlast;
      xfer_count <= xfer_count + 1;
      if (i_tlast) begin
        pkt_count  <= pkt_count + 1;
        xfer_count <= '0;
      end
    end

    if (rst) begin
      sop_reg    <= 1'b1;
      pkt_count  <= '0;
      xfer_count <= '0;
    end
  end
endmodule


`default_nettype wire