diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gnuradio/block.hpp | 163 | ||||
-rw-r--r-- | include/gnuradio/element.hpp | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_block.h | 37 | ||||
-rw-r--r-- | include/gnuradio/gr_hier_block2.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_io_signature.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_sync_block.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_sync_decimator.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_sync_interpolator.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_tags.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gr_top_block.h | 26 | ||||
-rw-r--r-- | include/gnuradio/gr_types.h | 2 | ||||
-rw-r--r-- | include/gnuradio/gras.hpp | 2 | ||||
-rw-r--r-- | include/gnuradio/hier_block.hpp | 2 | ||||
-rw-r--r-- | include/gnuradio/io_signature.hpp | 2 | ||||
-rw-r--r-- | include/gnuradio/tags.hpp | 2 | ||||
-rw-r--r-- | include/gnuradio/top_block.hpp | 45 |
16 files changed, 192 insertions, 103 deletions
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp index 25cf77c..81984f0 100644 --- a/include/gnuradio/block.hpp +++ b/include/gnuradio/block.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_BLOCK_HPP #define INCLUDED_GNURADIO_BLOCK_HPP @@ -27,6 +27,65 @@ namespace gnuradio { +//! Configuration parameters for an input port +struct GRAS_API InputPortConfig +{ + InputPortConfig(void); + + /*! + * Set buffer inlining for this port config. + * Inlining means that the input buffer can be used as an output buffer. + * The goal is to make better use of cache and memory bandwidth. + * + * By default, inlining is disabled on all input ports. + * The user should enable inlining on an input port + * when it is understood that the work function will read + * before writting to a particular section of the buffer. + * + * The scheduler will inline a buffer when + * * inlining is enabled on the particular input port + * * block holds the only buffer reference aka unique + * * the input buffer has the same affinity as the block + * * the input port has a buffer look-ahead of 0 + * + * Default = false. + */ + bool inline_buffer; + + /*! + * Set the number of input buffer look-ahead items. + * When num look-ahead items are not consumed, + * they will be available for the next work call. + * This is used to implement sample memory for + * things like sliding dot products/FIR filters. + * + * Default = 0. + */ + size_t lookahead_items; +}; + +//! Configuration parameters for an output port +struct GRAS_API OutputPortConfig +{ + OutputPortConfig(void); + + /*! + * Set an output reserve requirement such that work is called + * with an output buffer at least reserve items in size. + * + * Default = 1. + */ + size_t reserve_items; + + /*! + * Constrain the maximum number of items that + * work can be called with for this port. + * + * Default = 0 aka disabled. + */ + size_t maximum_items; +}; + template <typename PtrType> struct WorkBuffer { //! get a native pointer type to this buffer @@ -65,68 +124,28 @@ template <typename PtrType> struct WorkBuffer struct GRAS_API Block : Element { - enum - { - WORK_CALLED_PRODUCE = -2, - WORK_DONE = -1 - }; - - enum tag_propagation_policy_t - { - TPP_DONT = 0, - TPP_ALL_TO_ALL = 1, - TPP_ONE_TO_ONE = 2 - }; + //! Contruct an empty/null block Block(void); + //! Create a new block given the name Block(const std::string &name); /******************************************************************* - * Basic routines from basic block + * Deal with input and output port configuration ******************************************************************/ - //! Get the number of history items (default 0) - size_t input_history(const size_t which_input = 0) const; + //! Get the configuration rules of an input port + InputPortConfig input_config(const size_t which_input = 0) const; - /*! - * Set the number of items that will be saved from the previous run. - * Input buffers will begin with an overlap of the previous's buffer's - * num history items. This is used to implement sample memory for - * things like sliding dot products/FIR filters. - */ - void set_input_history(const size_t history, const size_t which_input = 0); - - void set_output_multiple(const size_t multiple, const size_t which_output = 0); - - size_t output_multiple(const size_t which_output = 0) const; - - void consume(const size_t which_input, const size_t how_many_items); - - void consume_each(const size_t how_many_items); - - void produce(const size_t which_output, const size_t how_many_items); + //! Set the configuration rules for an input port + void set_input_config(const InputPortConfig &config, const size_t which_input = 0); - /*! - * Set buffer inlining for this input. - * Inlining means that the input buffer can be used as an output buffer. - * The goal is to make better use of cache and memory bandwidth. - * - * By default, inlining is disabled on all input ports. - * The user should enable inlining on an input port - * when it is understood that the work function will read - * before writting to a particular section of the buffer. - * - * The scheduler will inline a buffer when - * * inlining is enabled on the particular input port - * * block holds the only buffer reference aka unique - * * the input buffer has the same affinity as the block - * * the input port has a buffer history of 0 items - */ - void set_input_inline(const size_t which_input, const bool enb); + //! Get the configuration rules of an output port + OutputPortConfig output_config(const size_t which_output = 0) const; - //! Get the buffer inlining state - bool input_inline(const size_t which_input) const; + //! Set the configuration rules for an output port + void set_output_config(const OutputPortConfig &config, const size_t which_output = 0); /*! * Enable fixed rate logic. @@ -145,9 +164,36 @@ struct GRAS_API Block : Element double relative_rate(void) const; /******************************************************************* - * Tag related routines from basic block + * Deal with data production and consumption + ******************************************************************/ + + //! Return options for the work call + enum + { + WORK_CALLED_PRODUCE = -2, + WORK_DONE = -1 + }; + + //! Call during work to consume items + void consume(const size_t which_input, const size_t how_many_items); + + //! Call during work to consume items + void consume_each(const size_t how_many_items); + + //! Call during work to produce items, must return WORK_CALLED_PRODUCE + void produce(const size_t which_output, const size_t how_many_items); + + /******************************************************************* + * Deal with tag handling and tag configuration ******************************************************************/ + enum tag_propagation_policy_t + { + TPP_DONT = 0, + TPP_ALL_TO_ALL = 1, + TPP_ONE_TO_ONE = 2 + }; + uint64_t nitems_read(const size_t which_input); uint64_t nitems_written(const size_t which_output); @@ -197,7 +243,7 @@ struct GRAS_API Block : Element typedef std::vector<WorkBuffer<void *> > OutputItems; //! The official call into the work routine (overload please) - virtual int Work( + virtual int work( const InputItems &input_items, const OutputItems &output_items ) = 0; @@ -211,6 +257,15 @@ struct GRAS_API Block : Element //! scheduler calls when the topology is updated, can be overloaded virtual bool check_topology(int ninputs, int noutputs); + /*! + * Set if the work call should be interruptible by stop(). + * Some work implementations block with the expectation of + * getting a boost thread interrupt in a blocking call. + * Set set_interruptible_work(true) if this is the case. + * By default, work implementations are not interruptible. + */ + void set_interruptible_work(const bool enb); + /******************************************************************* * routines related to affinity and allocation ******************************************************************/ diff --git a/include/gnuradio/element.hpp b/include/gnuradio/element.hpp index 6c2790d..f009862 100644 --- a/include/gnuradio/element.hpp +++ b/include/gnuradio/element.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_ELEMENT_HPP #define INCLUDED_GNURADIO_ELEMENT_HPP diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h index 4d35aa0..038c0dc 100644 --- a/include/gnuradio/gr_block.h +++ b/include/gnuradio/gr_block.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_BLOCK_H #define INCLUDED_GNURADIO_GR_BLOCK_H @@ -51,7 +51,7 @@ struct GRAS_API gr_block : gnuradio::Block template <typename T> void set_msg_handler(T msg_handler){/*LOL*/} //! implements work -> calls general work - int Work( + int work( const InputItems &input_items, const OutputItems &output_items ); @@ -77,18 +77,13 @@ struct GRAS_API gr_block : gnuradio::Block gr_vector_void_star &output_items ); - unsigned history(void) const - { - //implement off-by-one history compat - return this->input_history()+1; - } + unsigned history(void) const; - void set_history(unsigned history) - { - //implement off-by-one history compat - if (history == 0) history++; - this->set_input_history(history-1); - } + void set_history(unsigned history); + + unsigned output_multiple(void) const; + + void set_output_multiple(unsigned multiple); void set_alignment(const size_t alignment); @@ -104,6 +99,22 @@ struct GRAS_API gr_block : gnuradio::Block void set_decimation(const size_t); + int max_noutput_items(void) const; + + void set_max_noutput_items(int); + + void unset_max_noutput_items(void); + + bool is_set_max_noutput_items(void) const; + + ///////////// TODO ////////////////////// + void set_max_output_buffer(long){} + void set_max_output_buffer(int, long){} + long max_output_buffer(size_t){return 0;} + void set_min_output_buffer(long){} + void set_min_output_buffer(int, long){} + long min_output_buffer(size_t){return 0;} + }; typedef boost::shared_ptr<gr_block> gr_block_sptr; diff --git a/include/gnuradio/gr_hier_block2.h b/include/gnuradio/gr_hier_block2.h index 16b3b86..956cb1d 100644 --- a/include/gnuradio/gr_hier_block2.h +++ b/include/gnuradio/gr_hier_block2.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_HIER_BLOCK2_H #define INCLUDED_GNURADIO_GR_HIER_BLOCK2_H diff --git a/include/gnuradio/gr_io_signature.h b/include/gnuradio/gr_io_signature.h index aba4ae6..0b32efb 100644 --- a/include/gnuradio/gr_io_signature.h +++ b/include/gnuradio/gr_io_signature.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_IO_SIGNATURE_H #define INCLUDED_GNURADIO_GR_IO_SIGNATURE_H diff --git a/include/gnuradio/gr_sync_block.h b/include/gnuradio/gr_sync_block.h index f588505..cb81e67 100644 --- a/include/gnuradio/gr_sync_block.h +++ b/include/gnuradio/gr_sync_block.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_SYNC_BLOCK_H #define INCLUDED_GNURADIO_GR_SYNC_BLOCK_H diff --git a/include/gnuradio/gr_sync_decimator.h b/include/gnuradio/gr_sync_decimator.h index c5cec07..43f94be 100644 --- a/include/gnuradio/gr_sync_decimator.h +++ b/include/gnuradio/gr_sync_decimator.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H #define INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H diff --git a/include/gnuradio/gr_sync_interpolator.h b/include/gnuradio/gr_sync_interpolator.h index 0545223..b165ce8 100644 --- a/include/gnuradio/gr_sync_interpolator.h +++ b/include/gnuradio/gr_sync_interpolator.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H #define INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H diff --git a/include/gnuradio/gr_tags.h b/include/gnuradio/gr_tags.h index ab4f569..e4c9508 100644 --- a/include/gnuradio/gr_tags.h +++ b/include/gnuradio/gr_tags.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GR_TAGS_H #define INCLUDED_GR_TAGS_H diff --git a/include/gnuradio/gr_top_block.h b/include/gnuradio/gr_top_block.h index 5b4f8d9..3a56bf6 100644 --- a/include/gnuradio/gr_top_block.h +++ b/include/gnuradio/gr_top_block.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_TOP_BLOCK_H #define INCLUDED_GNURADIO_GR_TOP_BLOCK_H @@ -37,6 +37,30 @@ struct GRAS_API gr_top_block : gnuradio::TopBlock this->update(); } + void start(const size_t max_items) + { + this->set_max_noutput_items(max_items); + gnuradio::TopBlock::start(); + } + + void run(const size_t max_items) + { + this->set_max_noutput_items(max_items); + gnuradio::TopBlock::run(); + } + + int max_noutput_items(void) const + { + return this->global_config().maximum_output_items; + } + + void set_max_noutput_items(int max_items) + { + gnuradio::GlobalBlockConfig config = this->global_config(); + config.maximum_output_items = max_items; + this->set_global_config(config); + } + }; typedef boost::shared_ptr<gr_top_block> gr_top_block_sptr; diff --git a/include/gnuradio/gr_types.h b/include/gnuradio/gr_types.h index 0da08cc..872cadc 100644 --- a/include/gnuradio/gr_types.h +++ b/include/gnuradio/gr_types.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GRNURADIO_TYPES_H #define INCLUDED_GRNURADIO_TYPES_H diff --git a/include/gnuradio/gras.hpp b/include/gnuradio/gras.hpp index 93b2ef1..1759be1 100644 --- a/include/gnuradio/gras.hpp +++ b/include/gnuradio/gras.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GRAS_HPP #define INCLUDED_GNURADIO_GRAS_HPP diff --git a/include/gnuradio/hier_block.hpp b/include/gnuradio/hier_block.hpp index c22594b..8c337e3 100644 --- a/include/gnuradio/hier_block.hpp +++ b/include/gnuradio/hier_block.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_HIER_BLOCK_HPP #define INCLUDED_GNURADIO_HIER_BLOCK_HPP diff --git a/include/gnuradio/io_signature.hpp b/include/gnuradio/io_signature.hpp index 58398f5..b6b11a5 100644 --- a/include/gnuradio/io_signature.hpp +++ b/include/gnuradio/io_signature.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_IO_SIGNATURE_HPP #define INCLUDED_GNURADIO_IO_SIGNATURE_HPP diff --git a/include/gnuradio/tags.hpp b/include/gnuradio/tags.hpp index e730178..d8414d8 100644 --- a/include/gnuradio/tags.hpp +++ b/include/gnuradio/tags.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_TAGS_HPP #define INCLUDED_GNURADIO_TAGS_HPP diff --git a/include/gnuradio/top_block.hpp b/include/gnuradio/top_block.hpp index a0a057f..bab67ee 100644 --- a/include/gnuradio/top_block.hpp +++ b/include/gnuradio/top_block.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_TOP_BLOCK_HPP #define INCLUDED_GNURADIO_TOP_BLOCK_HPP @@ -22,38 +22,37 @@ namespace gnuradio { +struct GRAS_API GlobalBlockConfig +{ + GlobalBlockConfig(void); + + /*! + * Constrain the maximum number of items that + * work can be called with for all output ports. + * + * Default = 0 aka disabled. + */ + size_t maximum_output_items; +}; + struct GRAS_API TopBlock : HierBlock { TopBlock(void); TopBlock(const std::string &name); + //! Get the global block config settings + const GlobalBlockConfig &global_config(void) const; + + //! Set the global block config settings + void set_global_config(const GlobalBlockConfig &config); + /*! * Commit changes to the overall flow graph. * Call this after modifying connections. - * Update is called automatically by start/stop/run. - */ - void update(void); - - /*! - * Set the buffer allocation hint. - * This affects the size of buffers. + * Commit is called automatically by start/stop/run. */ - void set_buffer_hint(const size_t hint); - - //! Combined hint + start - void start(const size_t hint) - { - this->set_buffer_hint(hint); - this->start(); - } - - //! Combined hint + run - void run(const size_t hint) - { - this->set_buffer_hint(hint); - this->run(); - } + void commit(void); /*! * Run is for finite flow graph executions. |