USRP Hardware Driver and Device Manual  Version: 4.10.0.0-0-g2af4ddb9
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>
11 #include <uhd/rfnoc/block_id.hpp>
12 #include <uhd/rfnoc/defaults.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 
26 namespace uhd { namespace rfnoc {
27 
28 class clock_iface;
29 class mb_controller;
30 
42 {
43 public:
44  using sptr = std::shared_ptr<noc_block_base>;
45 
47  //
48  // This allows OOTs to compile even if they were created prior to making
49  // make_args_t fully opaque.
50  //
51  // This is deprecated and will be removed in future UHD versions.
53  {
55  };
56 
63  struct make_args_int_t;
64 
67  {
68  void operator()(make_args_int_t* ptr);
69  };
70 
72  using make_args_ptr = std::unique_ptr<make_args_int_t, make_args_deleter>;
73 
74  ~noc_block_base() override;
75 
76  /**************************************************************************
77  * node_t API calls
78  *************************************************************************/
80  std::string get_unique_id() const override
81  {
82  return get_block_id().to_string();
83  }
84 
92  size_t get_num_input_ports() const override
93  {
94  return _num_input_ports;
95  }
96 
104  size_t get_num_output_ports() const override
105  {
106  return _num_output_ports;
107  }
108 
109  /**************************************************************************
110  * RFNoC-block specific API calls
111  *************************************************************************/
117  {
118  return _noc_id;
119  }
120 
125  const block_id_t& get_block_id() const
126  {
127  return _block_id;
128  }
129 
134  double get_tick_rate() const;
135 
152  size_t get_mtu(const res_source_info& edge);
153 
167  size_t get_chdr_hdr_len(const bool account_for_ts = true) const;
168 
197  const res_source_info& edge, const bool account_for_ts = true);
198 
202  {
203  return _block_args;
204  }
205 
208  {
209  return _tree;
210  }
211 
214  {
215  return _tree;
216  }
217 
229  std::shared_ptr<mb_controller> get_mb_controller();
230 
231 protected:
233 
244  void set_num_input_ports(const size_t num_ports);
245 
259  void set_num_output_ports(const size_t num_ports);
260 
266  void set_tick_rate(const double tick_rate);
267 
297 
303  void set_mtu(const res_source_info& edge, const size_t new_mtu);
304 
315 
333  virtual void deinit();
334 
335 private:
336  friend class block_initializer;
337 
343  void _set_tick_rate(const double tick_rate);
344 
350  void shutdown() override;
351 
359  void post_init();
360 
361  /**************************************************************************
362  * Attributes
363  **************************************************************************/
365  noc_id_t _noc_id;
366 
368  //
369  // The framework will guarantee that no one else has the same block ID
370  block_id_t _block_id;
371 
373  size_t _num_input_ports;
374 
376  size_t _num_output_ports;
377 
379  // for all in- and output edges.
380  std::vector<property_t<double>> _tick_rate_props;
381 
383  forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::ONE_TO_ONE;
384 
386  bool _mtu_fwd_policy_set = false;
387 
389  // for all in- and output edges.
390  std::vector<property_t<size_t>> _mtu_props;
391 
393  std::unordered_map<res_source_info, size_t> _mtu;
394 
396  chdr_w_t _chdr_w;
397 
399  std::shared_ptr<clock_iface> _ctrlport_clock_iface;
400 
402  std::shared_ptr<clock_iface> _tb_clock_iface;
403 
405  // block had requested and was granted access
406  std::shared_ptr<mb_controller> _mb_controller;
407 
409  const uhd::device_addr_t _block_args;
410 
412  //
413  // It is mutable because _tree->access<>(..).get() is not const, but we
414  // need to do just that in some const contexts
415  mutable uhd::property_tree::sptr _tree;
416 
417 }; // class noc_block_base
418 
419 }} /* namespace uhd::rfnoc */
Definition: device_addr.hpp:39
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:224
Definition: block_id.hpp:40
Definition: noc_block_base.hpp:42
uhd::device_addr_t get_block_args() const
Definition: noc_block_base.hpp:201
void set_mtu_forwarding_policy(const forwarding_policy_t policy)
uhd::property_tree::sptr & get_tree() const
Return a reference to this block's subtree.
Definition: noc_block_base.hpp:207
size_t get_num_output_ports() const override
Definition: noc_block_base.hpp:104
uhd::property_tree::sptr & get_tree()
Return a reference to this block's subtree (non-const version)
Definition: noc_block_base.hpp:213
size_t get_mtu(const res_source_info &edge)
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
std::shared_ptr< mb_controller > get_mb_controller()
void set_num_input_ports(const size_t num_ports)
size_t get_num_input_ports() const override
Definition: noc_block_base.hpp:92
std::string get_unique_id() const override
Unique ID for an RFNoC block is its block ID.
Definition: noc_block_base.hpp:80
noc_block_base(make_args_ptr make_args)
size_t get_chdr_hdr_len(const bool account_for_ts=true) const
const block_id_t & get_block_id() const
Definition: noc_block_base.hpp:125
noc_id_t get_noc_id() const
Definition: noc_block_base.hpp:116
property_base_t * get_mtu_prop_ref(const res_source_info &edge)
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:72
std::shared_ptr< noc_block_base > sptr
Definition: noc_block_base.hpp:44
void set_tick_rate(const double tick_rate)
void set_num_output_ports(const size_t num_ports)
Definition: node.hpp:35
forwarding_policy_t
Types of property/action forwarding for those not defined by the block itself.
Definition: node.hpp:54
Definition: property.hpp:26
Definition: register_iface_holder.hpp:19
#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:67
Dummy make_args_t class.
Definition: noc_block_base.hpp:53
Definition: res_source_info.hpp:18