diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/graph.hpp | 7 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/node_accessor.hpp | 11 | ||||
-rw-r--r-- | host/lib/rfnoc/graph.cpp | 36 | ||||
-rw-r--r-- | host/lib/rfnoc/node.cpp | 17 |
4 files changed, 71 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/graph.hpp b/host/lib/include/uhdlib/rfnoc/graph.hpp index 49dc62551..4b08b5842 100644 --- a/host/lib/include/uhdlib/rfnoc/graph.hpp +++ b/host/lib/include/uhdlib/rfnoc/graph.hpp @@ -236,6 +236,13 @@ private: */ bool _assert_edge_props_consistent(rfnoc_graph_t::edge_descriptor edge); + /*! Query all blocks on their topology + * + * \throws uhd::runtime_error if any of the blocks doesn't like its + * configuration + */ + void _check_topology(); + /************************************************************************** * Attributes *************************************************************************/ diff --git a/host/lib/include/uhdlib/rfnoc/node_accessor.hpp b/host/lib/include/uhdlib/rfnoc/node_accessor.hpp index 827c87dd2..3351c5531 100644 --- a/host/lib/include/uhdlib/rfnoc/node_accessor.hpp +++ b/host/lib/include/uhdlib/rfnoc/node_accessor.hpp @@ -97,6 +97,17 @@ public: { node->receive_action(port_info, action); } + + /*! Check topology for this block + * + * See node_t::check_topology() for details + */ + bool check_topology(node_t* node, + const std::vector<size_t>& connected_inputs, + const std::vector<size_t>& connected_outputs) + { + return node->check_topology(connected_inputs, connected_outputs); + } }; diff --git a/host/lib/rfnoc/graph.cpp b/host/lib/rfnoc/graph.cpp index f687e8984..cbb7ab140 100644 --- a/host/lib/rfnoc/graph.cpp +++ b/host/lib/rfnoc/graph.cpp @@ -177,6 +177,7 @@ void graph_t::commit() { if (_release_count) { _release_count--; + _check_topology(); } UHD_LOG_TRACE(LOG_ID, "graph::commit() => " << _release_count.load()); resolve_all_properties(); @@ -524,6 +525,41 @@ bool graph_t::_assert_edge_props_consistent(rfnoc_graph_t::edge_descriptor edge) return props_match; } +void graph_t::_check_topology() +{ + node_accessor_t node_accessor{}; + bool topo_ok = true; + auto v_iterators = boost::vertices(_graph); + for (auto it = v_iterators.first; it != v_iterators.second; ++it) { + node_ref_t node = boost::get(vertex_property_t(), _graph, *it); + std::vector<size_t> connected_inputs; + std::vector<size_t> connected_outputs; + auto ie_iters = boost::in_edges(*it, _graph); + for (auto it = ie_iters.first; it != ie_iters.second; ++it) { + graph_edge_t edge_info = boost::get(edge_property_t(), _graph, *it); + connected_inputs.push_back(edge_info.dst_port); + } + auto oe_iters = boost::out_edges(*it, _graph); + for (auto it = oe_iters.first; it != oe_iters.second; ++it) { + graph_edge_t edge_info = boost::get(edge_property_t(), _graph, *it); + connected_outputs.push_back(edge_info.src_port); + } + + if (!node_accessor.check_topology(node, connected_inputs, connected_outputs)) { + UHD_LOG_ERROR(LOG_ID, + "Node " << node->get_unique_id() + << "cannot handle its current topology! (" + << connected_inputs.size() << "inputs, " + << connected_outputs.size() << " outputs)"); + topo_ok = false; + } + } + + if (!topo_ok) { + throw uhd::runtime_error("Graph topology is not valid!"); + } +} + std::pair<graph_t::node_ref_t, graph_t::graph_edge_t> graph_t::_find_neighbour( rfnoc_graph_t::vertex_descriptor origin, res_source_info port_info) { diff --git a/host/lib/rfnoc/node.cpp b/host/lib/rfnoc/node.cpp index 33649b23f..7eff22eab 100644 --- a/host/lib/rfnoc/node.cpp +++ b/host/lib/rfnoc/node.cpp @@ -154,6 +154,23 @@ void node_t::post_action( _post_action_cb(edge_info, action); } +bool node_t::check_topology(const std::vector<size_t>& connected_inputs, + const std::vector<size_t>& connected_outputs) +{ + for (size_t port : connected_inputs) { + if (port >= get_num_input_ports()) { + return false; + } + } + for (size_t port : connected_outputs) { + if (port >= get_num_output_ports()) { + return false; + } + } + + return true; +} + /*** Private methods *********************************************************/ property_base_t* node_t::_find_property( res_source_info src_info, const std::string& id) const |