diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-11-22 14:32:27 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-27 21:44:58 -0800 |
commit | b8ba43193ab763d3e9e70e0743da08c49c421549 (patch) | |
tree | 1b0828e914044f2eebde1ef38bccca91a6823e64 | |
parent | 267676363990fe95effc9bf283356da8d7ba9d4a (diff) | |
download | uhd-b8ba43193ab763d3e9e70e0743da08c49c421549.tar.gz uhd-b8ba43193ab763d3e9e70e0743da08c49c421549.tar.bz2 uhd-b8ba43193ab763d3e9e70e0743da08c49c421549.zip |
rfnoc: DDC/DUC: Fix fp-issues with samp_rate properties
Only update DDC/DUC samp_rate properties if the number is substantially
different (don't update for sub-1Hz property calculations). This fixes
resolver exceptions for certain rates.
-rw-r--r-- | host/lib/rfnoc/ddc_block_control.cpp | 27 | ||||
-rw-r--r-- | host/lib/rfnoc/duc_block_control.cpp | 46 |
2 files changed, 67 insertions, 6 deletions
diff --git a/host/lib/rfnoc/ddc_block_control.cpp b/host/lib/rfnoc/ddc_block_control.cpp index 8ac411a53..9f90980d9 100644 --- a/host/lib/rfnoc/ddc_block_control.cpp +++ b/host/lib/rfnoc/ddc_block_control.cpp @@ -314,7 +314,18 @@ private: if (not decim.is_valid()) { decim = coerce_decim(samp_rate_in.get() / samp_rate_out.get()); } - samp_rate_out = samp_rate_in.get() / decim.get(); + const double new_samp_rate_out = samp_rate_in.get() / decim.get(); + // Only update the samp_rate_out if the new value is not the same + // frequency. However, we still want to call the operator= to make + // sure metadata gets handled + if (samp_rate_out.is_valid()) { + samp_rate_out = (uhd::math::frequencies_are_equal( + samp_rate_out, new_samp_rate_out)) + ? samp_rate_out.get() + : new_samp_rate_out; + } else { + samp_rate_out = new_samp_rate_out; + } RFNOC_LOG_TRACE("New samp_rate_out is " << samp_rate_out.get()); // If the input rate changes, we need to update the DDS, too, // since it works on frequencies normalized by the input rate. @@ -343,7 +354,19 @@ private: // However, the decim resolver will set the output rate based // on the input rate, so we need to force the input rate first. if (decim.is_dirty()) { - samp_rate_in = samp_rate_out.get() * decim.get(); + const double new_samp_rate_in = samp_rate_out.get() * decim.get(); + // Only update the samp_rate_in if the new value is not the same + // frequency. However, we still want to call the operator= to make + // sure metadata gets handled + if (samp_rate_in.is_valid()) { + samp_rate_in = (uhd::math::frequencies_are_equal( + samp_rate_in, new_samp_rate_in)) + ? samp_rate_in.get() + : new_samp_rate_in; + } else { + samp_rate_in = new_samp_rate_in; + } + RFNOC_LOG_TRACE("New samp_rate_in is " << samp_rate_in.get()); } } scaling_out = scaling_in.get() * _residual_scaling.at(chan); diff --git a/host/lib/rfnoc/duc_block_control.cpp b/host/lib/rfnoc/duc_block_control.cpp index 0d10aee69..ff1c4e97a 100644 --- a/host/lib/rfnoc/duc_block_control.cpp +++ b/host/lib/rfnoc/duc_block_control.cpp @@ -252,9 +252,29 @@ private: set_interp(interp.get(), chan); } if (samp_rate_out.is_valid()) { - samp_rate_in = samp_rate_out.get() / interp.get(); + const double new_samp_rate_in = samp_rate_out.get() / interp.get(); + if (samp_rate_in.is_valid()) { + // Only update the samp_rate_in if the new value is not the same + // frequency. However, we still want to call the operator= to make + // sure metadata gets handled + samp_rate_in = uhd::math::frequencies_are_equal( + new_samp_rate_in, samp_rate_in.get()) + ? samp_rate_in.get() + : new_samp_rate_in; + } else { + samp_rate_in = new_samp_rate_in; + } } else if (samp_rate_in.is_valid()) { - samp_rate_out = samp_rate_in.get() * interp.get(); + const double new_samp_rate_out = samp_rate_in.get() * interp.get(); + if (samp_rate_out.is_valid()) { + // Only update if the new value is not the same frequency + samp_rate_out = uhd::math::frequencies_are_equal( + new_samp_rate_out, samp_rate_out.get()) + ? samp_rate_out.get() + : new_samp_rate_out; + } else { + samp_rate_out = new_samp_rate_out; + } } // The scaling is independent of the actual rates if (scaling_out.is_valid()) { @@ -298,7 +318,16 @@ private: if (samp_rate_out.is_valid()) { interp = coerce_interp(samp_rate_out.get() / samp_rate_in.get()); } - samp_rate_out = samp_rate_in.get() * interp.get(); + const double new_samp_rate_out = samp_rate_in.get() * interp.get(); + if (samp_rate_out.is_valid()) { + // Only update if the new value is not the same frequency + samp_rate_out = uhd::math::frequencies_are_equal( + new_samp_rate_out, samp_rate_out.get()) + ? samp_rate_out.get() + : new_samp_rate_out; + } else { + samp_rate_out = new_samp_rate_out; + } RFNOC_LOG_TRACE("New samp_rate_out is " << samp_rate_out.get()); } }); @@ -318,7 +347,16 @@ private: interp = coerce_interp(int(samp_rate_out.get() / samp_rate_in.get())); } - samp_rate_in = samp_rate_out.get() / interp.get(); + const double new_samp_rate_in = samp_rate_out.get() / interp.get(); + if (samp_rate_in.is_valid()) { + // Only update if the new value is not the same frequency + samp_rate_in = uhd::math::frequencies_are_equal( + new_samp_rate_in, samp_rate_in.get()) + ? samp_rate_in.get() + : new_samp_rate_in; + } else { + samp_rate_in = new_samp_rate_in; + } // We now need to force the resolver for freq to run so it can // update its phase increment freq.force_dirty(); |