diff options
author | Josh Blum <josh@joshknows.com> | 2011-07-08 11:58:51 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-07-08 11:58:51 -0700 |
commit | 54229a06d1e4c05158ef9517fd61e61204363ed6 (patch) | |
tree | 9102001f3a60d3af433d5b257ed213cd3faa9fdf /host/lib/usrp/cores | |
parent | aa6b340f436acf4c0cad80416f69312ecfe3f29f (diff) | |
download | uhd-54229a06d1e4c05158ef9517fd61e61204363ed6.tar.gz uhd-54229a06d1e4c05158ef9517fd61e61204363ed6.tar.bz2 uhd-54229a06d1e4c05158ef9517fd61e61204363ed6.zip |
usrp: added software scale factor adjustment
Diffstat (limited to 'host/lib/usrp/cores')
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.hpp | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index e059ddfca..82bc7c1bf 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -43,6 +43,10 @@ #define REG_RX_CTRL_NSAMPS_PP _ctrl_base + 28 #define REG_RX_CTRL_NCHANNELS _ctrl_base + 32 +template <class T> T ceil_log2(T num){ + return std::ceil(std::log(num)/std::log(T(2))); +} + using namespace uhd; class rx_dsp_core_200_impl : public rx_dsp_core_200{ @@ -146,9 +150,18 @@ public: _iface->poke32(REG_DSP_RX_DECIM, (hb1 << 9) | (hb0 << 8) | (decim & 0xff)); + // Calculate CIC decimation (i.e., without halfband decimators) + // Calculate closest multiplier constant to reverse gain absent scale multipliers + const double rate_pow = std::pow(double(decim & 0xff), 4); + _scaling_adjustment = std::pow(2, ceil_log2(rate_pow))/(1.65*rate_pow); + return _tick_rate/decim_rate; } + double get_scaling_adjustment(void){ + return _scaling_adjustment; + } + double set_freq(const double freq_){ //correct for outside of rate (wrap around) double freq = std::fmod(freq_, _tick_rate); @@ -181,6 +194,7 @@ private: const size_t _dsp_base, _ctrl_base; double _tick_rate, _link_rate; bool _continuous_streaming; + double _scaling_adjustment; }; rx_dsp_core_200::sptr rx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid, const bool lingering_packet){ diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp index abe7bf817..391cc8441 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp @@ -48,6 +48,8 @@ public: virtual double set_host_rate(const double rate) = 0; + virtual double get_scaling_adjustment(void) = 0; + virtual uhd::meta_range_t get_freq_range(void) = 0; virtual double set_freq(const double freq) = 0; |