From 188fbb17cfd18c87f60ec56f62476f97ef2779bb Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 19 Jun 2021 00:06:52 +0200 Subject: 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. --- host/lib/usrp/dboard/db_xcvr2450.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'host/lib/usrp/dboard/db_xcvr2450.cpp') diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 26c0d5950..b6b8858e7 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -50,10 +50,11 @@ #include #include #include +#include #include #include -#include #include +#include #include #include #include @@ -410,7 +411,7 @@ double xcvr2450::set_lo_freq_core(double target_freq) for (R = 1; R <= 7; R++) { double N = (target_freq * scaler * R * _ad9515div) / ref_freq; intdiv = int(std::floor(N)); - fracdiv = boost::math::iround((N - intdiv) * double(1 << 16)); + fracdiv = uhd::narrow_cast(std::lround((N - intdiv)) * double(1 << 16)); // actual minimum is 128, but most chips seems to require higher to lock if (intdiv < 131 or intdiv > 255) continue; @@ -504,7 +505,7 @@ void xcvr2450::set_rx_ant(const std::string& ant) static int gain_to_tx_vga_reg(double& gain) { // calculate the register value - int reg = uhd::clip(boost::math::iround(gain * 60 / 30.0) + 3, 0, 63); + int reg = uhd::clip(uhd::narrow_cast(std::lround(gain * 60 / 30.0) + 3), 0, 63); // calculate the actual gain value if (reg < 4) @@ -526,7 +527,7 @@ static int gain_to_tx_vga_reg(double& gain) */ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double& gain) { - int reg = uhd::clip(boost::math::iround(gain * 3 / 5.0), 0, 3); + int reg = uhd::clip(uhd::narrow_cast(std::lround(gain * 3 / 5.0)), 0, 3); switch (reg) { case 0: gain = 0; @@ -552,7 +553,7 @@ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double& gain) */ static int gain_to_rx_vga_reg(double& gain) { - int reg = uhd::clip(boost::math::iround(gain / 2.0), 0, 31); + int reg = uhd::clip(uhd::narrow_cast(std::lround(gain / 2.0)), 0, 31); gain = double(reg * 2); return reg; } @@ -565,7 +566,7 @@ static int gain_to_rx_vga_reg(double& gain) */ static int gain_to_rx_lna_reg(double& gain) { - int reg = uhd::clip(boost::math::iround(gain * 2 / 30.5) + 1, 0, 3); + int reg = uhd::clip(uhd::narrow_cast(std::lround(gain * 2 / 30.5)) + 1, 0, 3); switch (reg) { case 0: case 1: @@ -620,7 +621,7 @@ double xcvr2450::set_rx_gain(double gain, const std::string& name) static max2829_regs_t::tx_lpf_coarse_adj_t bandwidth_to_tx_lpf_coarse_reg( double& bandwidth) { - int reg = uhd::clip(boost::math::iround((bandwidth - 6.0e6) / 6.0e6), 1, 3); + int reg = uhd::clip(uhd::narrow_cast(std::lround((bandwidth - 6.0e6)) / 6.0e6), 1, 3); switch (reg) { case 1: // bandwidth < 15MHz @@ -639,8 +640,10 @@ static max2829_regs_t::tx_lpf_coarse_adj_t bandwidth_to_tx_lpf_coarse_reg( static max2829_regs_t::rx_lpf_fine_adj_t bandwidth_to_rx_lpf_fine_reg( double& bandwidth, double requested_bandwidth) { - int reg = - uhd::clip(boost::math::iround((requested_bandwidth / bandwidth) / 0.05), 18, 22); + int reg = uhd::clip( + uhd::narrow_cast(std::lround((requested_bandwidth / bandwidth)) / 0.05), + 18, + 22); switch (reg) { case 18: // requested_bandwidth < 92.5% @@ -665,7 +668,8 @@ static max2829_regs_t::rx_lpf_fine_adj_t bandwidth_to_rx_lpf_fine_reg( static max2829_regs_t::rx_lpf_coarse_adj_t bandwidth_to_rx_lpf_coarse_reg( double& bandwidth) { - int reg = uhd::clip(boost::math::iround((bandwidth - 7.0e6) / 1.0e6), 0, 11); + int reg = + uhd::clip(uhd::narrow_cast(std::lround((bandwidth - 7.0e6)) / 1.0e6), 0, 11); switch (reg) { case 0: // bandwidth < 7.5MHz -- cgit v1.2.3