diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-05-08 18:25:22 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:16 -0800 |
commit | 53becb55e1211a85b27a3d862afec4e7ffd0818e (patch) | |
tree | 63dc4b8a741bd0a367bf1d17cc67d7375e14ba19 /host | |
parent | 92bd2da55660044128f423b20e096d2fe5909d75 (diff) | |
download | uhd-53becb55e1211a85b27a3d862afec4e7ffd0818e.tar.gz uhd-53becb55e1211a85b27a3d862afec4e7ffd0818e.tar.bz2 uhd-53becb55e1211a85b27a3d862afec4e7ffd0818e.zip |
rfnoc: add register_iface holder class
Adding mixin class that manages holding onto a register_iface.
Deriving from this new class in noc_block_base, as it needs access to
a register_iface.
Co-authored-by: Brent Stapleton <brent.stapleton@ettus.com>
Diffstat (limited to 'host')
-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 */ |