diff options
author | michael-west <michael.west@ettus.com> | 2019-01-28 17:32:28 -0800 |
---|---|---|
committer | Ashish Chaudhari <ashish.chaudhari@ettus.com> | 2019-01-31 13:48:02 -0800 |
commit | f712d477b97e2ee7cca56d5afcf199f00959eb85 (patch) | |
tree | d94e89cc6204e86ff297e3f76a0895e0819b6e79 /host | |
parent | c08bc212d1b4e48f811b80ee8cb6321c944d4d58 (diff) | |
download | uhd-f712d477b97e2ee7cca56d5afcf199f00959eb85.tar.gz uhd-f712d477b97e2ee7cca56d5afcf199f00959eb85.tar.bz2 uhd-f712d477b97e2ee7cca56d5afcf199f00959eb85.zip |
RFNoC: Fix scaling of M and N values in DDC/DUC
Scale the M and N values if the tick_rate differs from the sample rate.
Fixes timestamps in packets when using TwinRX on X300.
Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/rfnoc/ddc_block_ctrl_impl.cpp | 6 | ||||
-rw-r--r-- | host/lib/rfnoc/duc_block_ctrl_impl.cpp | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp index f115a876b..caa1f4c20 100644 --- a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp @@ -226,6 +226,9 @@ private: double set_output_rate(const double requested_rate, const size_t chan) { const double input_rate = get_arg<double>("input_rate"); + const double tick_rate = _tree->exists("tick_rate") ? + _tree->access<double>("tick_rate").get() : input_rate; + const size_t m = size_t(tick_rate / input_rate); const size_t decim_rate = boost::math::iround( input_rate / this->get_output_rates().clip(requested_rate, true)); size_t decim = decim_rate; @@ -241,7 +244,8 @@ private: sr_write("DECIM_WORD", (hb_enable << 8) | (decim & 0xff), chan); // Rate change = M/N - sr_write("N", std::pow(2.0, double(hb_enable)) * (decim & 0xff), chan); + sr_write("M", m, chan); + sr_write("N", m * std::pow(2.0, double(hb_enable)) * (decim & 0xff), chan); const auto noc_id = _tree->access<uint64_t>(_root_path / "noc_id").get(); // FIXME this should be a rb reg in the FPGA, not based on a hard-coded // Noc-ID diff --git a/host/lib/rfnoc/duc_block_ctrl_impl.cpp b/host/lib/rfnoc/duc_block_ctrl_impl.cpp index 44825bfd0..8d5567d21 100644 --- a/host/lib/rfnoc/duc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/duc_block_ctrl_impl.cpp @@ -213,6 +213,9 @@ private: double set_input_rate(const double requested_rate, const size_t chan) { const double output_rate = get_arg<double>("output_rate", chan); + const double tick_rate = _tree->exists("tick_rate") ? + _tree->access<double>("tick_rate").get() : output_rate; + const size_t n = size_t(tick_rate / output_rate); const size_t interp_rate = boost::math::iround( output_rate / get_input_rates().clip(requested_rate, true)); size_t interp = interp_rate; @@ -228,8 +231,8 @@ private: sr_write("INTERP_WORD", (hb_enable << 8) | (interp & 0xff), chan); // Rate change = M/N - sr_write("N", 1, chan); - sr_write("M", std::pow(2.0, double(hb_enable)) * (interp & 0xff), chan); + sr_write("N", n, chan); + sr_write("M", n * std::pow(2.0, double(hb_enable)) * (interp & 0xff), chan); if (interp > 1 and hb_enable == 0) { UHD_LOGGER_WARNING("RFNOC") |