USRP Hardware Driver and USRP Manual Version: 20250718.0.git40403b7c.fc42
UHD and USRP Manual
 
Loading...
Searching...
No Matches
compat_check.hpp
Go to the documentation of this file.
1//
2// Copyright 2018 Ettus Research, a National Instruments Company
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7#pragma once
8
9#include <uhd/config.hpp>
10#include <cstddef>
11#include <cstdint>
12#include <string>
13
14namespace uhd {
15
17template <typename major_type, typename minor_type>
19{
20public:
21 constexpr compat_num(major_type major, minor_type minor)
22 : _major(major), _minor(minor)
23 {
24 }
25
26 major_type get_major() const
27 {
28 return _major;
29 }
30 major_type get_minor() const
31 {
32 return _minor;
33 }
34
36 {
37 return _major == rhs.get_major() && _minor == rhs.get_minor();
38 }
39
41 {
42 return !(*this == rhs);
43 }
44
46 {
47 return _major < rhs.get_major()
48 || (_major == rhs.get_major() && _minor < rhs.get_minor());
49 }
50
52 {
53 return *this == rhs || *this < rhs;
54 }
55
57 {
58 return _major > rhs.get_major()
59 || (_major == rhs.get_major() && _minor > rhs.get_minor());
60 }
61
63 {
64 return *this == rhs || *this > rhs;
65 }
66
67 std::string to_string() const
68 {
69 return std::to_string(_major) + ":" + std::to_string(_minor);
70 }
71
72protected:
73 major_type _major;
74 minor_type _minor;
75};
76
78class UHD_API_HEADER compat_num16 : public compat_num<uint8_t, uint8_t>
79{
80public:
81 compat_num16(const uint16_t compat_val)
82 : compat_num<uint8_t, uint8_t>((compat_val >> 8) & 0xFF, compat_val & 0xFF)
83 {
84 }
85
86 compat_num16(const uint8_t major, const uint8_t minor)
87 : compat_num<uint8_t, uint8_t>(major, minor)
88 {
89 }
90
91 uint16_t get() const
92 {
93 return static_cast<uint16_t>(_major) << 8 | _minor;
94 };
95};
96
98class UHD_API_HEADER compat_num32 : public compat_num<uint16_t, uint16_t>
99{
100public:
101 constexpr compat_num32(const uint32_t compat_val)
102 : compat_num<uint16_t, uint16_t>((compat_val >> 16) & 0xFFFF, compat_val & 0xFFFF)
103 {
104 }
105
106 constexpr compat_num32(const uint16_t major, const uint16_t minor)
107 : compat_num<uint16_t, uint16_t>(major, minor)
108 {
109 }
110
111 uint32_t get() const
112 {
113 return static_cast<uint32_t>(_major) << 16 | _minor;
114 };
115};
116
121void UHD_API assert_fpga_compat(const size_t uhd_major,
122 const size_t uhd_minor,
123 const uint64_t fpga_compat,
124 const std::string& fpga_component,
125 const std::string& log_component,
126 const bool fail_on_minor_behind = false);
127
132void UHD_API assert_fpga_compat(const size_t uhd_major,
133 const size_t uhd_minor,
134 const uint32_t fpga_compat,
135 const std::string& fpga_component,
136 const std::string& log_component,
137 const bool fail_on_minor_behind = false);
138
139} /* namespace uhd */
compat_num16(const uint8_t major, const uint8_t minor)
Definition compat_check.hpp:86
compat_num16(const uint16_t compat_val)
Definition compat_check.hpp:81
uint16_t get() const
Definition compat_check.hpp:91
uint32_t get() const
Definition compat_check.hpp:111
constexpr compat_num32(const uint16_t major, const uint16_t minor)
Definition compat_check.hpp:106
constexpr compat_num32(const uint32_t compat_val)
Definition compat_check.hpp:101
major_type _major
Definition compat_check.hpp:73
constexpr compat_num(major_type major, minor_type minor)
Definition compat_check.hpp:21
bool operator>(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:56
major_type get_major() const
Definition compat_check.hpp:26
minor_type _minor
Definition compat_check.hpp:74
bool operator>=(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:62
bool operator<(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:45
bool operator==(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:35
bool operator<=(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:51
bool operator!=(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:40
major_type get_minor() const
Definition compat_check.hpp:30
std::string to_string() const
Definition compat_check.hpp:67
#define UHD_API_HEADER
Definition config.h:88
#define UHD_API
Definition config.h:87
Definition build_info.hpp:12
void UHD_API assert_fpga_compat(const size_t uhd_major, const size_t uhd_minor, const uint64_t fpga_compat, const std::string &fpga_component, const std::string &log_component, const bool fail_on_minor_behind=false)