diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-05-26 19:15:54 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:18 -0800 |
commit | 36853315741aaba41af91cca93c742a6171ae46d (patch) | |
tree | 508a09c5004be8a4a53e2c6eee805ac4f783f481 /host/tests | |
parent | efd8e88859421c0a1876cbe850536dc28a21df69 (diff) | |
download | uhd-36853315741aaba41af91cca93c742a6171ae46d.tar.gz uhd-36853315741aaba41af91cca93c742a6171ae46d.tar.bz2 uhd-36853315741aaba41af91cca93c742a6171ae46d.zip |
rfnoc: Add DDC block controller
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/CMakeLists.txt | 10 | ||||
-rw-r--r-- | host/tests/rfnoc_blocks_test.cpp | 66 |
2 files changed, 76 insertions, 0 deletions
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index 88b673bb1..c918cc6bb 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -241,6 +241,16 @@ UHD_ADD_NONAPI_TEST( ${CMAKE_SOURCE_DIR}/lib/rfnoc/client_zero.cpp ) +UHD_ADD_NONAPI_TEST( + TARGET rfnoc_blocks_test.cpp + EXTRA_SOURCES + ${CMAKE_SOURCE_DIR}/lib/rfnoc/noc_block_base.cpp + ${CMAKE_SOURCE_DIR}/lib/rfnoc/block_id.cpp + ${CMAKE_SOURCE_DIR}/lib/utils/compat_check.cpp + ${CMAKE_SOURCE_DIR}/lib/rfnoc/ddc_block_control.cpp + ${CMAKE_SOURCE_DIR}/lib/usrp/cores/dsp_core_utils.cpp +) + ######################################################################## # demo of a loadable module ######################################################################## diff --git a/host/tests/rfnoc_blocks_test.cpp b/host/tests/rfnoc_blocks_test.cpp new file mode 100644 index 000000000..b9ffcb5f9 --- /dev/null +++ b/host/tests/rfnoc_blocks_test.cpp @@ -0,0 +1,66 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include "rfnoc_mock_reg_iface.hpp" +#include <uhd/rfnoc/ddc_block_control.hpp> +#include <uhdlib/rfnoc/clock_iface.hpp> +#include <uhdlib/rfnoc/node_accessor.hpp> +#include <boost/test/unit_test.hpp> +#include <iostream> + +using namespace uhd::rfnoc; + +namespace { + +noc_block_base::make_args_ptr make_make_args(noc_block_base::noc_id_t noc_id, + const std::string& block_id, + const size_t n_inputs, + const size_t n_outputs) +{ + auto make_args = std::make_unique<noc_block_base::make_args_t>(); + make_args->noc_id = noc_id; + make_args->num_input_ports = n_inputs; + make_args->num_output_ports = n_outputs; + make_args->reg_iface = std::make_shared<mock_reg_iface_t>(); + make_args->block_id = block_id; + make_args->clk_iface = std::make_shared<clock_iface>("MOCK_CLOCK"); + make_args->tree = uhd::property_tree::make(); + return make_args; +} + +} // namespace + +#define MOCK_REGISTER(BLOCK_NAME) \ + uhd::rfnoc::noc_block_base::sptr BLOCK_NAME##_make( \ + uhd::rfnoc::noc_block_base::make_args_ptr make_args); + +MOCK_REGISTER(ddc_block_control) + +BOOST_AUTO_TEST_CASE(test_ddc_block) +{ + node_accessor_t node_accessor{}; + constexpr uint32_t num_hb = 2; + constexpr uint32_t max_cic = 128; + constexpr size_t num_chans = 4; + constexpr noc_block_base::noc_id_t mock_noc_id = 0x7E57DDC0; + + auto ddc_make_args = make_make_args(mock_noc_id, "0/DDC#0", num_chans, num_chans); + auto ddc_reg_iface = std::dynamic_pointer_cast<mock_reg_iface_t>(ddc_make_args->reg_iface); + ddc_reg_iface->read_memory[ddc_block_control::RB_COMPAT_NUM] = + (ddc_block_control::MAJOR_COMPAT << 16) | ddc_block_control::MINOR_COMPAT; + ddc_reg_iface->read_memory[ddc_block_control::RB_NUM_HB] = num_hb; + ddc_reg_iface->read_memory[ddc_block_control::RB_CIC_MAX_DECIM] = max_cic; + auto test_ddc = ddc_block_control_make(std::move(ddc_make_args)); + + node_accessor.init_props(test_ddc.get()); + UHD_LOG_DEBUG("TEST", "Init done."); + test_ddc->set_property<int>("decim", 4, 0); + + BOOST_REQUIRE(ddc_reg_iface->write_memory.count(ddc_block_control::SR_DECIM_ADDR)); + BOOST_CHECK_EQUAL( + ddc_reg_iface->write_memory.at(ddc_block_control::SR_DECIM_ADDR), 2 << 8 | 1); +} + |