USRP Hardware Driver and Device Manual Version: 4.11.0.0-0-unknown
UHD and USRP Manual
Loading...
Searching...
No Matches
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>
17
19#define RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \
20 CLASS_NAME##_impl(make_args_ptr make_args) : CLASS_NAME(std::move(make_args))
21
22#define RFNOC_DECLARE_BLOCK(CLASS_NAME) \
23 using sptr = std::shared_ptr<CLASS_NAME>; \
24 CLASS_NAME(make_args_ptr make_args) : noc_block_base(std::move(make_args)) {}
25
26namespace uhd { namespace rfnoc {
27
28class clock_iface;
29class mb_controller;
30
42{
43public:
44 using sptr = std::shared_ptr<noc_block_base>;
45
54 {
56 };
57
64 struct make_args_int_t;
65
68 {
69 void operator()(make_args_int_t* ptr);
70 };
71
73 using make_args_ptr = std::unique_ptr<make_args_int_t, make_args_deleter>;
74
75 ~noc_block_base() override;
76
77 /**************************************************************************
78 * node_t API calls
79 *************************************************************************/
81 std::string get_unique_id() const override
82 {
83 return get_block_id().to_string();
84 }
85
93 size_t get_num_input_ports() const override
94 {
95 return _num_input_ports;
96 }
97
105 size_t get_num_output_ports() const override
106 {
107 return _num_output_ports;
108 }
109
110 /**************************************************************************
111 * RFNoC-block specific API calls
112 *************************************************************************/
118 {
119 return _noc_id;
120 }
121
127 {
128 return _block_id;
129 }
130
135 double get_tick_rate() const;
136
153 size_t get_mtu(const res_source_info& edge);
154
168 size_t get_chdr_hdr_len(const bool account_for_ts = true) const;
169
198 const res_source_info& edge, const bool account_for_ts = true);
199
203 {
204 return _block_args;
205 }
206
209 {
210 return _tree;
211 }
212
215 {
216 return _tree;
217 }
218
230 std::shared_ptr<mb_controller> get_mb_controller();
231
232protected:
234
245 void set_num_input_ports(const size_t num_ports);
246
260 void set_num_output_ports(const size_t num_ports);
261
267 void set_tick_rate(const double tick_rate);
268
298
304 void set_mtu(const res_source_info& edge, const size_t new_mtu);
305
316
334 virtual void deinit();
335
336private:
337 friend class block_initializer;
338
344 void _set_tick_rate(const double tick_rate);
345
351 void shutdown() override;
352
360 void post_init();
361
362 /**************************************************************************
363 * Attributes
364 **************************************************************************/
366 noc_id_t _noc_id;
367
372 block_id_t _block_id;
373
375 size_t _num_input_ports;
376
378 size_t _num_output_ports;
379
383 std::vector<property_t<double>> _tick_rate_props;
384
387
389 bool _mtu_fwd_policy_set = false;
390
394 std::vector<property_t<size_t>> _mtu_props;
395
397 std::unordered_map<res_source_info, size_t> _mtu;
398
400 chdr_w_t _chdr_w;
401
403 std::shared_ptr<clock_iface> _ctrlport_clock_iface;
404
406 std::shared_ptr<clock_iface> _tb_clock_iface;
407
411 std::shared_ptr<mb_controller> _mb_controller;
412
414 const uhd::device_addr_t _block_args;
415
421 mutable uhd::property_tree::sptr _tree;
422
423}; // class noc_block_base
424
425}} /* namespace uhd::rfnoc */
Definition device_addr.hpp:39
std::shared_ptr< property_tree > sptr
Definition property_tree.hpp:224
Definition block_id.hpp:40
uhd::device_addr_t get_block_args() const
Definition noc_block_base.hpp:202
void set_mtu_forwarding_policy(const forwarding_policy_t policy)
size_t get_num_output_ports() const override
Definition noc_block_base.hpp:105
size_t get_mtu(const res_source_info &edge)
friend class block_initializer
Definition noc_block_base.hpp:337
void set_mtu(const res_source_info &edge, const size_t new_mtu)
size_t get_max_payload_size(const res_source_info &edge, const bool account_for_ts=true)
double get_tick_rate() const
void set_num_input_ports(const size_t num_ports)
size_t get_num_input_ports() const override
Definition noc_block_base.hpp:93
std::string get_unique_id() const override
Unique ID for an RFNoC block is its block ID.
Definition noc_block_base.hpp:81
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:208
size_t get_chdr_hdr_len(const bool account_for_ts=true) const
uhd::property_tree::sptr & get_tree()
Return a reference to this block's subtree (non-const version).
Definition noc_block_base.hpp:214
noc_id_t get_noc_id() const
Definition noc_block_base.hpp:117
std::shared_ptr< mb_controller > get_mb_controller()
std::unique_ptr< make_args_int_t, make_args_deleter > make_args_ptr
Opaque pointer to the constructor arguments with custom deleter.
Definition noc_block_base.hpp:73
std::shared_ptr< noc_block_base > sptr
Definition noc_block_base.hpp:44
const block_id_t & get_block_id() const
Definition noc_block_base.hpp:126
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)
forwarding_policy_t
Types of property/action forwarding for those not defined by the block itself.
Definition node.hpp:54
@ ONE_TO_ONE
Definition node.hpp:58
Definition property.hpp:26
register_iface_holder(register_iface::sptr reg)
Definition register_iface_holder.hpp:21
#define UHD_API
Definition config.h:87
uint32_t noc_id_t
Definition defaults.hpp:52
chdr_w_t
Type that indicates the CHDR Width in bits.
Definition rfnoc_types.hpp:19
Definition build_info.hpp:12
Custom deleter for make_args_int_t that doesn't require complete type.
Definition noc_block_base.hpp:68
Dummy make_args_t class.
Definition noc_block_base.hpp:54
Definition res_source_info.hpp:18