aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/rfnoc/CMakeLists.txt1
-rw-r--r--host/include/uhd/rfnoc/defaults.hpp24
-rw-r--r--host/include/uhd/rfnoc/moving_average_block_control.hpp61
3 files changed, 75 insertions, 11 deletions
diff --git a/host/include/uhd/rfnoc/CMakeLists.txt b/host/include/uhd/rfnoc/CMakeLists.txt
index 805a59a4f..3249b51f3 100644
--- a/host/include/uhd/rfnoc/CMakeLists.txt
+++ b/host/include/uhd/rfnoc/CMakeLists.txt
@@ -41,6 +41,7 @@ UHD_INSTALL(FILES
fir_filter_block_control.hpp
fosphor_block_control.hpp
logpwr_block_control.hpp
+ moving_average_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 30df8cbc4..9964467d3 100644
--- a/host/include/uhd/rfnoc/defaults.hpp
+++ b/host/include/uhd/rfnoc/defaults.hpp
@@ -1,6 +1,7 @@
//
// Copyright 2014 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
+// Copyright 2020 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
@@ -73,16 +74,17 @@ static const device_type_t N320 = 0x1320;
static const device_type_t X300 = 0xA300;
// block identifiers
-static const noc_id_t ADDSUB_BLOCK = 0xADD00000;
-static const noc_id_t DUC_BLOCK = 0xD0C00000;
-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;
-static const noc_id_t WINDOW_BLOCK = 0xD0530000;
+static const noc_id_t ADDSUB_BLOCK = 0xADD00000;
+static const noc_id_t DUC_BLOCK = 0xD0C00000;
+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 MOVING_AVERAGE_BLOCK = 0xAAD20000;
+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;
+static const noc_id_t WINDOW_BLOCK = 0xD0530000;
}} // namespace uhd::rfnoc
diff --git a/host/include/uhd/rfnoc/moving_average_block_control.hpp b/host/include/uhd/rfnoc/moving_average_block_control.hpp
new file mode 100644
index 000000000..54bdd150f
--- /dev/null
+++ b/host/include/uhd/rfnoc/moving_average_block_control.hpp
@@ -0,0 +1,61 @@
+//
+// 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>
+#include <uhd/types/ranges.hpp>
+#include <boost/optional.hpp>
+
+namespace uhd { namespace rfnoc {
+
+/*! Moving Average Block Control Class
+ *
+ * The Moving Average block is an RFNoC block that computes the running average of an
+ * input data stream. The output is the sum of the last SUM_LEN samples divided by DIVISOR
+ * which may or may not be equal to SUM_LEN. For example, if SUM_LEN is set to 10 and
+ * DIVISOR is set to 10, the block will return a sample that is the average of the last 10
+ * samples. If SUM_LEN is set to 10 and DIVISOR is set to 1, the block will return a
+ * sample that is equal to the sum of the last 10 samples.
+ *
+ */
+class UHD_API moving_average_block_control : public noc_block_base
+{
+public:
+ RFNOC_DECLARE_BLOCK(moving_average_block_control)
+
+ static const uint32_t REG_SUM_LEN_ADDR;
+ static const uint32_t REG_DIVISOR_ADDR;
+
+ /*! Set the Sum Length
+ *
+ * Changing the sum length will clear the history and reset the accumulated sum to 0.
+ *
+ * \param sum_len The number of samples to sum
+ */
+ virtual void set_sum_len(const uint8_t sum_len) = 0;
+
+ /*! Return the current sum length
+ *
+ * \returns The number of samples to sum
+ */
+ virtual uint8_t get_sum_len() const = 0;
+
+ /*! Set the divisor
+ *
+ * \param divisor The amount to divide the sum by
+ */
+ virtual void set_divisor(const uint32_t divisor) = 0;
+
+ /*! Return the current divisor
+ *
+ * \returns The amount to divide the sum by
+ */
+ virtual uint32_t get_divisor() const = 0;
+};
+
+}} // namespace uhd::rfnoc