From 4574063639a3aa5389005f646577d5644f72d5d3 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 9 Jun 2021 14:54:23 +0200 Subject: multi_usrp: Factor out make_overall_tune_range() and fix limits This function had an issue where it might return negative frequency values. A quick fix was to limit it to positive frequencies. Since this function was duplicated between multi_usrp and multi_usrp_rfnoc, this patch also moves it to a common location to not have to fix it twice. --- host/lib/include/uhdlib/usrp/multi_usrp_utils.hpp | 37 +++++++++++++++++++++++ host/lib/usrp/multi_usrp.cpp | 20 +----------- host/lib/usrp/multi_usrp_rfnoc.cpp | 24 +-------------- 3 files changed, 39 insertions(+), 42 deletions(-) create mode 100644 host/lib/include/uhdlib/usrp/multi_usrp_utils.hpp diff --git a/host/lib/include/uhdlib/usrp/multi_usrp_utils.hpp b/host/lib/include/uhdlib/usrp/multi_usrp_utils.hpp new file mode 100644 index 000000000..40c360339 --- /dev/null +++ b/host/lib/include/uhdlib/usrp/multi_usrp_utils.hpp @@ -0,0 +1,37 @@ +// +// Copyright 2021 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +#include + +namespace uhd { + +/*! Create a total tune range for multi_usrp objects + * + * Digital tuning can be used to shift the baseband below / past the tunable + * limits of the actual RF front-end. The baseband filter, located on the + * daughterboard, however, limits the useful instantaneous bandwidth. We + * allow the user to tune to the edge of the filter, where the roll-off + * begins. This prevents the user from tuning past the point where less + * than half of the spectrum would be useful. + * Also, we make sure that frequencies don't become negative. + */ +static meta_range_t make_overall_tune_range( + const meta_range_t& fe_range, const meta_range_t& dsp_range, const double bw) +{ + meta_range_t range; + for (const range_t& sub_range : fe_range) { + range.push_back(range_t( + std::max(0.0, sub_range.start() + std::max(dsp_range.start(), -bw / 2)), + sub_range.stop() + std::min(dsp_range.stop(), bw / 2), + dsp_range.step())); + } + return range; +} + + +} // namespace uhd diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index bb5b9e5fc..048db0d35 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -190,25 +191,6 @@ clipped:\n" " Target Frequency: %f MHz\n" " Clipped Target Frequency: %f M } }*/ -/*! The CORDIC can be used to shift the baseband below / past the tunable - * limits of the actual RF front-end. The baseband filter, located on the - * daughterboard, however, limits the useful instantaneous bandwidth. We - * allow the user to tune to the edge of the filter, where the roll-off - * begins. This prevents the user from tuning past the point where less - * than half of the spectrum would be useful. */ -static meta_range_t make_overall_tune_range( - const meta_range_t& fe_range, const meta_range_t& dsp_range, const double bw) -{ - meta_range_t range; - for (const range_t& sub_range : fe_range) { - range.push_back(range_t(sub_range.start() + std::max(dsp_range.start(), -bw / 2), - sub_range.stop() + std::min(dsp_range.stop(), bw / 2), - dsp_range.step())); - } - return range; -} - - /*********************************************************************** * Gain helper functions **********************************************************************/ diff --git a/host/lib/usrp/multi_usrp_rfnoc.cpp b/host/lib/usrp/multi_usrp_rfnoc.cpp index f87e52190..8a11be122 100644 --- a/host/lib/usrp/multi_usrp_rfnoc.cpp +++ b/host/lib/usrp/multi_usrp_rfnoc.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -441,29 +442,6 @@ public: } - /*********************************************************************** - * Helper methods - **********************************************************************/ - /*! The CORDIC can be used to shift the baseband below / past the tunable - * limits of the actual RF front-end. The baseband filter, located on the - * daughterboard, however, limits the useful instantaneous bandwidth. We - * allow the user to tune to the edge of the filter, where the roll-off - * begins. This prevents the user from tuning past the point where less - * than half of the spectrum would be useful. - */ - static meta_range_t make_overall_tune_range( - const meta_range_t& fe_range, const meta_range_t& dsp_range, const double bw) - { - meta_range_t range; - for (const range_t& sub_range : fe_range) { - range.push_back( - range_t(sub_range.start() + std::max(dsp_range.start(), -bw / 2), - sub_range.stop() + std::min(dsp_range.stop(), bw / 2), - dsp_range.step())); - } - return range; - } - dict get_usrp_rx_info(size_t chan) override { auto& rx_chain = _get_rx_chan(chan); -- cgit v1.2.3