USRP Hardware Driver and USRP Manual  Version: 4.7.0.0
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 
43 {
44 public:
48  using sptr = std::shared_ptr<noc_block_base>;
49 
51  struct make_args_t;
52 
54  using make_args_ptr = std::unique_ptr<make_args_t>;
55 
56  ~noc_block_base() override;
57 
58  /**************************************************************************
59  * node_t API calls
60  *************************************************************************/
62  std::string get_unique_id() const override
63  {
64  return get_block_id().to_string();
65  }
66 
74  size_t get_num_input_ports() const override
75  {
76  return _num_input_ports;
77  }
78 
86  size_t get_num_output_ports() const override
87  {
88  return _num_output_ports;
89  }
90 
91  /**************************************************************************
92  * RFNoC-block specific API calls
93  *************************************************************************/
99  {
100  return _noc_id;
101  }
102 
107  const block_id_t& get_block_id() const
108  {
109  return _block_id;
110  }
111 
116  double get_tick_rate() const;
117 
134  size_t get_mtu(const res_source_info& edge);
135 
149  size_t get_chdr_hdr_len(const bool account_for_ts = true) const;
150 
178  size_t get_max_payload_size(
179  const res_source_info& edge, const bool account_for_ts = true);
180 
184  {
185  return _block_args;
186  }
187 
190  {
191  return _tree;
192  }
193 
196  {
197  return _tree;
198  }
199 
211  std::shared_ptr<mb_controller> get_mb_controller();
212 
213 protected:
214  noc_block_base(make_args_ptr make_args);
215 
226  void set_num_input_ports(const size_t num_ports);
227 
241  void set_num_output_ports(const size_t num_ports);
242 
248  void set_tick_rate(const double tick_rate);
249 
278  void set_mtu_forwarding_policy(const forwarding_policy_t policy);
279 
285  void set_mtu(const res_source_info& edge, const size_t new_mtu);
286 
296  property_base_t* get_mtu_prop_ref(const res_source_info& edge);
297 
315  virtual void deinit();
316 
317 private:
318  friend class block_initializer;
319 
325  void _set_tick_rate(const double tick_rate);
326 
332  void shutdown() override;
333 
341  void post_init();
342 
343  /**************************************************************************
344  * Attributes
345  **************************************************************************/
347  noc_id_t _noc_id;
348 
350  //
351  // The framework will guarantee that no one else has the same block ID
352  block_id_t _block_id;
353 
355  size_t _num_input_ports;
356 
358  size_t _num_output_ports;
359 
361  // for all in- and output edges.
362  std::vector<property_t<double>> _tick_rate_props;
363 
365  forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::ONE_TO_ONE;
366 
368  bool _mtu_fwd_policy_set = false;
369 
371  // for all in- and output edges.
372  std::vector<property_t<size_t>> _mtu_props;
373 
375  std::unordered_map<res_source_info, size_t> _mtu;
376 
378  chdr_w_t _chdr_w;
379 
381  std::shared_ptr<clock_iface> _ctrlport_clock_iface;
382 
384  std::shared_ptr<clock_iface> _tb_clock_iface;
385 
387  // block had requested and was granted access
388  std::shared_ptr<mb_controller> _mb_controller;
389 
391  const uhd::device_addr_t _block_args;
392 
394  //
395  // It is mutable because _tree->access<>(..).get() is not const, but we
396  // need to do just that in some const contexts
397  mutable uhd::property_tree::sptr _tree;
398 
399 }; // class noc_block_base
400 
401 }} /* namespace uhd::rfnoc */
402 
const block_id_t & get_block_id() const
Definition: noc_block_base.hpp:107
Definition: register_iface_holder.hpp:18
uhd::property_tree::sptr & get_tree()
Return a reference to this block&#39;s subtree (non-const version)
Definition: noc_block_base.hpp:195
std::string get_unique_id() const override
Unique ID for an RFNoC block is its block ID.
Definition: noc_block_base.hpp:62
Definition: block_id.hpp:39
Definition: build_info.hpp:12
Definition: noc_block_base.hpp:42
forwarding_policy_t
Types of property/action forwarding for those not defined by the block itself.
Definition: node.hpp:46
noc_id_t get_noc_id() const
Definition: noc_block_base.hpp:98
uhd::property_tree::sptr & get_tree() const
Return a reference to this block&#39;s subtree.
Definition: noc_block_base.hpp:189
Definition: res_source_info.hpp:17
size_t get_num_output_ports() const override
Definition: noc_block_base.hpp:86
size_t get_num_input_ports() const override
Definition: noc_block_base.hpp:74
std::shared_ptr< noc_block_base > sptr
Definition: noc_block_base.hpp:48
#define UHD_API
Definition: config.h:87
Definition: node.hpp:34
Definition: property.hpp:25
Definition: noc_block_make_args.hpp:24
uint32_t noc_id_t
Definition: defaults.hpp:51
chdr_w_t
Type that indicates the CHDR Width in bits.
Definition: rfnoc_types.hpp:19
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:223
std::unique_ptr< make_args_t > make_args_ptr
Opaque pointer to the constructor arguments.
Definition: noc_block_base.hpp:54
uhd::device_addr_t get_block_args() const
Definition: noc_block_base.hpp:183
Definition: device_addr.hpp:37