aboutsummaryrefslogtreecommitdiffstats
path: root/fpga/usrp3/lib/axi4s_sv/axi4s.vh
blob: 1a0b80256e03b6b556d354c24fe7317e1809f1a9 (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
//
// Copyright 2020 Ettus Research, A National Instruments Brand
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Header File: axi4s
// Description: Macros for use with AXI4S
//

//-----------------------------------------------------------------------------
// Unidirectional AXI4-Stream interface
//-----------------------------------------------------------------------------

// Macro that drives o from i for all fields. Of course ready runs in the
// counter direction.

`define AXI4S_ASSIGN(O,I) \
  if (``I.TDATA) ``O.tdata = ``I.tdata;\
  if (``I.TUSER) ``O.tuser = ``I.tuser;\
  else           ``O.tuser = 0;\
  if (``I.TKEEP) ``O.tkeep = ``I.tkeep;\
  else           ``O.tkeep = '1;\
  if (``I.TLAST) ``O.tlast = ``I.tlast;\
  ``O.tvalid = ``I.tvalid;\
  ``I.tready = ``O.tready;

`define AXI4S_DEBUG_ASSIGN(O,I) \
  (* mark_debug = "true" *) logic [``I.DATA_WIDTH-1:0]   ``I``_debug_tdata;\
  (* mark_debug = "true" *) logic [``I.USER_WIDTH-1:0]   ``I``_debug_tuser;\
  (* mark_debug = "true" *) logic [``I.DATA_WIDTH/8-1:0] ``I``_debug_tkeep;\
  (* mark_debug = "true" *) logic                        ``I``_debug_tlast;\
  (* mark_debug = "true" *) logic                        ``I``_debug_tvalid;\
  (* mark_debug = "true" *) logic                        ``I``_debug_tready;\
  always_comb begin\
    if (``I.TDATA) ``I``_debug_tdata = ``I.tdata;\
    if (``I.TUSER) ``I``_debug_tuser = ``I.tuser;\
    if (``I.TKEEP) ``I``_debug_tkeep = ``I.tkeep;\
    if (``I.TLAST) ``I``_debug_tlast = ``I.tlast;\
    ``I``_debug_tvalid = ``I.tvalid;\
    ``I``_debug_tready = ``O.tready;\
  end\
  always_comb begin\
    if (``I.TDATA) ``O.tdata = ``I``_debug_tdata;\
    if (``I.TUSER) ``O.tuser = ``I``_debug_tuser;\
    else           ``O.tuser = 0;\
    if (``I.TKEEP) ``O.tkeep = ``I``_debug_tkeep;\
    else           ``O.tkeep = '1;\
    if (``I.TLAST) ``O.tlast = ``I``_debug_tlast;\
    ``O.tvalid = ``I``_debug_tvalid;\
    ``I.tready = ``I``_debug_tready;\
  end