diff options
-rw-r--r-- | host/include/uhd/rfnoc/noc_block_base.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/register_iface_holder.hpp | 40 |
2 files changed, 42 insertions, 2 deletions
diff --git a/host/include/uhd/rfnoc/noc_block_base.hpp b/host/include/uhd/rfnoc/noc_block_base.hpp index 034caff9e..0adcfdafb 100644 --- a/host/include/uhd/rfnoc/noc_block_base.hpp +++ b/host/include/uhd/rfnoc/noc_block_base.hpp @@ -10,6 +10,7 @@ #include <uhd/config.hpp> #include <uhd/rfnoc/block_id.hpp> #include <uhd/rfnoc/node.hpp> +#include <uhd/rfnoc/register_iface_holder.hpp> //! Shorthand for block constructor #define UHD_RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \ @@ -28,7 +29,7 @@ namespace uhd { namespace rfnoc { * The main difference between this class and its parent is the direct access to * registers, and the NoC&block IDs. */ -class UHD_API noc_block_base : public node_t +class UHD_API noc_block_base : public node_t, public register_iface_holder { public: /*! A shared pointer to allow easy access to this class and for @@ -89,4 +90,3 @@ private: }} /* namespace uhd::rfnoc */ #endif /* INCLUDED_LIBUHD_NOC_BLOCK_BASE_HPP */ - diff --git a/host/include/uhd/rfnoc/register_iface_holder.hpp b/host/include/uhd/rfnoc/register_iface_holder.hpp new file mode 100644 index 000000000..453b0cf10 --- /dev/null +++ b/host/include/uhd/rfnoc/register_iface_holder.hpp @@ -0,0 +1,40 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_REGISTER_IFACE_HOLDER_HPP +#define INCLUDED_LIBUHD_REGISTER_IFACE_HOLDER_HPP + +#include <uhd/rfnoc/register_iface.hpp> + +namespace uhd { namespace rfnoc { + +/*! Register interface holder class + * + * Classes derived from this class have access to a uhd::rfnoc::register_iface + * object. + */ +class register_iface_holder +{ +public: + register_iface_holder(register_iface::sptr reg) : _reg(reg){}; + virtual ~register_iface_holder() = default; + + /*! Return the register interface to access low-level registers + * + * \return iface A reference to an interface for low-level register access + */ + register_iface& regs() + { + return *(_reg.get()); + }; + +private: + register_iface::sptr _reg; +}; + +}} /* namespace uhd::rfnoc */ + +#endif /* INCLUDED_LIBUHD_REGISTER_IFACE_HOLDER_HPP */ |