aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-06-19 00:06:52 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2021-06-24 12:00:49 -0500
commit188fbb17cfd18c87f60ec56f62476f97ef2779bb (patch)
treee88b9fb8436aa42f3ecbdc0403751a3e68bbbac8 /host/lib/usrp/usrp1
parent78ec29b6becd53f79a0ae282ae22c38bedb887d1 (diff)
downloaduhd-188fbb17cfd18c87f60ec56f62476f97ef2779bb.tar.gz
uhd-188fbb17cfd18c87f60ec56f62476f97ef2779bb.tar.bz2
uhd-188fbb17cfd18c87f60ec56f62476f97ef2779bb.zip
uhd: Remove all occurences of boost::math::*round()
Its behaviour is almost identical to std::lround, which we use instead. The only downside of std::lround is that it always returns a long, which we don't always need. We thus add some casts for those cases to make the compiler happy.
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp13
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp8
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp6
3 files changed, 15 insertions, 12 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index ca5503132..413caaf67 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -13,11 +13,12 @@
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/log.hpp>
#include <uhd/utils/safe_call.hpp>
-#include <stdint.h>
+#include <uhdlib/utils/narrow.hpp>
+#include <cstdint>
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <boost/math/special_functions/sign.hpp>
+#include <cmath>
#include <iomanip>
#include <tuple>
@@ -257,7 +258,8 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)
{
// special case for aux dac d (aka sigma delta word)
if (which == AUX_DAC_D) {
- uint16_t dac_word = uhd::clip(boost::math::iround(volts * 0xfff / 3.3), 0, 0xfff);
+ uint16_t dac_word = uhd::clip(
+ uhd::narrow_cast<int>(std::lround(volts * 0xfff / 3.3)), 0, 0xfff);
_ad9862_regs.sig_delt_11_4 = uint8_t(dac_word >> 4);
_ad9862_regs.sig_delt_3_0 = uint8_t(dac_word & 0xf);
this->send_reg(42);
@@ -266,7 +268,8 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)
}
// calculate the dac word for aux dac a, b, c
- uint8_t dac_word = uhd::clip(boost::math::iround(volts * 0xff / 3.3), 0, 0xff);
+ uint8_t dac_word =
+ uhd::clip(uhd::narrow_cast<int>(std::lround(volts * 0xff / 3.3)), 0, 0xff);
// setup a lookup table for the aux dac params (reg ref, reg addr)
typedef std::tuple<uint8_t*, uint8_t> dac_params_t;
@@ -356,7 +359,7 @@ double usrp1_codec_ctrl_impl::fine_tune(double codec_rate, double target_freq)
static const double scale_factor = std::pow(2.0, 24);
uint32_t freq_word =
- uint32_t(boost::math::round(std::abs((target_freq / codec_rate) * scale_factor)));
+ uint32_t(std::lround(std::abs((target_freq / codec_rate) * scale_factor)));
double actual_freq = freq_word * codec_rate / scale_factor;
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index b93cfa094..5d7b4a77b 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -17,11 +17,11 @@
#include <uhd/utils/safe_call.hpp>
#include <uhd/utils/tasks.hpp>
#include <boost/format.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <boost/math/special_functions/sign.hpp>
#include <boost/thread/thread.hpp>
#include <atomic>
#include <chrono>
+#include <cmath>
#include <functional>
#include <memory>
#include <thread>
@@ -517,7 +517,7 @@ uhd::meta_range_t usrp1_impl::get_tx_dsp_host_rates(void)
double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate)
{
const size_t div = this->has_rx_halfband() ? 2 : 1;
- const size_t rate = boost::math::iround(
+ const size_t rate = std::lround(
_master_clock_rate / this->get_rx_dsp_host_rates().clip(samp_rate, true));
if (rate < 8 and this->has_rx_halfband())
@@ -548,7 +548,7 @@ double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate)
double usrp1_impl::update_tx_samp_rate(size_t dspno, const double samp_rate)
{
const size_t div = this->has_tx_halfband() ? 4 : 2; // doubled for codec interp
- const size_t rate = boost::math::iround(
+ const size_t rate = std::lround(
_master_clock_rate / this->get_tx_dsp_host_rates().clip(samp_rate, true));
if (dspno == 0) { // only care if dsp0 is set since its homogeneous
@@ -591,7 +591,7 @@ double usrp1_impl::update_rx_dsp_freq(const size_t dspno, const double freq_)
UHD_ASSERT_THROW(std::abs(freq) <= _master_clock_rate / 2.0);
static const double scale_factor = std::pow(2.0, 32);
const int32_t freq_word =
- int32_t(boost::math::round((freq / _master_clock_rate) * scale_factor));
+ int32_t(std::lround((freq / _master_clock_rate) * scale_factor));
static const uint32_t dsp_index_to_reg_val[4] = {
FR_RX_FREQ_0, FR_RX_FREQ_1, FR_RX_FREQ_2, FR_RX_FREQ_3};
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 6ed1a6a69..d88b6af8e 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -16,8 +16,8 @@
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <chrono>
+#include <cmath>
#include <cstdio>
#include <functional>
@@ -533,8 +533,8 @@ void usrp1_impl::set_enb_rx_dc_offset(const std::string& db, const bool enb)
std::complex<double> usrp1_impl::set_rx_dc_offset(
const std::string& db, const std::complex<double>& offset)
{
- const int32_t i_off = boost::math::iround(offset.real() * (1ul << 31));
- const int32_t q_off = boost::math::iround(offset.imag() * (1ul << 31));
+ const int32_t i_off = static_cast<int32_t>(std::lround(offset.real() * (1ul << 31)));
+ const int32_t q_off = static_cast<int32_t>(std::lround(offset.imag() * (1ul << 31)));
if (db == "A") {
_iface->poke32(FR_ADC_OFFSET_0, i_off);