diff options
author | Lars Amsel <lars.amsel@ni.com> | 2019-08-26 16:55:14 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:16:25 -0800 |
commit | f5c06403041edeecd0c0d7078ccadb60e7c98838 (patch) | |
tree | e0ea85b225c854739a1820e4f53d786abef09bd6 /host | |
parent | f9f9cb0d2cd29b1f2da21c026560215e7f3043a5 (diff) | |
download | uhd-f5c06403041edeecd0c0d7078ccadb60e7c98838.tar.gz uhd-f5c06403041edeecd0c0d7078ccadb60e7c98838.tar.bz2 uhd-f5c06403041edeecd0c0d7078ccadb60e7c98838.zip |
rfnoc: Port FFT controller
rfnoc used noc-script for FFT controller implementation. Because
erfnoc does not support noc-script yet, the implementation is done
as a rfnoc controller.
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/blocks/fft_1x64.yml | 56 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/fft_block_control.hpp | 52 | ||||
-rw-r--r-- | host/lib/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/rfnoc/fft_block_control.cpp | 114 |
5 files changed, 224 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/CMakeLists.txt b/host/include/uhd/rfnoc/CMakeLists.txt index 9abacbeaa..bb3cc0190 100644 --- a/host/include/uhd/rfnoc/CMakeLists.txt +++ b/host/include/uhd/rfnoc/CMakeLists.txt @@ -34,6 +34,7 @@ UHD_INSTALL(FILES ddc_block_control.hpp duc_block_control.hpp dmafifo_block_control.hpp + fft_block_control.hpp null_block_control.hpp radio_control.hpp diff --git a/host/include/uhd/rfnoc/blocks/fft_1x64.yml b/host/include/uhd/rfnoc/blocks/fft_1x64.yml new file mode 100644 index 000000000..ac2155381 --- /dev/null +++ b/host/include/uhd/rfnoc/blocks/fft_1x64.yml @@ -0,0 +1,56 @@ +schema: rfnoc_modtool_args +module_name: fft +version: 1.0 +rfnoc_version: 1.0 +chdr_width: 64 +noc_id: 0xFF700000 + +clocks: + - name: rfnoc_chdr + freq: "[]" + - name: rfnoc_ctrl + freq: "[]" + - name: fft + freq: "[]" + +control: + sw_iface: nocscript + fpga_iface: ctrlport + interface_direction: master_slave + fifo_depth: 32 + clk_domain: fft + ctrlport: + byte_mode: True + timed: False + has_status: False + +# parameters: + +data: + fpga_iface: axis_chdr + clk_domain: fft + mtu: 1024 + inputs: + port0: + index: 0 + item_width: 32 + nipc: 2 + context_fifo_depth: 1 + payload_fifo_depth: 1 + format: int32 + mdata_sig: ~ + outputs: + port0: + index: 0 + item_width: 32 + nipc: 2 + context_fifo_depth: 1 + payload_fifo_depth: 1 + format: int32 + mdata_sig: ~ + +io_port: + +registers: + +properties: diff --git a/host/include/uhd/rfnoc/fft_block_control.hpp b/host/include/uhd/rfnoc/fft_block_control.hpp new file mode 100644 index 000000000..c865dce78 --- /dev/null +++ b/host/include/uhd/rfnoc/fft_block_control.hpp @@ -0,0 +1,52 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_FFT_BLOCK_CONTROL_HPP +#define INCLUDED_LIBUHD_FFT_BLOCK_CONTROL_HPP + +#include <uhd/config.hpp> +#include <uhd/rfnoc/noc_block_base.hpp> + +namespace uhd { namespace rfnoc { + +enum class fft_shift { NORMAL, REVERSE, NATURAL }; +enum class fft_direction { REVERSE, FORWARD }; +enum class fft_magnitude { COMPLEX, MAGNITUDE, MAGNITUDE_SQUARED }; + +// Custom property keys +static const std::string PROP_KEY_MAGNITUDE = "magnitude"; +static const std::string PROP_KEY_DIRECTION = "direction"; +static const std::string PROP_KEY_FFT_LEN = "fft_len"; +static const std::string PROP_KEY_FFT_SCALING = "fft_scaling"; +static const std::string PROP_KEY_FFT_SHIFT = "fft_shift"; + +/*! FFT Block Control Class + */ +class UHD_API fft_block_control : public noc_block_base +{ +public: + RFNOC_DECLARE_BLOCK(fft_block_control) + + // Readback addresses + static const uint32_t RB_FFT_RESET; + static const uint32_t RB_MAGNITUDE_OUT; + static const uint32_t RB_FFT_SIZE_LOG2; + static const uint32_t RB_FFT_DIRECTION; + static const uint32_t RB_FFT_SCALING; + static const uint32_t RB_FFT_SHIFT_CONFIG; + // Write addresses + static const uint32_t SR_FFT_RESET; + static const uint32_t SR_FFT_SIZE_LOG2; + static const uint32_t SR_MAGNITUDE_OUT; + static const uint32_t SR_FFT_DIRECTION; + static const uint32_t SR_FFT_SCALING; + static const uint32_t SR_FFT_SHIFT_CONFIG; + +}; + +}} // namespace uhd::rfnoc + +#endif /* INCLUDED_LIBUHD_FFT_BLOCK_CONTROL_HPP */ diff --git a/host/lib/rfnoc/CMakeLists.txt b/host/lib/rfnoc/CMakeLists.txt index ae531275f..e685cef26 100644 --- a/host/lib/rfnoc/CMakeLists.txt +++ b/host/lib/rfnoc/CMakeLists.txt @@ -43,6 +43,7 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/ddc_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/duc_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dmafifo_block_control.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/fft_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/null_block_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/radio_control_impl.cpp ) diff --git a/host/lib/rfnoc/fft_block_control.cpp b/host/lib/rfnoc/fft_block_control.cpp new file mode 100644 index 000000000..266eb3e7f --- /dev/null +++ b/host/lib/rfnoc/fft_block_control.cpp @@ -0,0 +1,114 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhd/exception.hpp> +#include <uhd/rfnoc/defaults.hpp> +#include <uhd/rfnoc/fft_block_control.hpp> +#include <uhd/rfnoc/registry.hpp> + +#include <string> + +using namespace uhd::rfnoc; + +namespace { + +constexpr int DEFAULT_SIZE = 256; +const fft_shift DEFAULT_SHIFT = fft_shift::NORMAL; +const fft_direction DEFAULT_DIRECTION = fft_direction::FORWARD; +const fft_magnitude DEFAULT_MAGNITUDE = fft_magnitude::COMPLEX; +constexpr int DEFAULT_FFT_SCALING = 1706; + +const uhd::rfnoc::io_type_t DEFAULT_TYPE = uhd::rfnoc::IO_TYPE_SC16; + +} // namespace + + +const uint32_t fft_block_control::RB_FFT_RESET = 0; +const uint32_t fft_block_control::RB_MAGNITUDE_OUT = 8; +const uint32_t fft_block_control::RB_FFT_SIZE_LOG2 = 16; +const uint32_t fft_block_control::RB_FFT_DIRECTION = 24; +const uint32_t fft_block_control::RB_FFT_SCALING = 32; +const uint32_t fft_block_control::RB_FFT_SHIFT_CONFIG = 40; + +const uint32_t fft_block_control::SR_FFT_RESET = 131 * 8; +const uint32_t fft_block_control::SR_FFT_SIZE_LOG2 = 132 * 8; +const uint32_t fft_block_control::SR_MAGNITUDE_OUT = 133 * 8; +const uint32_t fft_block_control::SR_FFT_DIRECTION = 134 * 8; +const uint32_t fft_block_control::SR_FFT_SCALING = 135 * 8; +const uint32_t fft_block_control::SR_FFT_SHIFT_CONFIG = 136 * 8; + +class fft_block_control_impl : public fft_block_control +{ +public: + RFNOC_BLOCK_CONSTRUCTOR(fft_block_control) + { + set_prop_forwarding_policy(forwarding_policy_t::ONE_TO_ONE); + set_action_forwarding_policy(forwarding_policy_t::ONE_TO_ONE); + } + + void reset() + { + regs().poke32(SR_FFT_RESET, uint32_t(1)); + regs().poke32(SR_FFT_RESET, uint32_t(0)); + } + + +private: + + /************************************************************************** + * Initialization + *************************************************************************/ + void _register_props() + { + // register block specific properties + register_property(&_size, [this]() { + this->regs().poke32(SR_FFT_SIZE_LOG2, uint32_t(this->_size.get())); + }); + register_property(&_magnitude, [this]() { + this->regs().poke32(SR_MAGNITUDE_OUT, uint32_t(this->_magnitude.get())); + }); + register_property(&_direction, [this]() { + this->regs().poke32(SR_MAGNITUDE_OUT, uint32_t(this->_direction.get())); + }); + register_property(&_scaling, [this]() { + this->regs().poke32(SR_MAGNITUDE_OUT, uint32_t(this->_scaling.get())); + }); + register_property(&_shift, [this]() { + this->regs().poke32(SR_MAGNITUDE_OUT, uint32_t(this->_shift.get())); + }); + + //register edge properties + register_property(&_type_in); + register_property(&_type_out); + + //add resolvers for type (keeps it constant) + add_property_resolver({&_type_in}, {&_type_in}, [& type_in = _type_in]() { + type_in.set(IO_TYPE_SC16); + }); + add_property_resolver({&_type_out}, {&_type_out}, [& type_out = _type_out]() { + type_out.set(IO_TYPE_SC16); + }); + + } + + property_t<int> _size{PROP_KEY_FFT_LEN, DEFAULT_SIZE, {res_source_info::USER}}; + property_t<int> _magnitude = property_t<int>{ + PROP_KEY_MAGNITUDE, static_cast<int>(DEFAULT_MAGNITUDE), {res_source_info::USER}}; + property_t<int> _direction = property_t<int>{ + PROP_KEY_DIRECTION, static_cast<int>(DEFAULT_DIRECTION), {res_source_info::USER}}; + property_t<int> _scaling = property_t<int>{ + PROP_KEY_FFT_SCALING, DEFAULT_FFT_SCALING, {res_source_info::USER}}; + property_t<int> _shift = property_t<int>{ + PROP_KEY_FFT_SHIFT, static_cast<int>(DEFAULT_SHIFT), {res_source_info::USER}}; + + property_t<std::string> _type_in = property_t<std::string>{ + PROP_KEY_TYPE, IO_TYPE_SC16, {res_source_info::INPUT_EDGE}}; + property_t<std::string> _type_out = property_t<std::string>{ + PROP_KEY_TYPE, IO_TYPE_SC16, {res_source_info::OUTPUT_EDGE}}; +}; + +UHD_RFNOC_BLOCK_REGISTER_DIRECT( + fft_block_control, 0xFF700000, "FFT", CLOCK_KEY_GRAPH, "bus_clk") |