diff options
author | Josh Blum <josh@joshknows.com> | 2011-11-03 20:34:06 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-03 20:37:14 -0700 |
commit | 07fb8d2b82c59ddaf7722b12db8c1387011fb34b (patch) | |
tree | b6c37b7ef0db85293e418ffd3d1b3376a520da14 | |
parent | 5cdbf5b36969e12b93e720f67102dd4ab246b074 (diff) | |
download | uhd-07fb8d2b82c59ddaf7722b12db8c1387011fb34b.tar.gz uhd-07fb8d2b82c59ddaf7722b12db8c1387011fb34b.tar.bz2 uhd-07fb8d2b82c59ddaf7722b12db8c1387011fb34b.zip |
usrp: fix rate calculation logic
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.cpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_dsp_core_200.cpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/io_impl.cpp | 6 | ||||
-rw-r--r-- | host/tests/ranges_test.cpp | 13 |
4 files changed, 17 insertions, 8 deletions
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index 6d306d507..b97f9c58e 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -149,8 +149,7 @@ public: } double set_host_rate(const double rate){ - const size_t decim_rate = this->get_host_rates().clip( - boost::math::iround(_tick_rate/rate), true); + const size_t decim_rate = boost::math::iround(_tick_rate/this->get_host_rates().clip(rate, true)); size_t decim = decim_rate; //determine which half-band filters are activated diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp index 1d571ea7c..9d90d30cc 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -89,8 +89,7 @@ public: } double set_host_rate(const double rate){ - const size_t interp_rate = this->get_host_rates().clip( - boost::math::iround(_tick_rate/rate), true); + const size_t interp_rate = boost::math::iround(_tick_rate/this->get_host_rates().clip(rate, true)); size_t interp = interp_rate; //determine which half-band filters are activated diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 31c834109..937706fdd 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -470,8 +470,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 = this->get_rx_dsp_host_rates().clip( - boost::math::iround(_master_clock_rate / samp_rate), true); + const size_t rate = boost::math::iround(_master_clock_rate/this->get_rx_dsp_host_rates().clip(samp_rate, true)); if (rate < 8 and this->has_rx_halfband()) UHD_MSG(warning) << "USRP1 cannot achieve decimations below 8 when the half-band filter is present.\n" @@ -499,8 +498,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()? 2 : 1; - const size_t rate = this->get_tx_dsp_host_rates().clip( - boost::math::iround(_master_clock_rate / samp_rate), true); + const size_t rate = boost::math::iround(_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 bool s = this->disable_tx(); diff --git a/host/tests/ranges_test.cpp b/host/tests/ranges_test.cpp index 5f6de4645..85bb4c3c4 100644 --- a/host/tests/ranges_test.cpp +++ b/host/tests/ranges_test.cpp @@ -55,3 +55,16 @@ BOOST_AUTO_TEST_CASE(test_ranges_clip){ BOOST_CHECK_CLOSE(mr.clip(50.9, false), 50.9, tolerance); BOOST_CHECK_CLOSE(mr.clip(50.9, true), 51.0, tolerance); } + +BOOST_AUTO_TEST_CASE(test_ranges_clip2){ + meta_range_t mr; + mr.push_back(range_t(1.)); + mr.push_back(range_t(2.)); + mr.push_back(range_t(3.)); + + BOOST_CHECK_CLOSE(mr.clip(2., true), 2., tolerance); + BOOST_CHECK_CLOSE(mr.clip(0., true), 1., tolerance); + BOOST_CHECK_CLOSE(mr.clip(1.2, true), 1., tolerance); + BOOST_CHECK_CLOSE(mr.clip(3.1, true), 3., tolerance); + BOOST_CHECK_CLOSE(mr.clip(4., true), 3., tolerance); +} |