aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-11-25 14:37:59 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2021-12-01 13:34:35 -0800
commitbc6b4539630e4a61eeff70d0f6f6395944712b31 (patch)
tree6995cc4555c17714f0fa487b303b44cb81f5e68a /host/lib/utils
parent6fd9f37e1cc16bedaafbbf3f013e78bb4869de6c (diff)
downloaduhd-bc6b4539630e4a61eeff70d0f6f6395944712b31.tar.gz
uhd-bc6b4539630e4a61eeff70d0f6f6395944712b31.tar.bz2
uhd-bc6b4539630e4a61eeff70d0f6f6395944712b31.zip
rfnoc: Fix issue in uhd::rfnoc::connect_through_blocks()
When connect_through_blocks() was called on blocks within a single chain, there was a bug where the chain was incorrectly cropped. In a standard FPGA image, say one was to use this API call to connect the radio to the DDC. It would generate a chain of blocks hanging off the radio as such: Radio -> DDC -> SEP What the code should do, and what this fix provides, is that the chain gets cropped after the DDC, to look like this: Radio -> DDC With the current bug, it would assume the chain has a dangling edge, and incorrectly throw an exception. Note that this bug would not appear when source and destination block are on separate chains (i.e., both have an SEP in their chain). This patch includes minor logging and comment improvements around the offending lines of code.
Diffstat (limited to 'host/lib/utils')
-rw-r--r--host/lib/utils/graph_utils.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/host/lib/utils/graph_utils.cpp b/host/lib/utils/graph_utils.cpp
index f21000ccf..513f7b709 100644
--- a/host/lib/utils/graph_utils.cpp
+++ b/host/lib/utils/graph_utils.cpp
@@ -56,7 +56,7 @@ std::vector<graph_edge_t> get_block_chain(const rfnoc_graph::sptr graph,
// If the current block is the edge's source, make the edge's
// destination the current block
next_found = true;
- UHD_LOG_TRACE("GRAPH_UTILS", "Found next block: " + edge.dst_blockid);
+ UHD_LOG_TRACE("GRAPH_UTILS", " --> Found next block: " + edge.dst_blockid);
block_chain.push_back(edge);
current_block = (source_chain) ? edge.dst_blockid : edge.src_blockid;
@@ -103,12 +103,14 @@ void connect_through_blocks(rfnoc_graph::sptr graph,
|| (dst_blk.to_string() == edge.dst_blockid
&& dst_port == edge.dst_port);
});
- // If our dst_blk is in the chain already, make sure its the last element and continue
if (dst_found) {
+ // If our dst_blk is in the chain already, make sure it's the last element
+ // and continue. This means we pop everything from block_chain that comes
+ // after our block.
UHD_LOG_TRACE(
"GRAPH_UTILS", "Found dst_blk (" + dst_blk.to_string() + ") in source chain");
- while (dst_blk.to_string() == block_chain.back().dst_blockid
- && dst_port == block_chain.back().dst_port) {
+ while (dst_blk.to_string() != block_chain.back().dst_blockid
+ || dst_port != block_chain.back().dst_port) {
UHD_LOG_TRACE("GRAPH_UTILS",
boost::format(
"Last block (%s:%d) doesn't match dst_blk (%s:%d); removing.")
@@ -153,8 +155,9 @@ void connect_through_blocks(rfnoc_graph::sptr graph,
if (has_src_to_sep_connection && has_sep_to_dst_connection) {
graph->connect(src_to_sep_id, src_to_sep_port, sep_to_dst_id, sep_to_dst_port);
} else if (has_src_to_sep_connection != has_sep_to_dst_connection) {
- throw uhd::runtime_error(
- "[graph_utils] Incomplete path. Only one SEP edge found.");
+ const std::string err_msg = "Incomplete path. Only one SEP edge found.";
+ UHD_LOG_TRACE("GRAPH_UTILS", err_msg);
+ throw uhd::runtime_error("[graph_utils] " + err_msg);
}
}