| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
rfnoc_graph.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/rfnoc/block_id.hpp>
11#include <uhd/rfnoc/graph_edge.hpp>
12#include <uhd/rfnoc/noc_block_base.hpp>
13#include <uhd/rfnoc/rfnoc_types.hpp>
14#include <uhd/stream.hpp>
15#include <uhd/transport/adapter_id.hpp>
16#include <uhd/types/device_addr.hpp>
17#include <uhd/types/time_spec.hpp>
18#include <uhd/utils/noncopyable.hpp>
19#include <boost/units/detail/utility.hpp> // for demangle
20#include <memory>
21#include <vector>
22
23 namespace uhd { namespace rfnoc {
24
25 class mb_controller;
26
33 class UHD_API rfnoc_graph : public uhd::noncopyable,
34 public std::enable_shared_from_this<rfnoc_graph>
35{
36 public:
40 using sptr = std::shared_ptr<rfnoc_graph>;
41
42 virtual ~rfnoc_graph() {}
43
44 /******************************************
45 * Factory
46 ******************************************/
55 static sptr make(const device_addr_t& dev_addr);
56
57 /******************************************
58 * Block Discovery/Retrieval
59 ******************************************/
79 virtual std::vector<block_id_t> find_blocks(
80 const std::string& block_id_hint) const = 0;
81
84 template <typename T>
85 std::vector<block_id_t> find_blocks(const std::string& block_id_hint) const
86 {
87 std::vector<block_id_t> all_block_ids = find_blocks(block_id_hint);
88 std::vector<block_id_t> filt_block_ids;
89 for (size_t i = 0; i < all_block_ids.size(); i++) {
90 if (has_block<T>(all_block_ids[i])) {
91 filt_block_ids.push_back(all_block_ids[i]);
92 }
93 }
94 return filt_block_ids;
95 }
96
103 virtual bool has_block(const block_id_t& block_id) const = 0;
104
110 template <typename T>
111 bool has_block(const block_id_t& block_id) const
112 {
113 return has_block(block_id)
114 && bool(std::dynamic_pointer_cast<T>(get_block(block_id)));
115 }
116
125 virtual noc_block_base::sptr get_block(const block_id_t& block_id) const = 0;
126
141 template <typename T>
142 std::shared_ptr<T> get_block(const block_id_t& block_id) const
143 {
144 std::shared_ptr<T> blk = std::dynamic_pointer_cast<T>(get_block(block_id));
145 if (blk) {
146 return blk;
147 } else {
148 throw uhd::lookup_error(
149 std::string("This device does not have a block of type ")
150 + boost::units::detail::demangle(typeid(T).name())
151 + " with ID: " + block_id.to_string());
152 }
153 }
154
155 /**************************************************************************
156 * Connection APIs
157 *************************************************************************/
166 virtual bool is_connectable(const block_id_t& src_blk,
167 size_t src_port,
168 const block_id_t& dst_blk,
169 size_t dst_port) = 0;
170
190 virtual void connect(const block_id_t& src_blk,
191 size_t src_port,
192 const block_id_t& dst_blk,
193 size_t dst_port,
194 bool is_back_edge = false) = 0;
195
207 virtual void connect(uhd::tx_streamer::sptr streamer,
208 size_t strm_port,
209 const block_id_t& dst_blk,
210 size_t dst_port,
211 uhd::transport::adapter_id_t adapter_id = uhd::transport::NULL_ADAPTER_ID) = 0;
212
224 virtual void connect(const block_id_t& src_blk,
225 size_t src_port,
226 uhd::rx_streamer::sptr streamer,
227 size_t strm_port,
228 uhd::transport::adapter_id_t adapter_id = uhd::transport::NULL_ADAPTER_ID) = 0;
229
243 virtual void disconnect(const block_id_t& src_blk,
244 size_t src_port,
245 const block_id_t& dst_blk,
246 size_t dst_port) = 0;
247
257 virtual void disconnect(const std::string& streamer_id) = 0;
258
269 virtual void disconnect(const std::string& streamer_id, size_t port) = 0;
270
280 virtual std::vector<uhd::transport::adapter_id_t> enumerate_adapters_from_src(
281 const block_id_t& src_blk, size_t src_port) = 0;
282
292 virtual std::vector<uhd::transport::adapter_id_t> enumerate_adapters_to_dst(
293 const block_id_t& dst_blk, size_t dst_port) = 0;
294
304 virtual std::vector<graph_edge_t> enumerate_static_connections() const = 0;
305
313 virtual std::vector<graph_edge_t> enumerate_active_connections() = 0;
314
322 virtual void commit() = 0;
323
329 virtual void release() = 0;
330
337 virtual std::string to_dot() = 0;
338
339 /******************************************
340 * Streaming
341 ******************************************/
342
353 virtual rx_streamer::sptr create_rx_streamer(
354 const size_t num_ports, const stream_args_t& args) = 0;
355
366 virtual tx_streamer::sptr create_tx_streamer(
367 const size_t num_ports, const stream_args_t& args) = 0;
368
369 /**************************************************************************
370 * Hardware Control
371 *************************************************************************/
379 virtual size_t get_num_mboards() const = 0;
380
390 virtual std::shared_ptr<mb_controller> get_mb_controller(
391 const size_t mb_index = 0) = 0;
392
427 virtual bool synchronize_devices(
428 const uhd::time_spec_t& time_spec, const bool quiet) = 0;
429
431 virtual uhd::property_tree::sptr get_tree(void) const = 0;
432
434 virtual chdr_w_t get_chdr_width(const size_t mb_index = 0) const = 0;
435}; // class rfnoc_graph
436
437}}; // namespace uhd::rfnoc
adapter_id.hpp
block_id.hpp
uhd::device_addr_t
Definition device_addr.hpp:39
uhd::property_tree::sptr
std::shared_ptr< property_tree > sptr
Definition property_tree.hpp:224
uhd::rfnoc::block_id_t
Definition block_id.hpp:40
uhd::rfnoc::block_id_t::to_string
std::string to_string() const
Return a string like this: "0/FFT#1" (includes all components, if set).
uhd::rfnoc::mb_controller
Definition mb_controller.hpp:31
uhd::rfnoc::noc_block_base::sptr
std::shared_ptr< noc_block_base > sptr
Definition noc_block_base.hpp:48
uhd::rfnoc::rfnoc_graph
Definition rfnoc_graph.hpp:35
uhd::rfnoc::rfnoc_graph::commit
virtual void commit()=0
uhd::rfnoc::rfnoc_graph::disconnect
virtual void disconnect(const std::string &streamer_id, size_t port)=0
uhd::rfnoc::rfnoc_graph::get_num_mboards
virtual size_t get_num_mboards() const =0
uhd::rfnoc::rfnoc_graph::to_dot
virtual std::string to_dot()=0
uhd::rfnoc::rfnoc_graph::has_block
bool has_block(const block_id_t &block_id) const
Definition rfnoc_graph.hpp:111
uhd::rfnoc::rfnoc_graph::enumerate_adapters_from_src
virtual std::vector< uhd::transport::adapter_id_t > enumerate_adapters_from_src(const block_id_t &src_blk, size_t src_port)=0
uhd::rfnoc::rfnoc_graph::~rfnoc_graph
virtual ~rfnoc_graph()
Definition rfnoc_graph.hpp:42
uhd::rfnoc::rfnoc_graph::release
virtual void release()=0
uhd::rfnoc::rfnoc_graph::enumerate_adapters_to_dst
virtual std::vector< uhd::transport::adapter_id_t > enumerate_adapters_to_dst(const block_id_t &dst_blk, size_t dst_port)=0
uhd::rfnoc::rfnoc_graph::connect
virtual void connect(uhd::tx_streamer::sptr streamer, size_t strm_port, const block_id_t &dst_blk, size_t dst_port, uhd::transport::adapter_id_t adapter_id=uhd::transport::NULL_ADAPTER_ID)=0
uhd::rfnoc::rfnoc_graph::is_connectable
virtual bool is_connectable(const block_id_t &src_blk, size_t src_port, const block_id_t &dst_blk, size_t dst_port)=0
uhd::rfnoc::rfnoc_graph::enumerate_static_connections
virtual std::vector< graph_edge_t > enumerate_static_connections() const =0
uhd::rfnoc::rfnoc_graph::get_chdr_width
virtual chdr_w_t get_chdr_width(const size_t mb_index=0) const =0
Return the CHDR width for a given device.
uhd::rfnoc::rfnoc_graph::create_tx_streamer
virtual tx_streamer::sptr create_tx_streamer(const size_t num_ports, const stream_args_t &args)=0
uhd::rfnoc::rfnoc_graph::get_mb_controller
virtual std::shared_ptr< mb_controller > get_mb_controller(const size_t mb_index=0)=0
uhd::rfnoc::rfnoc_graph::connect
virtual void connect(const block_id_t &src_blk, size_t src_port, uhd::rx_streamer::sptr streamer, size_t strm_port, uhd::transport::adapter_id_t adapter_id=uhd::transport::NULL_ADAPTER_ID)=0
uhd::rfnoc::rfnoc_graph::has_block
virtual bool has_block(const block_id_t &block_id) const =0
Checks if a specific NoC block exists on the device.
uhd::rfnoc::rfnoc_graph::get_block
std::shared_ptr< T > get_block(const block_id_t &block_id) const
Definition rfnoc_graph.hpp:142
uhd::rfnoc::rfnoc_graph::create_rx_streamer
virtual rx_streamer::sptr create_rx_streamer(const size_t num_ports, const stream_args_t &args)=0
uhd::rfnoc::rfnoc_graph::disconnect
virtual void disconnect(const block_id_t &src_blk, size_t src_port, const block_id_t &dst_blk, size_t dst_port)=0
uhd::rfnoc::rfnoc_graph::get_block
virtual noc_block_base::sptr get_block(const block_id_t &block_id) const =0
Returns a block controller class for an NoC block.
uhd::rfnoc::rfnoc_graph::connect
virtual void connect(const block_id_t &src_blk, size_t src_port, const block_id_t &dst_blk, size_t dst_port, bool is_back_edge=false)=0
uhd::rfnoc::rfnoc_graph::find_blocks
virtual std::vector< block_id_t > find_blocks(const std::string &block_id_hint) const =0
uhd::rfnoc::rfnoc_graph::get_tree
virtual uhd::property_tree::sptr get_tree(void) const =0
Return a reference to the property tree.
uhd::rfnoc::rfnoc_graph::find_blocks
std::vector< block_id_t > find_blocks(const std::string &block_id_hint) const
Definition rfnoc_graph.hpp:85
uhd::rfnoc::rfnoc_graph::make
static sptr make(const device_addr_t &dev_addr)
uhd::rfnoc::rfnoc_graph::disconnect
virtual void disconnect(const std::string &streamer_id)=0
uhd::rfnoc::rfnoc_graph::synchronize_devices
virtual bool synchronize_devices(const uhd::time_spec_t &time_spec, const bool quiet)=0
uhd::rfnoc::rfnoc_graph::sptr
std::shared_ptr< rfnoc_graph > sptr
Definition rfnoc_graph.hpp:40
uhd::rfnoc::rfnoc_graph::enumerate_active_connections
virtual std::vector< graph_edge_t > enumerate_active_connections()=0
uhd::rx_streamer::sptr
std::shared_ptr< rx_streamer > sptr
Definition stream.hpp:172
uhd::time_spec_t
Definition time_spec.hpp:31
uhd::tx_streamer::sptr
std::shared_ptr< tx_streamer > sptr
Definition stream.hpp:325
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
device_addr.hpp
graph_edge.hpp
uhd::rfnoc
Definition actions.hpp:24
uhd::rfnoc::chdr_w_t
chdr_w_t
Type that indicates the CHDR Width in bits.
Definition rfnoc_types.hpp:19
uhd::transport::adapter_id_t
size_t adapter_id_t
Host transport adapter ID.
Definition adapter_id.hpp:17
uhd
Definition build_info.hpp:12
uhd::noncopyable
boost::noncopyable noncopyable
Definition noncopyable.hpp:45
noc_block_base.hpp
noncopyable.hpp
rfnoc_types.hpp
stream.hpp
uhd::lookup_error
Definition exception.hpp:59
uhd::stream_args_t
Definition stream.hpp:51
time_spec.hpp