aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorLane Kolbly <lane.kolbly@ni.com>2022-01-31 16:10:42 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2022-02-03 14:19:40 -0600
commitd2374c6ad67f94fa577d28d5660f32579f4775cc (patch)
tree5d18d4ae1ca9d5cd6720380d419a3888c64f4385 /host
parentc8849fadc8819f5dbfd2d5fd3ad010da8e102c7a (diff)
downloaduhd-d2374c6ad67f94fa577d28d5660f32579f4775cc.tar.gz
uhd-d2374c6ad67f94fa577d28d5660f32579f4775cc.tar.bz2
uhd-d2374c6ad67f94fa577d28d5660f32579f4775cc.zip
host: zbx: Expose tuning table on property tree
This allows viewing or, conceivably, customizing the tuning table that ZBX uses, depending on the particular needs of the end user.
Diffstat (limited to 'host')
-rw-r--r--host/lib/include/uhdlib/usrp/dboard/zbx/zbx_constants.hpp7
-rw-r--r--host/lib/include/uhdlib/usrp/dboard/zbx/zbx_expert.hpp3
-rw-r--r--host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp14
-rw-r--r--host/lib/usrp/dboard/zbx/zbx_expert.cpp9
-rw-r--r--host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp59
5 files changed, 87 insertions, 5 deletions
diff --git a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_constants.hpp b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_constants.hpp
index bc61b9d61..f6956a6aa 100644
--- a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_constants.hpp
+++ b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_constants.hpp
@@ -10,6 +10,7 @@
#include <unordered_map>
#include <array>
#include <cstddef>
+#include <cstring>
#include <list>
#include <map>
#include <string>
@@ -199,6 +200,10 @@ struct tune_map_item_t
double if1_freq_max;
double if2_freq_min;
double if2_freq_max;
+
+ bool operator==(const tune_map_item_t& other) const {
+ return std::memcmp(this, &other, sizeof(tune_map_item_t)) == 0;
+ }
};
// These are addresses for the various table-based registers
@@ -266,4 +271,6 @@ namespace uhd { namespace usrp { namespace zbx {
// Any added expert nodes of type enum class will have to define this
std::ostream& operator<<(
std::ostream& os, const ::uhd::usrp::zbx::zbx_lo_source_t& lo_source);
+std::ostream& operator<<(
+ std::ostream& os, const std::vector<::uhd::usrp::zbx::tune_map_item_t>& tune_map);
}}} // namespace uhd::usrp::zbx
diff --git a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_expert.hpp b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_expert.hpp
index f4e2003ea..9d67e3041 100644
--- a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_expert.hpp
+++ b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_expert.hpp
@@ -103,6 +103,7 @@ public:
const double lo_step_size)
: experts::worker_node_t(fe_path / "zbx_freq_fe_expert")
, _desired_frequency(db, fe_path / "freq" / "desired")
+ , _tune_table(db, fe_path / "tune_table")
, _desired_lo1_frequency(db, fe_path / "los" / ZBX_LO1 / "freq" / "value" / "desired")
, _desired_lo2_frequency(db, fe_path / "los" / ZBX_LO2 / "freq" / "value" / "desired")
, _lo1_enabled(db, fe_path / ZBX_LO1 / "enabled")
@@ -124,6 +125,7 @@ public:
{
// Inputs
bind_accessor(_desired_frequency);
+ bind_accessor(_tune_table);
// Outputs
bind_accessor(_desired_lo1_frequency);
@@ -147,6 +149,7 @@ private:
// Inputs from user/API
uhd::experts::data_reader_t<double> _desired_frequency;
+ uhd::experts::data_reader_t<std::vector<tune_map_item_t>> _tune_table;
// Outputs
// From calculation, to LO expert
diff --git a/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp b/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp
index 6871080ff..18fb9bbe1 100644
--- a/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp
+++ b/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp
@@ -66,6 +66,13 @@ std::ostream& operator<<(
}
}
+std::ostream& operator<<(
+ std::ostream& os, const std::vector<::uhd::usrp::zbx::tune_map_item_t>& tune_map)
+{
+ os << "Tune map with " << tune_map.size() << " entries";
+ return os;
+}
+
void zbx_dboard_impl::_init_cpld()
{
// CPLD
@@ -573,6 +580,13 @@ void zbx_dboard_impl::_init_lo_prop_tree(uhd::property_tree::sptr subtree,
const size_t chan_idx,
const fs_path fe_path)
{
+ // Tuning table
+ expert_factory::add_prop_node<std::vector<tune_map_item_t>>(expert,
+ subtree,
+ fe_path / "tune_table",
+ trx == RX_DIRECTION ? rx_tune_map : tx_tune_map,
+ AUTO_RESOLVE_ON_WRITE);
+
// Analog LO Specific
for (const std::string lo : {ZBX_LO1, ZBX_LO2}) {
expert_factory::add_prop_node<zbx_lo_source_t>(expert,
diff --git a/host/lib/usrp/dboard/zbx/zbx_expert.cpp b/host/lib/usrp/dboard/zbx/zbx_expert.cpp
index ae39814ff..02b4873d9 100644
--- a/host/lib/usrp/dboard/zbx/zbx_expert.cpp
+++ b/host/lib/usrp/dboard/zbx/zbx_expert.cpp
@@ -28,11 +28,10 @@ bool _is_band_highband(const tune_map_item_t tune_setting)
return tune_setting.rf_fir == 0;
}
-tune_map_item_t _get_tune_settings(const double freq, const uhd::direction_t trx)
+tune_map_item_t _get_tune_settings(const double freq, const std::vector<tune_map_item_t>& tune_map)
{
- auto tune_setting = trx == RX_DIRECTION ? rx_tune_map.begin() : tx_tune_map.begin();
-
- auto tune_settings_end = trx == RX_DIRECTION ? rx_tune_map.end() : tx_tune_map.end();
+ auto tune_setting = tune_map.begin();
+ auto tune_settings_end = tune_map.end();
for (; tune_setting != tune_settings_end; ++tune_setting) {
if (tune_setting->max_band_freq >= freq) {
@@ -147,7 +146,7 @@ void zbx_scheduling_expert::resolve()
void zbx_freq_fe_expert::resolve()
{
const double tune_freq = ZBX_FREQ_RANGE.clip(_desired_frequency);
- _tune_settings = _get_tune_settings(tune_freq, _trx);
+ _tune_settings = _get_tune_settings(tune_freq, _tune_table.get());
// Set mixer values so the backend expert knows how to calculate final frequency
_mixer1_m = _tune_settings.mix1_m;
diff --git a/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp b/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp
index 92ed07a25..1e422f03e 100644
--- a/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp
+++ b/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp
@@ -581,6 +581,65 @@ BOOST_FIXTURE_TEST_CASE(zbx_lo_tree_test, x400_radio_fixture)
}
}
+BOOST_FIXTURE_TEST_CASE(zbx_custom_tx_tune_table_test, x400_radio_fixture)
+{
+ auto tree = test_radio->get_tree();
+ constexpr size_t chan = 0;
+ constexpr double ep = 10.0;
+
+ test_radio->set_tx_frequency(4.4e9, chan);
+
+ BOOST_REQUIRE(abs(test_radio->get_tx_lo_freq(ZBX_LO2, chan) - 5447680000.0) < ep);
+
+ // Custom TX tune table to try. This table is identical to the normal table,
+ // except it only has one entry (4.03GHz-4.5GHz) and the IF2 frequency for
+ // that band is 10MHz lower (chosen arbitrarily)
+ // Turn clang-formatting off so it doesn't compress these tables into a mess.
+ // clang-format off
+ static const std::vector<tune_map_item_t> alternate_tx_tune_map = {
+ // | min_band_freq | max_band_freq | rf_fir | if1_fir | if2_fir | mix1 m, n | mix2 m, n | if1_freq_min | if1_freq_max | if2_freq_min | if2_freq_max |
+ { 4030e6, 4500e6, 0, 1, 1, 0, 0, -1, 1, 0, 0, 1050e6, 1050e6 },
+ };
+
+ // Turn clang-format back on just for posterity
+ // clang-format on
+
+ tree->access<std::vector<uhd::usrp::zbx::tune_map_item_t>>(
+ "dboard/tx_frontends/0/tune_table")
+ .set(alternate_tx_tune_map);
+
+ BOOST_REQUIRE(abs(test_radio->get_tx_lo_freq(ZBX_LO2, chan) - 5437440000.0) < ep);
+}
+
+BOOST_FIXTURE_TEST_CASE(zbx_custom_rx_tune_table_test, x400_radio_fixture)
+{
+ auto tree = test_radio->get_tree();
+ constexpr size_t chan = 0;
+ constexpr double ep = 10.0;
+
+ test_radio->set_rx_frequency(4.4e9, chan);
+
+ BOOST_REQUIRE(abs(test_radio->get_rx_lo_freq(ZBX_LO2, chan) - 6236160000.0) < ep);
+
+ // Custom RX tune table to try. This table is identical to the normal table,
+ // except it only has one entry (4.2GHz-4.5GHz) and the IF2 frequency for
+ // that band is 10MHz lower (chosen arbitrarily)
+ // Turn clang-formatting off so it doesn't compress these tables into a mess.
+ // clang-format off
+ static const std::vector<tune_map_item_t> alternate_rx_tune_map = {
+ // | min_band_freq | max_band_freq | rf_fir | if1_fir | if2_fir | mix1 m, n | mix2 m, n | if1_freq_min | if1_freq_max | if2_freq_min | if2_freq_max |
+ { 4200e6, 4500e6, 0, 2, 2, 0, 0, -1, 1, 0, 0, 1840e6, 1840e6 },
+ };
+
+ // Turn clang-format back on just for posterity
+ // clang-format on
+
+ tree->access<std::vector<uhd::usrp::zbx::tune_map_item_t>>(
+ "dboard/rx_frontends/0/tune_table")
+ .set(alternate_rx_tune_map);
+
+ BOOST_REQUIRE(abs(test_radio->get_rx_lo_freq(ZBX_LO2, chan) - 6225920000.0) < ep);
+}
BOOST_FIXTURE_TEST_CASE(zbx_ant_test, x400_radio_fixture)
{