USRP Hardware Driver and USRP Manual  Version: 4.4.0.HEAD-0-g5fac246b
UHD and USRP Manual
rfnoc_types.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2019 Ettus Research, a National Instruments Brand
3 //
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 //
6 
7 #pragma once
8 
9 #include <cstddef>
10 #include <cstdint>
11 
12 namespace uhd { namespace rfnoc {
13 
14 //-----------------------------------------------------------------------------
15 // Types (note: internal types are defined in rfnoc_common.hpp)
16 //-----------------------------------------------------------------------------
17 
19 enum chdr_w_t { CHDR_W_64 = 0, CHDR_W_128 = 1, CHDR_W_256 = 2, CHDR_W_512 = 3 };
20 
22 constexpr size_t chdr_w_to_bits(chdr_w_t chdr_w)
23 {
24  // clang-format off
25  // This switch statement is what this function is doing, but it requires all
26  // consumers of this file to use C++14, which we currently enforce. We
27  // therefore keep this switch statement for reference, and for future
28  // improvements of this code, but what we feed the compiler is the nested
29  // ternary statement below.
30  /*
31  switch (chdr_w) {
32  case CHDR_W_64:
33  return 64;
34  case CHDR_W_128:
35  return 128;
36  case CHDR_W_256:
37  return 256;
38  case CHDR_W_512:
39  return 512;
40  default:
41  return 0;
42  }
43  */
44  return
45  chdr_w == CHDR_W_64 ? 64 :
46  chdr_w == CHDR_W_128 ? 128 :
47  chdr_w == CHDR_W_256 ? 256 :
48  chdr_w == CHDR_W_512 ? 512 :
49  /* default */ 0 ;
50  // clang-format on
51 }
52 
54 constexpr chdr_w_t bits_to_chdr_w(size_t bits)
55 {
56  // clang-format off
57  return
58  bits == 64 ? CHDR_W_64 :
59  bits == 128 ? CHDR_W_128 :
60  bits == 256 ? CHDR_W_256 :
61  bits == 512 ? CHDR_W_512 :
62  /* default */ CHDR_W_64 ;
63  // clang-format on
64 }
65 
67 // Stream endpoints within a graph are unique. They are assigned dynamically
68 // during runtime when needed. Stream endpoints exist both in the host as well
69 // as in the devices. See also sep_addr_t. The value of any sep_id_t is
70 // meaningless, it provides no information on where the SEP is physically
71 // located. In comments and variables, it is often abbreviated as "EPID"
72 // ("endpoint ID").
73 using sep_id_t = uint16_t;
74 
75 }} // namespace uhd::rfnoc
uhd::rfnoc::CHDR_W_128
@ CHDR_W_128
Definition: rfnoc_types.hpp:19
uhd::rfnoc::chdr_w_to_bits
constexpr size_t chdr_w_to_bits(chdr_w_t chdr_w)
Conversion from chdr_w_t to a number of bits.
Definition: rfnoc_types.hpp:22
uhd::rfnoc::CHDR_W_64
@ CHDR_W_64
Definition: rfnoc_types.hpp:19
uhd::rfnoc::sep_id_t
uint16_t sep_id_t
Stream Endpoint ID Type.
Definition: rfnoc_types.hpp:73
uhd
Definition: build_info.hpp:12
uhd::rfnoc::CHDR_W_512
@ CHDR_W_512
Definition: rfnoc_types.hpp:19
uhd::rfnoc::bits_to_chdr_w
constexpr chdr_w_t bits_to_chdr_w(size_t bits)
Conversion from number of bits to chdr_w_t.
Definition: rfnoc_types.hpp:54
uhd::rfnoc::CHDR_W_256
@ CHDR_W_256
Definition: rfnoc_types.hpp:19
uhd::rfnoc::chdr_w_t
chdr_w_t
Type that indicates the CHDR Width in bits.
Definition: rfnoc_types.hpp:19