From 699870d7dec67b43c08e55fcc1d4e159a337c49a Mon Sep 17 00:00:00 2001 From: michael-west Date: Thu, 9 Dec 2021 16:22:28 -0800 Subject: RFNoC: Fix DSP frequency accuracy The host code was calculating and programming a 32-bit value for the DSP frequency, but the DDS modules in the FPGA only use the upper 24-bits. This led to inaccurate frequency values being returned. This change corrects the resolution of the value on the host side so an accurate value is returned. Signed-off-by: michael-west --- host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'host/lib/include/uhdlib/usrp') diff --git a/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp b/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp index 74b4c3848..6371eb2e5 100644 --- a/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp +++ b/host/lib/include/uhdlib/usrp/cores/dsp_core_utils.hpp @@ -9,16 +9,19 @@ #include -/*! For a requested frequency and sampling rate, return the - * correct frequency word (to set the CORDIC) and the actual frequency. +/*! For a requested frequency, sampling rate, and frequency word width (in + * number of bits), return the correct frequency word (to set the CORDIC or + * DDS) and the actual frequency. */ void get_freq_and_freq_word(const double requested_freq, const double tick_rate, double& actual_freq, - int32_t& freq_word); + int32_t& freq_word, + int word_width = 32); -/*! For a requested frequency and sampling rate, return the - * correct frequency word (to set the CORDIC) and the actual frequency. +/*! For a requested frequency, sampling rate, and frequency word width (in + * number of bits), return the correct frequency word (to set the CORDIC or + * DDS) and the actual frequency. */ std::tuple get_freq_and_freq_word( - const double requested_freq, const double tick_rate); + const double requested_freq, const double tick_rate, int word_width = 32); -- cgit v1.2.3