USRP Hardware Driver and USRP Manual Version: 4.1.0.4
UHD and USRP Manual
noc_block_base.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 <uhd/config.hpp>
10#include <uhd/property_tree.hpp>
13#include <uhd/rfnoc/node.hpp>
16
18#define RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \
19 CLASS_NAME##_impl(make_args_ptr make_args) : CLASS_NAME(std::move(make_args))
20
21#define RFNOC_DECLARE_BLOCK(CLASS_NAME) \
22 using sptr = std::shared_ptr<CLASS_NAME>; \
23 CLASS_NAME(make_args_ptr make_args) : noc_block_base(std::move(make_args)) {}
24
25namespace uhd { namespace rfnoc {
26
27class clock_iface;
28class mb_controller;
29
42{
43public:
47 using sptr = std::shared_ptr<noc_block_base>;
48
50 struct make_args_t;
51
53 using make_args_ptr = std::unique_ptr<make_args_t>;
54
55 ~noc_block_base() override;
56
57 /**************************************************************************
58 * node_t API calls
59 *************************************************************************/
61 std::string get_unique_id() const override
62 {
63 return get_block_id().to_string();
64 }
65
67 // information stored in the global register space.
68 //
69 // Note: This may be overridden by the block (e.g., the X300 radio may not
70 // have all ports available if no TwinRX board is plugged in), but the
71 // subclassed version may never report more ports than this.
72 size_t get_num_input_ports() const override
73 {
74 return _num_input_ports;
75 }
76
78 // information stored in the global register space.
79 //
80 // Note: This may be overridden by the block (e.g., the X300 radio may not
81 // have all ports available if no TwinRX board is plugged in), but the
82 // subclassed version may never report more ports than this.
83 size_t get_num_output_ports() const override
84 {
85 return _num_output_ports;
86 }
87
88 /**************************************************************************
89 * RFNoC-block specific API calls
90 *************************************************************************/
96 {
97 return _noc_id;
98 }
99
105 {
106 return _block_id;
107 }
108
113 double get_tick_rate() const;
114
127 size_t get_mtu(const res_source_info& edge);
128
132 {
133 return _block_args;
134 }
135
138 {
139 return _tree;
140 }
141
144 {
145 return _tree;
146 }
147
148protected:
150
152 //
153 // - The new number of ports may not exceed the old number. This can only
154 // be used to 'decrease' the number of ports.
155 // - This is considered an 'advanced' API and should rarely be called by
156 // blocks. See also get_num_output_ports().
157 //
158 // \throws uhd::value_error if \p num_ports is larger than the current
159 // number of ports.
160 void set_num_input_ports(const size_t num_ports);
161
163 //
164 // - The new number of ports may not exceed the old number. This can only
165 // be used to 'decrease' the number of ports.
166 // - This is considered an 'advanced' API and should rarely be called by
167 // blocks. An example of where this is useful is the X310 radio block,
168 // which has 2 output ports, but only 1 is useful for UBX/SBX/WBX boards
169 // (i.e., boards with 1 frontend). In that case, software can make a
170 // determination to 'invalidate' one of the ports.
171 //
172 // \throws uhd::value_error if \p num_ports is larger than the current
173 // number of ports.
174 void set_num_output_ports(const size_t num_ports);
175
181 void set_tick_rate(const double tick_rate);
182
212
218 void set_mtu(const res_source_info& edge, const size_t new_mtu);
219
227
239 std::shared_ptr<mb_controller> get_mb_controller();
240
258 virtual void deinit();
259
260private:
266 void _set_tick_rate(const double tick_rate);
267
273 void shutdown() override;
274
275 /**************************************************************************
276 * Attributes
277 **************************************************************************/
279 noc_id_t _noc_id;
280
282 //
283 // The framework will guarantee that no one else has the same block ID
284 block_id_t _block_id;
285
287 size_t _num_input_ports;
288
290 size_t _num_output_ports;
291
293 // for all in- and output edges.
294 std::vector<property_t<double>> _tick_rate_props;
295
297 forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::DROP;
298
300 bool _mtu_fwd_policy_set = false;
301
303 // for all in- and output edges.
304 std::vector<property_t<size_t>> _mtu_props;
305
307 std::unordered_map<res_source_info, size_t> _mtu;
308
310 std::shared_ptr<clock_iface> _ctrlport_clock_iface;
311
313 std::shared_ptr<clock_iface> _tb_clock_iface;
314
316 // block had requested and was granted access
317 std::shared_ptr<mb_controller> _mb_controller;
318
320 const uhd::device_addr_t _block_args;
321
323 //
324 // It is mutable because _tree->access<>(..).get() is not const, but we
325 // need to do just that in some const contexts
326 mutable uhd::property_tree::sptr _tree;
327
328}; // class noc_block_base
329
330}} /* namespace uhd::rfnoc */
331
Definition: device_addr.hpp:38
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:216
Definition: block_id.hpp:40
Definition: noc_block_base.hpp:42
uhd::device_addr_t get_block_args() const
Definition: noc_block_base.hpp:131
std::unique_ptr< make_args_t > make_args_ptr
Opaque pointer to the constructor arguments.
Definition: noc_block_base.hpp:53
void set_mtu_forwarding_policy(const forwarding_policy_t policy)
size_t get_num_output_ports() const override
Number of output ports. Note: This gets passed outto this block from the.
Definition: noc_block_base.hpp:83
size_t get_mtu(const res_source_info &edge)
void set_mtu(const res_source_info &edge, const size_t new_mtu)
double get_tick_rate() const
void set_num_input_ports(const size_t num_ports)
Update number of input ports.
size_t get_num_input_ports() const override
Number of input ports. Note: This gets passed into this block from the.
Definition: noc_block_base.hpp:72
std::string get_unique_id() const override
Unique ID for an RFNoC block is its block ID.
Definition: noc_block_base.hpp:61
noc_block_base(make_args_ptr make_args)
uhd::property_tree::sptr & get_tree() const
Return a reference to this block's subtree.
Definition: noc_block_base.hpp:137
uhd::property_tree::sptr & get_tree()
Return a reference to this block's subtree (non-const version)
Definition: noc_block_base.hpp:143
noc_id_t get_noc_id() const
Definition: noc_block_base.hpp:95
std::shared_ptr< mb_controller > get_mb_controller()
std::shared_ptr< noc_block_base > sptr
Definition: noc_block_base.hpp:47
const block_id_t & get_block_id() const
Definition: noc_block_base.hpp:104
property_base_t * get_mtu_prop_ref(const res_source_info &edge)
void set_tick_rate(const double tick_rate)
void set_num_output_ports(const size_t num_ports)
Update number of output ports.
Definition: node.hpp:35
forwarding_policy_t
Types of property/action forwarding for those not defined by the block itself.
Definition: node.hpp:45
Definition: property.hpp:26
Definition: register_iface_holder.hpp:19
#define UHD_API
Definition: config.h:70
uint32_t noc_id_t
Definition: defaults.hpp:54
Definition: build_info.hpp:12
Definition: noc_block_make_args.hpp:24
Definition: res_source_info.hpp:18