From 636dad30696b68fc26bb91f370873fb3f938b020 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 24 May 2019 16:38:28 -0700 Subject: rfnoc: Move graph_edge data structure to its own header, add to_string() This structure represents information about a graph edge. Required by detail::graph and rfnoc_graph. graph_edge_t::to_string() will now provide a textual representation of the edge. --- host/include/uhd/rfnoc/CMakeLists.txt | 1 + host/include/uhd/rfnoc/graph_edge.hpp | 86 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 host/include/uhd/rfnoc/graph_edge.hpp (limited to 'host/include') 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 +#include +#include + +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 */ -- cgit v1.2.3