Loading...
Searching...
No Matches
rfnoc_graph.hpp
Go to the documentation of this file.
//
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <uhd/rfnoc/block_id.hpp>
#include <uhd/rfnoc/graph_edge.hpp>
#include <uhd/rfnoc/noc_block_base.hpp>
#include <uhd/rfnoc/rfnoc_types.hpp>
#include <uhd/stream.hpp>
#include <uhd/transport/adapter_id.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/types/time_spec.hpp>
#include <uhd/utils/noncopyable.hpp>
#include <boost/units/detail/utility.hpp> // for demangle
#include <memory>
#include <vector>
namespace uhd { namespace rfnoc {
class mb_controller;
class UHD_API rfnoc_graph : public uhd::noncopyable,
public std::enable_shared_from_this<rfnoc_graph>
{
public:
using sptr = std::shared_ptr<rfnoc_graph>;
virtual ~rfnoc_graph() {}
/******************************************
* Factory
******************************************/
static sptr make(const device_addr_t& dev_addr);
/******************************************
* Block Discovery/Retrieval
******************************************/
virtual std::vector<block_id_t> find_blocks(
const std::string& block_id_hint) const = 0;
template <typename T>
std::vector<block_id_t> find_blocks(const std::string& block_id_hint) const
{
std::vector<block_id_t> all_block_ids = find_blocks(block_id_hint);
std::vector<block_id_t> filt_block_ids;
for (size_t i = 0; i < all_block_ids.size(); i++) {
if (has_block<T>(all_block_ids[i])) {
filt_block_ids.push_back(all_block_ids[i]);
}
}
return filt_block_ids;
}
virtual bool has_block(const block_id_t& block_id) const = 0;
template <typename T>
bool has_block(const block_id_t& block_id) const
{
return has_block(block_id)
&& bool(std::dynamic_pointer_cast<T>(get_block(block_id)));
}
virtual noc_block_base::sptr get_block(const block_id_t& block_id) const = 0;
template <typename T>
std::shared_ptr<T> get_block(const block_id_t& block_id) const
{
std::shared_ptr<T> blk = std::dynamic_pointer_cast<T>(get_block(block_id));
if (blk) {
return blk;
} else {
throw uhd::lookup_error(
std::string("This device does not have a block of type ")
+ boost::units::detail::demangle(typeid(T).name())
+ " with ID: " + block_id.to_string());
}
}
/**************************************************************************
* Connection APIs
*************************************************************************/
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;
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;
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;
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;
virtual void disconnect(const block_id_t& src_blk,
size_t src_port,
const block_id_t& dst_blk,
size_t dst_port) = 0;
virtual void disconnect(const std::string& streamer_id) = 0;
virtual void disconnect(const std::string& streamer_id, size_t port) = 0;
virtual std::vector<uhd::transport::adapter_id_t> enumerate_adapters_from_src(
const block_id_t& src_blk, size_t src_port) = 0;
virtual std::vector<uhd::transport::adapter_id_t> enumerate_adapters_to_dst(
const block_id_t& dst_blk, size_t dst_port) = 0;
virtual std::vector<graph_edge_t> enumerate_static_connections() const = 0;
virtual std::vector<graph_edge_t> enumerate_active_connections() = 0;
virtual void commit() = 0;
virtual void release() = 0;
virtual std::string to_dot() = 0;
/******************************************
* Streaming
******************************************/
virtual rx_streamer::sptr create_rx_streamer(
const size_t num_ports, const stream_args_t& args) = 0;
virtual tx_streamer::sptr create_tx_streamer(
const size_t num_ports, const stream_args_t& args) = 0;
/**************************************************************************
* Hardware Control
*************************************************************************/
virtual size_t get_num_mboards() const = 0;
virtual std::shared_ptr<mb_controller> get_mb_controller(
const size_t mb_index = 0) = 0;
virtual bool synchronize_devices(
const uhd::time_spec_t& time_spec, const bool quiet) = 0;
virtual uhd::property_tree::sptr get_tree(void) const = 0;
virtual chdr_w_t get_chdr_width(const size_t mb_index = 0) const = 0;
}; // class rfnoc_graph
}}; // 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