aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/graph_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/rfnoc/graph_impl.cpp')
-rw-r--r--host/lib/rfnoc/graph_impl.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/host/lib/rfnoc/graph_impl.cpp b/host/lib/rfnoc/graph_impl.cpp
index be2a4c505..f715c0b65 100644
--- a/host/lib/rfnoc/graph_impl.cpp
+++ b/host/lib/rfnoc/graph_impl.cpp
@@ -160,3 +160,76 @@ void graph_impl::connect(
connect(src_block, ANY_PORT, dst_block, ANY_PORT);
}
+void graph_impl::connect_src(
+ const block_id_t &src_block,
+ const size_t src_block_port,
+ const uhd::sid_t dst_sid,
+ const size_t buf_size_dst_bytes,
+ const size_t pkt_size_
+) {
+ device3::sptr device_ptr = _device_ptr.lock();
+ if (not device_ptr) {
+ throw uhd::runtime_error("Invalid device");
+ }
+
+ UHD_LOGGER_DEBUG("RFNOC")
+ << "[" << _name << "] Connecting "
+ << src_block << ":" << src_block_port << " --> "
+ << dst_sid.to_pp_string_hex();
+
+ uhd::rfnoc::source_block_ctrl_base::sptr src =
+ device_ptr->get_block_ctrl<rfnoc::source_block_ctrl_base>(src_block);
+
+ src->set_destination(dst_sid.get(), src_block_port);
+
+ size_t pkt_size = (pkt_size_ != 0)
+ ? pkt_size_
+ : src->get_output_signature(src_block_port).packet_size;
+ if (pkt_size == 0) { // Unspecified packet rate. Assume max packet size.
+ UHD_LOGGER_WARNING("RFNOC")
+ << "Assuming max packet size for " << src->get_block_id();
+ pkt_size = uhd::rfnoc::MAX_PACKET_SIZE;
+ }
+ size_t buf_size_pkts = buf_size_dst_bytes / pkt_size;
+ if (buf_size_pkts == 0) {
+ throw uhd::runtime_error(str(
+ boost::format("Input FIFO for unknown destination is too small "
+ "(%d kiB) for packets of size %d kiB\n coming from "
+ "block %s.")
+ % (buf_size_dst_bytes / 1024)
+ % (pkt_size / 1024)
+ % src->get_block_id().get()
+ ));
+ }
+ src->configure_flow_control_out(buf_size_pkts, src_block_port);
+
+}
+
+void graph_impl::connect_sink(
+ const block_id_t &sink_block,
+ const size_t dst_block_port,
+ const size_t pkts_per_ack
+) {
+ device3::sptr device_ptr = _device_ptr.lock();
+ if (not device_ptr) {
+ throw uhd::runtime_error("Invalid device");
+ }
+
+ UHD_LOGGER_DEBUG("RFNOC")
+ << "[" << _name << "] Connecting unknown source to"
+ << sink_block << ":" << dst_block_port;
+
+ uhd::rfnoc::sink_block_ctrl_base::sptr dst =
+ device_ptr->get_block_ctrl<rfnoc::sink_block_ctrl_base>(sink_block);
+ dst->configure_flow_control_in(
+ 0,
+ pkts_per_ack,
+ dst_block_port
+ );
+
+ /********************************************************************
+ * 5. Configure error policy
+ ********************************************************************/
+ dst->set_error_policy("next_burst");
+
+}