diff options
author | Martin Braun <martin.braun@ettus.com> | 2022-01-26 09:52:48 +0100 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-02-01 14:39:35 -0600 |
commit | c3327801ca43f3fdeca669e3aff470ce05e439a0 (patch) | |
tree | 3615492eba2327c3299e36cfe34215025bf0af29 | |
parent | 13f4b9ec43e581f994a235619495ccd06c98ad54 (diff) | |
download | uhd-c3327801ca43f3fdeca669e3aff470ce05e439a0.tar.gz uhd-c3327801ca43f3fdeca669e3aff470ce05e439a0.tar.bz2 uhd-c3327801ca43f3fdeca669e3aff470ce05e439a0.zip |
rfnoc: Add post_init() method to noc_block_base
This method allows running a fixed set of rules to check the internal
consistency of a block. This may be necessary, because blocks authors
may incorrectly implement a certain design rule, and we want the ability
to not start an RFNoC graph with blocks that have rule violations which
we can write checks for.
-rw-r--r-- | host/include/uhd/rfnoc/noc_block_base.hpp | 11 | ||||
-rw-r--r-- | host/lib/rfnoc/noc_block_base.cpp | 5 | ||||
-rw-r--r-- | host/lib/rfnoc/rfnoc_graph.cpp | 18 |
3 files changed, 34 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/noc_block_base.hpp b/host/include/uhd/rfnoc/noc_block_base.hpp index b9ebda63b..b18de41fc 100644 --- a/host/include/uhd/rfnoc/noc_block_base.hpp +++ b/host/include/uhd/rfnoc/noc_block_base.hpp @@ -311,6 +311,8 @@ protected: virtual void deinit(); private: + friend struct block_initializer; + /*! Update the tick rate of this block * * This will make sure that the underlying register_iface is notified of the @@ -325,6 +327,15 @@ private: */ void shutdown() override; + /*! Run post-init tasks, i.e., after the constructor concludes. + * + * The purpose of this method is to make sure the block is in a good state + * after the block controller's ctor has concluded. This allows checking + * that block configurations follow certain rules, even though they may not + * even be part of UHD. + */ + void post_init(); + /************************************************************************** * Attributes **************************************************************************/ diff --git a/host/lib/rfnoc/noc_block_base.cpp b/host/lib/rfnoc/noc_block_base.cpp index 9719e739b..f854ca8d4 100644 --- a/host/lib/rfnoc/noc_block_base.cpp +++ b/host/lib/rfnoc/noc_block_base.cpp @@ -350,6 +350,11 @@ void noc_block_base::shutdown() update_reg_iface(); } +void noc_block_base::post_init() +{ + // nop +} + std::shared_ptr<mb_controller> noc_block_base::get_mb_controller() { return _mb_controller; diff --git a/host/lib/rfnoc/rfnoc_graph.cpp b/host/lib/rfnoc/rfnoc_graph.cpp index 35a5cb28c..0d0e03043 100644 --- a/host/lib/rfnoc/rfnoc_graph.cpp +++ b/host/lib/rfnoc/rfnoc_graph.cpp @@ -58,8 +58,25 @@ struct route_info_t graph_edge_t src_static_edge; graph_edge_t dst_static_edge; }; + } // namespace +// Define an attorney to limit access to noc_block_base internals +class rfnoc_graph_impl; +namespace uhd { namespace rfnoc { + +class block_initializer +{ + static void post_init(noc_block_base::sptr block) + { + block->post_init(); + } + friend rfnoc_graph_impl; +}; + +}} // namespace uhd::rfnoc + + class rfnoc_graph_impl : public rfnoc_graph { public: @@ -731,6 +748,7 @@ private: try { _block_registry->register_block( block_factory_info.factory_fn(std::move(make_args_uptr))); + block_initializer::post_init(_block_registry->get_block(block_id)); } catch (...) { UHD_LOG_ERROR( LOG_ID, "Error during initialization of block " << block_id << "!"); |