diff options
-rw-r--r-- | host/include/uhd/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/graph_edge.hpp | 86 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/graph.hpp | 62 |
3 files changed, 90 insertions, 59 deletions
diff --git a/host/include/uhd/rfnoc/CMakeLists.txt b/host/include/uhd/rfnoc/CMakeLists.txt index 41826a9cb..a16fa7330 100644 --- a/host/include/uhd/rfnoc/CMakeLists.txt +++ b/host/include/uhd/rfnoc/CMakeLists.txt @@ -16,6 +16,7 @@ if(ENABLE_RFNOC) defaults.hpp dirtifier.hpp graph.hpp + graph_edge.hpp noc_block_make_args.hpp node_ctrl_base.hpp node_ctrl_base.ipp diff --git a/host/include/uhd/rfnoc/graph_edge.hpp b/host/include/uhd/rfnoc/graph_edge.hpp new file mode 100644 index 000000000..8ab33f2a7 --- /dev/null +++ b/host/include/uhd/rfnoc/graph_edge.hpp @@ -0,0 +1,86 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_RFNOC_GRAPH_EDGE_HPP +#define INCLUDED_LIBUHD_RFNOC_GRAPH_EDGE_HPP + +#include <uhd/config.hpp> +#include <string> +#include <tuple> + +namespace uhd { namespace rfnoc { + +/*! A container that holds information about a graph edge + * + * Note: The source and destination IDs are strings, not block IDs + * (uhd::rfnoc::block_id_t). This is because the graph can contain edges + * that are not between RFNoC blocks (e.g., to a streamer), and we need to + * be able to generically express node IDs. + */ +struct UHD_API graph_edge_t +{ + enum edge_t { + STATIC, ///< A static connection between two blocks in the FPGA + DYNAMIC, ///< A user (dynamic) connection between two blocks in the FPGA + RX_STREAM, ///< A connection from an FPGA block to a software RX streamer + TX_STREAM ///< A connection from a software TX streamer and an FPGA block + }; + + graph_edge_t() = default; + + graph_edge_t(const size_t src_port_, + const size_t dst_port_, + const edge_t edge_, + const bool ppa) + : src_port(src_port_) + , dst_port(dst_port_) + , edge(edge_) + , property_propagation_active(ppa) + { + } + + //! The ID of the source block for this edge + std::string src_blockid; + //! The port number of the source block for this edge + size_t src_port = 0; + //! The ID of the destination block for this edge + std::string dst_blockid; + //! The port number of the destination block for this edge + size_t dst_port = 0; + //! The type of edge + edge_t edge = DYNAMIC; + //! When true, the framework will use this edge for property propagation + bool property_propagation_active = true; + + bool operator==(const graph_edge_t& rhs) const + { + return std::tie(src_blockid, + src_port, + dst_blockid, + dst_port, + edge, + property_propagation_active) + == std::tie(rhs.src_blockid, + rhs.src_port, + rhs.dst_blockid, + rhs.dst_port, + rhs.edge, + rhs.property_propagation_active); + } + + //! Return a string representation of the connection + std::string to_string() const + { + return src_blockid + ":" + std::to_string(src_port) + + (edge == STATIC ? "==>" : "-->") + dst_blockid + ":" + + std::to_string(dst_port); + } +}; + + +}} /* namespace uhd::rfnoc */ + +#endif /* INCLUDED_LIBUHD_RFNOC_GRAPH_EDGE_HPP */ diff --git a/host/lib/include/uhdlib/rfnoc/graph.hpp b/host/lib/include/uhdlib/rfnoc/graph.hpp index ec6309bd0..fdb4525d1 100644 --- a/host/lib/include/uhdlib/rfnoc/graph.hpp +++ b/host/lib/include/uhdlib/rfnoc/graph.hpp @@ -7,6 +7,7 @@ #ifndef INCLUDED_LIBUHD_GRAPH_HPP #define INCLUDED_LIBUHD_GRAPH_HPP +#include <uhd/rfnoc/graph_edge.hpp> #include <uhd/rfnoc/actions.hpp> #include <uhd/rfnoc/node.hpp> #include <boost/graph/adjacency_list.hpp> @@ -14,64 +15,7 @@ #include <memory> #include <deque> -namespace uhd { namespace rfnoc { - -/*! A container that holds information about a graph edge - */ -struct graph_edge_t -{ - enum edge_t { - STATIC, ///< A static connection between two blocks in the FPGA - DYNAMIC, ///< A user (dynamic) connection between two blocks in the FPGA - RX_STREAM, ///< A connection from an FPGA block to a software RX streamer - TX_STREAM ///< A connection from a software TX streamer and an FPGA block - }; - - graph_edge_t() = default; - - graph_edge_t(const size_t src_port_, - const size_t dst_port_, - const edge_t edge_, - const bool ppa) - : src_port(src_port_) - , dst_port(dst_port_) - , edge(edge_) - , property_propagation_active(ppa) - { - } - - //! The block ID of the source block for this edge - std::string src_blockid; - //! The port number of the source block for this edge - size_t src_port = 0; - //! The block ID of the destination block for this edge - std::string dst_blockid; - //! The port number of the destination block for this edge - size_t dst_port = 0; - //! The type of edge - edge_t edge = DYNAMIC; - //! When true, the framework will use this edge for property propagation - bool property_propagation_active = true; - - bool operator==(const graph_edge_t& rhs) const - { - return std::tie(src_blockid, - src_port, - dst_blockid, - dst_port, - edge, - property_propagation_active) - == std::tie(rhs.src_blockid, - rhs.src_port, - rhs.dst_blockid, - rhs.dst_port, - rhs.edge, - rhs.property_propagation_active); - } -}; - - -namespace detail { +namespace uhd { namespace rfnoc { namespace detail { //! Container for the logical graph within an uhd::rfnoc_graph class graph_t @@ -80,7 +24,7 @@ public: using uptr = std::unique_ptr<graph_t>; //! A shorthand for a pointer to a node using node_ref_t = uhd::rfnoc::node_t*; - + //! Shorthand to existing graph_edge_t using graph_edge_t = uhd::rfnoc::graph_edge_t; /*! Add a connection to the graph |