From 2da99fad97a7123cb08b429e93a557327582ade9 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Wed, 9 Oct 2019 11:41:38 -0700 Subject: rfnoc: Adding rfnoc_graph utilities Adding graph_utils to keep rfnoc_graph utilities to contain helper function and commonly used algorithms for the rfnoc_graph. These functions aren't core to the rfnoc_graph's functionality, so we'll keep them out of its API. --- host/include/uhd/utils/CMakeLists.txt | 1 + host/include/uhd/utils/graph_utils.hpp | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 host/include/uhd/utils/graph_utils.hpp (limited to 'host/include') diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index bf367f63d..b70de86ba 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -17,6 +17,7 @@ UHD_INSTALL(FILES fp_compare_delta.ipp fp_compare_epsilon.ipp gain_group.hpp + graph_utils.hpp log.hpp log_add.hpp math.hpp diff --git a/host/include/uhd/utils/graph_utils.hpp b/host/include/uhd/utils/graph_utils.hpp new file mode 100644 index 000000000..b2c61f78f --- /dev/null +++ b/host/include/uhd/utils/graph_utils.hpp @@ -0,0 +1,68 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Branch +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_UHD_UTILS_GRAPH_UTILS_HPP +#define INCLUDED_UHD_UTILS_GRAPH_UTILS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace uhd { namespace rfnoc { + +//! Tuple that stores a block ID, as well as an optional port number +using block_port_def = std::tuple>; + +// TODO: Get rid of magic strings +/*! List of blocks that can terminate chains. Note that some blocks only terminate at + * some of their ports, so we can optionally include a port number. + */ +static const std::vector TERMINATOR_BLOCKS{ + {NODE_ID_SEP, boost::none}, {"Radio", boost::none}, {"NullSrcSink", 0}}; + +/*! + * Get a chain of blocks that statically connect back to a terminating block. This + * vector's first element is `start_block`, and the chain continues from there. + * + * This function does not make the connections between blocks, it simply traverses the + * static connections. + * + * \param graph The rfnoc_graph that is being examined + * \param start_block The block we begin to build the chain from + * \param port The block port of `src_port` that the path will begin at + * \param source_block Whether or not the `start_block` is a source (or a destination). + * If true, the chain will start at `start_block`'s output port. If + * false, the chain will start with `start_block`'s output port. + * \return The edge list representing the data path requested + */ +std::vector UHD_API get_block_chain(const rfnoc_graph::sptr graph, + const block_id_t start_block, + const size_t port, + const bool source_chain); + + +/*! Connect desired blocks by whatever path that can be found + * + * \param src_blk Source block's ID + * \param src_port Block port where the path starts + * \param dst_blk Destination block's ID + * \param dst_port Block port where the path ends + */ +void UHD_API connect_through_blocks(rfnoc_graph::sptr graph, + const block_id_t src_blk, + const size_t src_port, + const block_id_t dst_blk, + const size_t dst_port); + +}} // namespace uhd::rfnoc + +#endif /* INCLUDED_UHD_UTILS_GRAPH_UTILS_HPP */ -- cgit v1.2.3