diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-06-22 14:50:19 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-06-22 09:13:11 -0700 |
commit | 1ae324575c203dc5fdb7ac4833562fd8c9860235 (patch) | |
tree | c3487e234b7f13e3954ce503277537dbba0e2ed2 /host/include | |
parent | b5be620d1922e924eb5da5bf26955b570eab2584 (diff) | |
download | uhd-1ae324575c203dc5fdb7ac4833562fd8c9860235.tar.gz uhd-1ae324575c203dc5fdb7ac4833562fd8c9860235.tar.bz2 uhd-1ae324575c203dc5fdb7ac4833562fd8c9860235.zip |
RFNoC: Add FIR, Null, and Window block controllers
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/rfnoc/fir_block_ctrl.hpp | 46 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/null_block_ctrl.hpp | 70 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/window_block_ctrl.hpp | 54 |
3 files changed, 170 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/fir_block_ctrl.hpp b/host/include/uhd/rfnoc/fir_block_ctrl.hpp new file mode 100644 index 000000000..bfed5e067 --- /dev/null +++ b/host/include/uhd/rfnoc/fir_block_ctrl.hpp @@ -0,0 +1,46 @@ +// +// Copyright 2014-2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_RFNOC_fir_block_ctrl_HPP +#define INCLUDED_LIBUHD_RFNOC_fir_block_ctrl_HPP + +#include <uhd/rfnoc/source_block_ctrl_base.hpp> +#include <uhd/rfnoc/sink_block_ctrl_base.hpp> + +namespace uhd { + namespace rfnoc { + +/*! \brief Block controller for the standard FIR RFNoC block. + * + * The standard FIR has the following features: + * - One input- and output-port + * - Configurable taps, but fixed number of taps + * - Supports data type sc16 (16-Bit fix-point complex samples) + * + * This block requires packets to be the same size as the FFT length. + * It will perform one FFT operation per incoming packet, treating it + * as a vector of samples. + */ +class UHD_RFNOC_API fir_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base +{ +public: + UHD_RFNOC_BLOCK_OBJECT(fir_block_ctrl) + + //! Configure the filter taps. + // + // The length of \p taps must correspond the number of taps + // in this block. If it's shorter, zeros will be padded. + // If it's longer, throws a uhd::value_error. + virtual void set_taps(const std::vector<int> &taps) = 0; + + //! Returns the number of filter taps in this block. + virtual size_t get_n_taps() const = 0; +}; /* class fir_block_ctrl*/ + +}} /* namespace uhd::rfnoc */ + +#endif /* INCLUDED_LIBUHD_RFNOC_fir_block_ctrl_HPP */ +// vim: sw=4 et: diff --git a/host/include/uhd/rfnoc/null_block_ctrl.hpp b/host/include/uhd/rfnoc/null_block_ctrl.hpp new file mode 100644 index 000000000..8a982b3e0 --- /dev/null +++ b/host/include/uhd/rfnoc/null_block_ctrl.hpp @@ -0,0 +1,70 @@ +// +// Copyright 2014-2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_RFNOC_NULL_BLOCK_CTRL_HPP +#define INCLUDED_LIBUHD_RFNOC_NULL_BLOCK_CTRL_HPP + +#include <uhd/rfnoc/source_block_ctrl_base.hpp> +#include <uhd/rfnoc/sink_block_ctrl_base.hpp> + +namespace uhd { + namespace rfnoc { + +/*! \brief Provide access to a 'null block'. + * + * A 'null block' is a specific block, which comes with a couple + * of features useful for testing: + * - It can produce data at a given line rate, with a configurable + * packet size. + * - It can be used to dump packets ("null sink", "bit bucket") + * + * This block also serves as an example of how to create your own + * C++ classes to control your block. + * + * As a true source, it understands the following stream commands: + * - STREAM_MODE_START_CONTINUOUS + * - STREAM_MODE_STOP_CONTINUOUS + * + * Other stream commands are not understood and issue_stream_cmd() + * will throw if it receives them. + */ +class null_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base +{ +public: + // This macro must always be at the top of the public section in an RFNoC block class + UHD_RFNOC_BLOCK_OBJECT(null_block_ctrl) + + //! Set this register to number of lines per packet + static const uint32_t SR_LINES_PER_PACKET = 129; + //! Set this register to number of cycles between producing a line + static const uint32_t SR_LINE_RATE = 130; + //! Set this register to non-zero to start producing data + static const uint32_t SR_ENABLE_STREAM = 131; + + static const size_t DEFAULT_LINES_PER_PACKET = 32; + static const size_t BYTES_PER_LINE = 8; + + //! Custom function to set the rate at which data is produced. + // Note: This is 'cycles per line', so the bit rate is actually + // 64 times this value (byte/s is 8*rate etc.) + // + // Equivalent to writing to line_rate/value in the property tree. + // + // \param The rate you want to set this to + // \param The clock rate of this block's clock domain + // \returns the actual line rate (will find closest possible). + virtual double set_line_rate(double rate, double clock_rate=166.6e6) = 0; + + //! Return the current line rate. Equivalent to reading line_rate/value + // from the property tree. + virtual double get_line_rate(double clock_rate=166.6e6) const = 0; + +}; /* class null_block_ctrl*/ + +}} /* namespace uhd::rfnoc */ + +#endif /* INCLUDED_LIBUHD_RFNOC_NULL_BLOCK_CTRL_HPP */ +// vim: sw=4 et: diff --git a/host/include/uhd/rfnoc/window_block_ctrl.hpp b/host/include/uhd/rfnoc/window_block_ctrl.hpp new file mode 100644 index 000000000..093b34e67 --- /dev/null +++ b/host/include/uhd/rfnoc/window_block_ctrl.hpp @@ -0,0 +1,54 @@ +// +// Copyright 2014-2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_RFNOC_WINDOW_BLOCK_CTRL_HPP +#define INCLUDED_LIBUHD_RFNOC_WINDOW_BLOCK_CTRL_HPP + +#include <uhd/rfnoc/source_block_ctrl_base.hpp> +#include <uhd/rfnoc/sink_block_ctrl_base.hpp> + +namespace uhd { + namespace rfnoc { + +/*! \brief Block controller for the standard windowing RFNoC block. + * + * The standard windowing block has the following features: + * - One input- and output-port + * - Configurable window length and coefficients + * - Supports data type sc16 (16-Bit fix-point complex samples) + * + * This block requires packets to be the same size as the downstream FFT length. + * It will perform one window operation per incoming packet, treating it + * as a vector of samples. + */ +class UHD_RFNOC_API window_block_ctrl : public source_block_ctrl_base, public sink_block_ctrl_base +{ +public: + UHD_RFNOC_BLOCK_OBJECT(window_block_ctrl) + + static const size_t MAX_COEFF_VAL = 32767; + static const uint32_t SR_WINDOW_LEN = 131; // Note: AXI config bus uses 129 & 130 + static const uint32_t RB_MAX_WINDOW_LEN = 0; + static const uint32_t AXIS_WINDOW_LOAD = AXIS_CONFIG_BUS+0; // 2*0+0 + static const uint32_t AXIS_WINDOW_LOAD_TLAST = AXIS_CONFIG_BUS+1; // 2*0+1 + + //! Configure the window coefficients + // + // \p coeffs size determines the window length. If it longer than + // the maximum window length, throws a uhd::value_error. + virtual void set_window(const std::vector<int> &coeffs) = 0; + + //! Returns the maximum window length. + virtual size_t get_max_len() const = 0; + + //! Returns the current window length. + virtual size_t get_window_len() const = 0; + +}; /* class window_block_ctrl*/ + +}} /* namespace uhd::rfnoc */ + +#endif /* INCLUDED_LIBUHD_RFNOC_WINDOW_BLOCK_CTRL_HPP */ |