diff options
author | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-06-17 10:40:17 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-06-29 14:03:17 -0500 |
commit | 1ce6f961a76a455da2284f771a2d0140223a8f48 (patch) | |
tree | b74d21c6d6f98522b607514e20a4d233c696173e /host | |
parent | cf82b36388880237fe7b690c16dde46afc1a3da3 (diff) | |
download | uhd-1ce6f961a76a455da2284f771a2d0140223a8f48.tar.gz uhd-1ce6f961a76a455da2284f771a2d0140223a8f48.tar.bz2 uhd-1ce6f961a76a455da2284f771a2d0140223a8f48.zip |
rfnoc: Add Log Power RFNoC block support
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/defaults.hpp | 2 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/logpwr_block_control.hpp | 26 | ||||
-rw-r--r-- | host/lib/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/rfnoc/logpwr_block_control.cpp | 58 |
5 files changed, 88 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/CMakeLists.txt b/host/include/uhd/rfnoc/CMakeLists.txt index cc91a6125..33d324a4d 100644 --- a/host/include/uhd/rfnoc/CMakeLists.txt +++ b/host/include/uhd/rfnoc/CMakeLists.txt @@ -38,6 +38,7 @@ UHD_INSTALL(FILES fft_block_control.hpp fir_filter_block_control.hpp fosphor_block_control.hpp + logpwr_block_control.hpp null_block_control.hpp radio_control.hpp split_stream_block_control.hpp diff --git a/host/include/uhd/rfnoc/defaults.hpp b/host/include/uhd/rfnoc/defaults.hpp index 2104e8416..30df8cbc4 100644 --- a/host/include/uhd/rfnoc/defaults.hpp +++ b/host/include/uhd/rfnoc/defaults.hpp @@ -29,6 +29,7 @@ static const std::string PROP_KEY_MTU("mtu"); static const std::string NODE_ID_SEP("SEP"); using io_type_t = std::string; +static const io_type_t IO_TYPE_S16 = "s16"; static const io_type_t IO_TYPE_SC16 = "sc16"; static const io_type_t IO_TYPE_U8 = "u8"; @@ -78,6 +79,7 @@ static const noc_id_t DDC_BLOCK = 0xDDC00000; static const noc_id_t FFT_BLOCK = 0xFF700000; static const noc_id_t FIR_FILTER_BLOCK = 0xF1120000; static const noc_id_t FOSPHOR_BLOCK = 0x666F0000; +static const noc_id_t LOGPWR_BLOCK = 0x4C500000; static const noc_id_t SPLIT_STREAM_BLOCK = 0x57570000; static const noc_id_t RADIO_BLOCK = 0x12AD1000; static const noc_id_t VECTOR_IIR_BLOCK = 0x11120000; diff --git a/host/include/uhd/rfnoc/logpwr_block_control.hpp b/host/include/uhd/rfnoc/logpwr_block_control.hpp new file mode 100644 index 000000000..45b4b61a3 --- /dev/null +++ b/host/include/uhd/rfnoc/logpwr_block_control.hpp @@ -0,0 +1,26 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +#include <uhd/config.hpp> +#include <uhd/rfnoc/noc_block_base.hpp> + +namespace uhd { namespace rfnoc { + +/*! Log Power Block Control Class + * + * The Log Power Block is an RFNoC block that takes in a packet of signed + * 16-bit complex samples and computes an estimate of 1024 * log2(i^2 + q^2), + * putting the result in the upper 16 bits of each 32-bit output sample. + */ +class UHD_API logpwr_block_control : public noc_block_base +{ +public: + RFNOC_DECLARE_BLOCK(logpwr_block_control) +}; + +}} // namespace uhd::rfnoc diff --git a/host/lib/rfnoc/CMakeLists.txt b/host/lib/rfnoc/CMakeLists.txt index 1a45ab1ff..7c54a71f6 100644 --- a/host/lib/rfnoc/CMakeLists.txt +++ b/host/lib/rfnoc/CMakeLists.txt @@ -48,6 +48,7 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/fft_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fir_filter_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fosphor_block_control.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/logpwr_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/null_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/radio_control_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/split_stream_block_control.cpp diff --git a/host/lib/rfnoc/logpwr_block_control.cpp b/host/lib/rfnoc/logpwr_block_control.cpp new file mode 100644 index 000000000..4f18dab81 --- /dev/null +++ b/host/lib/rfnoc/logpwr_block_control.cpp @@ -0,0 +1,58 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhd/convert.hpp> +#include <uhd/exception.hpp> +#include <uhd/rfnoc/defaults.hpp> +#include <uhd/rfnoc/logpwr_block_control.hpp> +#include <uhd/rfnoc/property.hpp> +#include <uhd/rfnoc/registry.hpp> +#include <string> + +using namespace uhd::rfnoc; + + +class logpwr_block_control_impl : public logpwr_block_control +{ +public: + RFNOC_BLOCK_CONSTRUCTOR(logpwr_block_control) + { + const size_t num_input_ports = get_num_input_ports(); + const size_t num_output_ports = get_num_output_ports(); + UHD_ASSERT_THROW(num_output_ports == num_input_ports); + + _prop_type_in.reserve(num_input_ports); + _prop_type_out.reserve(num_output_ports); + + for (size_t chan = 0; chan < num_input_ports; chan++) { + // register edge properties + _prop_type_in.emplace_back(property_t<std::string>{ + PROP_KEY_TYPE, IO_TYPE_SC16, {res_source_info::INPUT_EDGE, chan}}); + _prop_type_out.emplace_back(property_t<std::string>{ + PROP_KEY_TYPE, IO_TYPE_S16, {res_source_info::OUTPUT_EDGE, chan}}); + register_property(&_prop_type_in.back()); + register_property(&_prop_type_out.back()); + + // add resolvers for type + add_property_resolver({&_prop_type_in.back()}, + {&_prop_type_in.back()}, + [this, chan]() { _prop_type_in.at(chan).set(IO_TYPE_SC16); }); + add_property_resolver({&_prop_type_out.back()}, + {&_prop_type_out.back()}, + [this, chan]() { _prop_type_out.at(chan).set(IO_TYPE_S16); }); + } + } + +private: + /************************************************************************** + * Attributes + *************************************************************************/ + std::vector<property_t<std::string>> _prop_type_in; + std::vector<property_t<std::string>> _prop_type_out; +}; + +UHD_RFNOC_BLOCK_REGISTER_DIRECT( + logpwr_block_control, LOGPWR_BLOCK, "LogPwr", CLOCK_KEY_GRAPH, "bus_clk") |