diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-06-01 13:08:56 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:23 -0800 |
commit | dc9ca94afaa0a1c049eac934ad1c278deedc6766 (patch) | |
tree | cd105505e852abe366e2428073390746344de90f /host | |
parent | faa4786e025e787c196eec99f213da0d51a1f87e (diff) | |
download | uhd-dc9ca94afaa0a1c049eac934ad1c278deedc6766.tar.gz uhd-dc9ca94afaa0a1c049eac934ad1c278deedc6766.tar.bz2 uhd-dc9ca94afaa0a1c049eac934ad1c278deedc6766.zip |
rfnoc: noc_block_base: Add API to reduce num ports
This allows blocks to reduce the number of actual, available ports.
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/rfnoc/noc_block_base.hpp | 33 | ||||
-rw-r--r-- | host/lib/rfnoc/noc_block_base.cpp | 20 |
2 files changed, 53 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/noc_block_base.hpp b/host/include/uhd/rfnoc/noc_block_base.hpp index 4f3f2a2bc..6396d64df 100644 --- a/host/include/uhd/rfnoc/noc_block_base.hpp +++ b/host/include/uhd/rfnoc/noc_block_base.hpp @@ -65,10 +65,18 @@ public: //! Number of input ports. Note: This gets passed into this block from the // information stored in the global register space. + // + // Note: This may be overridden by the block (e.g., the X300 radio may not + // have all ports available if no TwinRX board is plugged in), but the + // subclassed version may never report more ports than this. size_t get_num_input_ports() const { return _num_input_ports; } //! Number of output ports. Note: This gets passed outto this block from the // information stored in the global register space. + // + // Note: This may be overridden by the block (e.g., the X300 radio may not + // have all ports available if no TwinRX board is plugged in), but the + // subclassed version may never report more ports than this. size_t get_num_output_ports() const { return _num_output_ports; } /************************************************************************** @@ -95,6 +103,31 @@ public: protected: noc_block_base(make_args_ptr make_args); + //! Update number of input ports. + // + // - The new number of ports may not exceed the old number. This can only + // be used to 'decrease' the number of ports. + // - This is considered an 'advanced' API and should rarely be called by + // blocks. See also get_num_output_ports(). + // + // \throws uhd::value_error if \p num_ports is larger than the current + // number of ports. + void set_num_input_ports(const size_t num_ports); + + //! Update number of output ports. + // + // - The new number of ports may not exceed the old number. This can only + // be used to 'decrease' the number of ports. + // - This is considered an 'advanced' API and should rarely be called by + // blocks. An example of where this is useful is the X310 radio block, + // which has 2 output ports, but only 1 is useful for UBX/SBX/WBX boards + // (i.e., boards with 1 frontend). In that case, software can make a + // determination to 'invalidate' one of the ports. + // + // \throws uhd::value_error if \p num_ports is larger than the current + // number of ports. + void set_num_output_ports(const size_t num_ports); + /*! Update tick rate for this node and all the connected nodes * * Careful: Calling this function will trigger a property propagation to any diff --git a/host/lib/rfnoc/noc_block_base.cpp b/host/lib/rfnoc/noc_block_base.cpp index 0b2d456b2..97aaeb002 100644 --- a/host/lib/rfnoc/noc_block_base.cpp +++ b/host/lib/rfnoc/noc_block_base.cpp @@ -64,6 +64,26 @@ noc_block_base::~noc_block_base() // nop } +void noc_block_base::set_num_input_ports(const size_t num_ports) +{ + if (num_ports > get_num_input_ports()) { + throw uhd::value_error( + "New number of input ports must not exceed current number!"); + } + + _num_input_ports = num_ports; +} + +void noc_block_base::set_num_output_ports(const size_t num_ports) +{ + if (num_ports > get_num_output_ports()) { + throw uhd::value_error( + "New number of output ports must not exceed current number!"); + } + + _num_output_ports = num_ports; +} + void noc_block_base::set_tick_rate(const double tick_rate) { |