aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/cores
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/cores
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/cores')
-rw-r--r--host/lib/usrp/cores/dsp_core_utils.cpp4
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_200.cpp5
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_3000.cpp5
-rw-r--r--host/lib/usrp/cores/rx_frontend_core_200.cpp8
-rw-r--r--host/lib/usrp/cores/rx_frontend_core_3000.cpp8
-rw-r--r--host/lib/usrp/cores/tx_dsp_core_200.cpp5
-rw-r--r--host/lib/usrp/cores/tx_dsp_core_3000.cpp5
-rw-r--r--host/lib/usrp/cores/tx_frontend_core_200.cpp8
8 files changed, 22 insertions, 26 deletions
diff --git a/host/lib/usrp/cores/dsp_core_utils.cpp b/host/lib/usrp/cores/dsp_core_utils.cpp
index a96028d65..2e99cde4d 100644
--- a/host/lib/usrp/cores/dsp_core_utils.cpp
+++ b/host/lib/usrp/cores/dsp_core_utils.cpp
@@ -8,8 +8,8 @@
#include <uhd/exception.hpp>
#include <uhd/utils/math.hpp>
#include <uhdlib/usrp/cores/dsp_core_utils.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <boost/math/special_functions/sign.hpp>
+#include <cmath>
static const int32_t MAX_FREQ_WORD = boost::numeric::bounds<int32_t>::highest();
static const int32_t MIN_FREQ_WORD = boost::numeric::bounds<int32_t>::lowest();
@@ -47,7 +47,7 @@ void get_freq_and_freq_word(const double requested_freq,
} else {
/* The operation is safe. Perform normally. */
- freq_word = int32_t(boost::math::round((freq / tick_rate) * scale_factor));
+ freq_word = int32_t(std::lround((freq / tick_rate) * scale_factor));
}
actual_freq = (double(freq_word) / scale_factor) * tick_rate;
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp
index 5e2c3804f..f5d31a374 100644
--- a/host/lib/usrp/cores/rx_dsp_core_200.cpp
+++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp
@@ -13,7 +13,6 @@
#include <uhdlib/usrp/cores/dsp_core_utils.hpp>
#include <uhdlib/usrp/cores/rx_dsp_core_200.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <boost/numeric/conversion/bounds.hpp>
#include <algorithm>
#include <chrono>
@@ -186,7 +185,7 @@ public:
double set_host_rate(const double rate) override
{
const size_t decim_rate =
- boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true));
+ std::lround(_tick_rate / this->get_host_rates().clip(rate, true));
size_t decim = decim_rate;
// determine which half-band filters are activated
@@ -229,7 +228,7 @@ public:
const double factor = 1.0 + std::max(ceil_log2(_scaling_adjustment), 0.0);
const double target_scalar =
(1 << 17) * _scaling_adjustment / _dsp_extra_scaling / factor;
- const int32_t actual_scalar = boost::math::iround(target_scalar);
+ const int32_t actual_scalar = static_cast<int32_t>(std::lround(target_scalar));
_fxpt_scalar_correction =
target_scalar / actual_scalar * factor; // should be small
_iface->poke32(REG_DSP_RX_SCALE_IQ, actual_scalar);
diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.cpp b/host/lib/usrp/cores/rx_dsp_core_3000.cpp
index ff431fd41..9b7013cea 100644
--- a/host/lib/usrp/cores/rx_dsp_core_3000.cpp
+++ b/host/lib/usrp/cores/rx_dsp_core_3000.cpp
@@ -13,7 +13,6 @@
#include <uhdlib/usrp/cores/dsp_core_utils.hpp>
#include <uhdlib/usrp/cores/rx_dsp_core_3000.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <algorithm>
#include <cmath>
#include <functional>
@@ -136,7 +135,7 @@ public:
double set_host_rate(const double rate) override
{
const size_t decim_rate =
- boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true));
+ std::lround(_tick_rate / this->get_host_rates().clip(rate, true));
size_t decim = decim_rate;
// determine which half-band filters are activated
@@ -228,7 +227,7 @@ public:
{
const double target_scalar =
(1 << (_is_b200 ? 16 : 15)) * _scaling_adjustment / _dsp_extra_scaling;
- const int32_t actual_scalar = boost::math::iround(target_scalar);
+ const int32_t actual_scalar = static_cast<int32_t>(std::lround(target_scalar));
// Calculate the error introduced by using integer representation for the scalar,
// can be corrected in host later.
_fxpt_scalar_correction = target_scalar / actual_scalar;
diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp
index d96672da4..e9830e29f 100644
--- a/host/lib/usrp/cores/rx_frontend_core_200.cpp
+++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp
@@ -7,7 +7,7 @@
#include <uhd/types/ranges.hpp>
#include <uhdlib/usrp/cores/rx_frontend_core_200.hpp>
-#include <boost/math/special_functions/round.hpp>
+#include <cmath>
#include <functional>
using namespace uhd;
@@ -29,7 +29,7 @@ static const double DC_OFFSET_MAX = 1.0;
static uint32_t fs_to_bits(const double num, const size_t bits)
{
- return int32_t(boost::math::round(num * (1 << (bits - 1))));
+ return int32_t(std::lround(num * (1 << (bits - 1))));
}
rx_frontend_core_200::~rx_frontend_core_200(void)
@@ -65,8 +65,8 @@ public:
std::complex<double> set_dc_offset(const std::complex<double>& off) override
{
static const double scaler = double(1ul << 29);
- _i_dc_off = boost::math::iround(off.real() * scaler);
- _q_dc_off = boost::math::iround(off.imag() * scaler);
+ _i_dc_off = static_cast<int32_t>(std::lround(off.real() * scaler));
+ _q_dc_off = static_cast<int32_t>(std::lround(off.imag() * scaler));
this->set_dc_offset(OFFSET_SET | OFFSET_FIXED);
diff --git a/host/lib/usrp/cores/rx_frontend_core_3000.cpp b/host/lib/usrp/cores/rx_frontend_core_3000.cpp
index abbe64b13..2424783e3 100644
--- a/host/lib/usrp/cores/rx_frontend_core_3000.cpp
+++ b/host/lib/usrp/cores/rx_frontend_core_3000.cpp
@@ -11,7 +11,7 @@
#include <uhdlib/usrp/cores/dsp_core_utils.hpp>
#include <uhdlib/usrp/cores/rx_frontend_core_3000.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/math/special_functions/round.hpp>
+#include <cmath>
#include <functional>
using namespace uhd;
@@ -45,7 +45,7 @@ using namespace uhd::usrp;
static uint32_t fs_to_bits(const double num, const size_t bits)
{
- return int32_t(boost::math::round(num * (1 << (bits - 1))));
+ return int32_t(std::lround(num * (1 << (bits - 1))));
}
rx_frontend_core_3000::~rx_frontend_core_3000(void)
@@ -151,8 +151,8 @@ public:
std::complex<double> set_dc_offset(const std::complex<double>& off) override
{
static const double scaler = double(1ul << 29);
- _i_dc_off = boost::math::iround(off.real() * scaler);
- _q_dc_off = boost::math::iround(off.imag() * scaler);
+ _i_dc_off = static_cast<int32_t>(std::lround(off.real() * scaler));
+ _q_dc_off = static_cast<int32_t>(std::lround(off.imag() * scaler));
_set_dc_offset(OFFSET_SET | OFFSET_FIXED);
diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp
index 1c743b0b0..e38938863 100644
--- a/host/lib/usrp/cores/tx_dsp_core_200.cpp
+++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp
@@ -12,7 +12,6 @@
#include <uhdlib/usrp/cores/dsp_core_utils.hpp>
#include <uhdlib/usrp/cores/tx_dsp_core_200.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <algorithm>
#include <chrono>
#include <cmath>
@@ -118,7 +117,7 @@ public:
double set_host_rate(const double rate) override
{
const size_t interp_rate =
- boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true));
+ std::lround(_tick_rate / this->get_host_rates().clip(rate, true));
size_t interp = interp_rate;
// determine which half-band filters are activated
@@ -159,7 +158,7 @@ public:
const double factor = 1.0 + std::max(ceil_log2(_scaling_adjustment), 0.0);
const double target_scalar =
(1 << 17) * _scaling_adjustment / _dsp_extra_scaling / factor;
- const int32_t actual_scalar = boost::math::iround(target_scalar);
+ const int32_t actual_scalar = static_cast<int32_t>(std::lround(target_scalar));
_fxpt_scalar_correction =
target_scalar / actual_scalar * factor; // should be small
_iface->poke32(REG_DSP_TX_SCALE_IQ, actual_scalar);
diff --git a/host/lib/usrp/cores/tx_dsp_core_3000.cpp b/host/lib/usrp/cores/tx_dsp_core_3000.cpp
index f46938de3..b7f5614a7 100644
--- a/host/lib/usrp/cores/tx_dsp_core_3000.cpp
+++ b/host/lib/usrp/cores/tx_dsp_core_3000.cpp
@@ -12,7 +12,6 @@
#include <uhdlib/usrp/cores/dsp_core_utils.hpp>
#include <uhdlib/usrp/cores/tx_dsp_core_3000.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <algorithm>
#include <cmath>
#include <functional>
@@ -76,7 +75,7 @@ public:
double set_host_rate(const double rate) override
{
const size_t interp_rate =
- boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true));
+ std::lround(_tick_rate / this->get_host_rates().clip(rate, true));
size_t interp = interp_rate;
// determine which half-band filters are activated
@@ -123,7 +122,7 @@ public:
void update_scalar(void)
{
const double target_scalar = (1 << 16) * _scaling_adjustment / _dsp_extra_scaling;
- const int32_t actual_scalar = boost::math::iround(target_scalar);
+ const int32_t actual_scalar = static_cast<int32_t>(std::lround(target_scalar));
_fxpt_scalar_correction = target_scalar / actual_scalar; // should be small
_iface->poke32(REG_DSP_TX_SCALE_IQ, actual_scalar);
}
diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp
index 45b2045dd..000f47977 100644
--- a/host/lib/usrp/cores/tx_frontend_core_200.cpp
+++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp
@@ -10,7 +10,7 @@
#include <uhd/types/ranges.hpp>
#include <uhdlib/usrp/cores/tx_frontend_core_200.hpp>
#include <boost/assign/list_of.hpp>
-#include <boost/math/special_functions/round.hpp>
+#include <cmath>
#include <functional>
using namespace uhd;
@@ -33,7 +33,7 @@ static const double DC_OFFSET_MAX = 1.0;
static uint32_t fs_to_bits(const double num, const size_t bits)
{
- return int32_t(boost::math::round(num * (1 << (bits - 1))));
+ return int32_t(std::lround(num * (1 << (bits - 1))));
}
tx_frontend_core_200::~tx_frontend_core_200(void)
@@ -66,8 +66,8 @@ public:
std::complex<double> set_dc_offset(const std::complex<double>& off) override
{
static const double scaler = double(1ul << 23);
- const int32_t i_dc_off = boost::math::iround(off.real() * scaler);
- const int32_t q_dc_off = boost::math::iround(off.imag() * scaler);
+ const int32_t i_dc_off = static_cast<int>(std::lround(off.real() * scaler));
+ const int32_t q_dc_off = static_cast<int>(std::lround(off.imag() * scaler));
_iface->poke32(REG_TX_FE_DC_OFFSET_I, i_dc_off);
_iface->poke32(REG_TX_FE_DC_OFFSET_Q, q_dc_off);