diff options
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/config.h.in | 8 | ||||
-rw-r--r-- | host/include/uhd/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/cal/CMakeLists.txt | 23 | ||||
-rw-r--r-- | host/include/uhd/cal/container.hpp | 104 | ||||
-rw-r--r-- | host/include/uhd/cal/power_container.hpp | 79 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/block_ctrl_base.hpp | 5 | ||||
-rw-r--r-- | host/include/uhd/types/sid.hpp | 42 | ||||
-rw-r--r-- | host/include/uhd/utils/atomic.hpp | 70 | ||||
-rw-r--r-- | host/include/uhd/version.hpp.in | 2 |
9 files changed, 235 insertions, 99 deletions
diff --git a/host/include/config.h.in b/host/include/config.h.in index 8e72a1f00..0e8982488 100644 --- a/host/include/config.h.in +++ b/host/include/config.h.in @@ -18,10 +18,10 @@ #cmakedefine HAVE_LOG2 /* Version macros */ -#cmakedefine UHD_VERSION_MAJOR ${TRIMMED_VERSION_MAJOR} -#cmakedefine UHD_VERSION_API ${TRIMMED_VERSION_API} -#cmakedefine UHD_VERSION_ABI ${TRIMMED_VERSION_ABI} -#cmakedefine UHD_VERSION_PATCH ${TRIMMED_VERSION_PATCH} +#cmakedefine UHD_VERSION_MAJOR ${UHD_VERSION_MAJOR} +#cmakedefine UHD_VERSION_API ${UHD_VERSION_API} +#cmakedefine UHD_VERSION_ABI ${UHD_VERSION_ABI} +#cmakedefine UHD_VERSION_PATCH ${UHD_VERSION_PATCH} #cmakedefine ENABLE_USB #ifndef UHD_VERSION #cmakedefine UHD_VERSION @UHD_VERSION_ADDED@ diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index e31ff80a0..42c89a9f3 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -18,6 +18,7 @@ ADD_SUBDIRECTORY(rfnoc) ADD_SUBDIRECTORY(transport) ADD_SUBDIRECTORY(types) +ADD_SUBDIRECTORY(cal) ADD_SUBDIRECTORY(usrp) ADD_SUBDIRECTORY(usrp_clock) ADD_SUBDIRECTORY(utils) diff --git a/host/include/uhd/cal/CMakeLists.txt b/host/include/uhd/cal/CMakeLists.txt new file mode 100644 index 000000000..14107ee53 --- /dev/null +++ b/host/include/uhd/cal/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Copyright 2016 Ettus Research +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +UHD_INSTALL(FILES + container.hpp + power_container.hpp + DESTINATION ${INCLUDE_DIR}/uhd/cal + COMPONENT headers +) diff --git a/host/include/uhd/cal/container.hpp b/host/include/uhd/cal/container.hpp new file mode 100644 index 000000000..e4f418311 --- /dev/null +++ b/host/include/uhd/cal/container.hpp @@ -0,0 +1,104 @@ +// +// Copyright 2016 Ettus Research +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_CAL_CONTAINER_HPP +#define INCLUDED_UHD_CAL_CONTAINER_HPP + +#include <uhd/config.hpp> +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/vector.hpp> +#include <boost/serialization/string.hpp> +#include <boost/serialization/map.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/shared_ptr.hpp> + +namespace uhd { +namespace cal { + +class base_container { +public: + typedef std::map<std::string, std::string> metadata_t; + typedef boost::shared_ptr<base_container> sptr; +}; + +/*! + * An interface for creating and managing a generic calibration + * data container. + * + * These containers are used to represent N dimensional data structures + * in order to accommodate a mapping from multi-variable input to a scalar + * value (e.g. gain, frequency, temperature -> power level [dBm]). + * + * The container only supports inputs of the same type to be mapped. + * + */ +template<typename in_type, typename out_type> +class UHD_API cal_container : public base_container { +public: + typedef std::map<in_type, out_type> container_t; + + /*! + * Get the mapping from an input to an output + * from the calibration container. + * + * \param args input values + * \returns the output of the mapping (a scalar value) + * \throws uhd::assertion_error if the dimensions of the input args + * are incorrect for this container + */ + virtual out_type get(const in_type &args) = 0; + + /*! + * Add a data point to the container. + * This function records a mapping R^n -> R between an input vector + * and output scalar. + * + * \param output the output of the data point mapping + * \param args input values + */ + virtual void add(const out_type output, const in_type &args) = 0; + + /*! + * Associate some metadata with the container. + * + * \param data a map of metadata (string -> string). + */ + virtual void add_metadata(const metadata_t &data) = 0; + + /*! + * Retrieve metadata from the container. + * + * \returns map of metadata. + */ + virtual const metadata_t &get_metadata() = 0; + +public: + typedef boost::archive::text_iarchive iarchive_type; + typedef boost::archive::text_oarchive oarchive_type; + +protected: + friend class boost::serialization::access; + + virtual void serialize(iarchive_type & ar, const unsigned int) = 0; + virtual void serialize(oarchive_type & ar, const unsigned int) = 0; +}; + +} // namespace cal +} // namespace uhd + +#endif /* INCLUDED_UHD_CAL_CONTAINER_HPP */ diff --git a/host/include/uhd/cal/power_container.hpp b/host/include/uhd/cal/power_container.hpp new file mode 100644 index 000000000..37f7bd8df --- /dev/null +++ b/host/include/uhd/cal/power_container.hpp @@ -0,0 +1,79 @@ +// +// Copyright 2016 Ettus Research +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_CAL_POWER_CONTAINER_HPP +#define INCLUDED_UHD_CAL_POWER_CONTAINER_HPP + +#include <uhd/config.hpp> +#include <uhd/cal/container.hpp> +#include <boost/shared_ptr.hpp> + +namespace uhd { +namespace cal { + +class UHD_API power_container : public cal_container<std::vector<double>, double> { +public: + typedef boost::shared_ptr<power_container> sptr; + + /*! + * Create a container for data related to power calibration. + * + * \returns shared pointer to the container + */ + static sptr make(); + + /*! + * Get the mapping from an input to an output + * from the calibration container. + * + * \param args input values + * \returns the output of the mapping (a scalar value) + * \throws uhd::assertion_error if the number of input values are incorrect + * for the container type + */ + virtual double get(const std::vector<double> &args) = 0; + + /*! + * Add a data point to the container. + * This function records a mapping R^n -> R between an input vector + * and output scalar. For example, a mapping might be + * (power level, frequency, temperature) -> gain. + * + * \param output the output of the data point mapping + * \param args input values + */ + virtual void add(const double output, const std::vector<double> &args) = 0; + + /*! + * Associate some metadata with the container. + * + * \param data a map of metadata (string -> string). + */ + virtual void add_metadata(const metadata_t &data) = 0; + + /*! + * Retrieve metadata from the container. + * + * \returns map of metadata. + */ + virtual const metadata_t &get_metadata() = 0; +}; + +} // namespace cal +} // namespace uhd + +#endif /* INCLUDED_UHD_CAL_POWER_CONTAINER_HPP */ diff --git a/host/include/uhd/rfnoc/block_ctrl_base.hpp b/host/include/uhd/rfnoc/block_ctrl_base.hpp index f770cf129..778ded043 100644 --- a/host/include/uhd/rfnoc/block_ctrl_base.hpp +++ b/host/include/uhd/rfnoc/block_ctrl_base.hpp @@ -46,7 +46,6 @@ struct make_args_t { make_args_t(const std::string &key="") : device_index(0), - is_big_endian(true), block_name(""), block_key(key) {} @@ -61,7 +60,6 @@ struct make_args_t // property tree is /mboards/0, pass a subtree starting at /mboards/0 // to the constructor. uhd::property_tree::sptr tree; - bool is_big_endian; //! The name of the block as it will be addressed std::string block_name; //! The key of the block, i.e. how it was registered @@ -391,9 +389,6 @@ protected: //! Root node of this block's properties uhd::fs_path _root_path; - //! Endianness of underlying transport (for data transport) - bool _transport_is_big_endian; - //! Block definition (stores info about the block such as ports) blockdef::sptr _block_def; diff --git a/host/include/uhd/types/sid.hpp b/host/include/uhd/types/sid.hpp index 5ea8e8f41..f1471549e 100644 --- a/host/include/uhd/types/sid.hpp +++ b/host/include/uhd/types/sid.hpp @@ -1,5 +1,5 @@ // -// Copyright 2014 Ettus Research LLC +// Copyright 2014-2016 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,9 +19,8 @@ #define INCLUDED_UHD_TYPES_SID_HPP #include <uhd/config.hpp> -#include <stdint.h> -#include <boost/shared_ptr.hpp> #include <iostream> +#include <stdint.h> namespace uhd { /*! @@ -99,47 +98,47 @@ namespace uhd { // Getters // //! Alias for get_sid() - UHD_INLINE uint32_t get() const { return get_sid(); }; + inline uint32_t get() const { return get_sid(); }; //! Returns a 32-Bit representation of the SID if set, or zero otherwise. - UHD_INLINE uint32_t get_sid() const { return _set ? _sid : 0; }; + inline uint32_t get_sid() const { return _set ? _sid : 0; }; //! Return the 16-bit source address of this SID - UHD_INLINE uint32_t get_src() const { + inline uint32_t get_src() const { return (_sid >> 16) & 0xFFFF; } //! Return the 16-bit destination address of this SID - UHD_INLINE uint32_t get_dst() const { + inline uint32_t get_dst() const { return _sid & 0xFFFF; } //! Return 8-bit address of the source - UHD_INLINE uint32_t get_src_addr() const { + inline uint32_t get_src_addr() const { return (get_src() >> 8) & 0xFF; } //! Return endpoint of the source - UHD_INLINE uint32_t get_src_endpoint() const { + inline uint32_t get_src_endpoint() const { return get_src() & 0xFF; } //! Return crossbar port of the source - UHD_INLINE uint32_t get_src_xbarport() const { + inline uint32_t get_src_xbarport() const { return (get_src_endpoint() >> 4) & 0xF; } //! Return block port of the source - UHD_INLINE uint32_t get_src_blockport() const { + inline uint32_t get_src_blockport() const { return (get_src_endpoint()) & 0xF; } //! Return 8-bit address of the destination - UHD_INLINE uint32_t get_dst_addr() const { + inline uint32_t get_dst_addr() const { return (get_dst() >> 8) & 0xFF; } //! Return endpoint of the destination - UHD_INLINE uint32_t get_dst_endpoint() const { + inline uint32_t get_dst_endpoint() const { return get_dst() & 0xFF; } //! Return crossbar port of the source - UHD_INLINE uint32_t get_dst_xbarport() const { + inline uint32_t get_dst_xbarport() const { return (get_dst_endpoint() >> 4) & 0xF; } //! Return block port of the source - UHD_INLINE uint32_t get_dst_blockport() const { + inline uint32_t get_dst_blockport() const { return (get_dst_endpoint()) & 0xF; } @@ -168,14 +167,14 @@ namespace uhd { // Manipulators //! Swaps dst and src address and returns the new SID. - sid_t reversed(); + sid_t reversed() const; - //! Swaps dst and src in-place. + //! Swaps dst and src in-place. This modifies the current SID. void reverse(); // Overloaded operators - sid_t operator = (uint32_t new_sid) { + sid_t operator = (const uint32_t new_sid) { set_sid(new_sid); return *this; } @@ -185,6 +184,11 @@ namespace uhd { return *this; } + sid_t operator = (const sid_t &sid) { + set_sid(sid.get_sid()); + return *this; + } + sid_t operator = (const std::string &sid_str) { set_from_str(sid_str); return *this; @@ -222,7 +226,7 @@ namespace uhd { }; //! Stream output operator. Honors std::ios::hex. - UHD_INLINE std::ostream& operator<< (std::ostream& out, const sid_t &sid) { + inline std::ostream& operator<< (std::ostream& out, const sid_t &sid) { std::ios_base::fmtflags ff = out.flags(); if (ff & std::ios::hex) { out << sid.to_pp_string_hex(); diff --git a/host/include/uhd/utils/atomic.hpp b/host/include/uhd/utils/atomic.hpp index ec4d3e0a2..f37fb4395 100644 --- a/host/include/uhd/utils/atomic.hpp +++ b/host/include/uhd/utils/atomic.hpp @@ -68,76 +68,6 @@ namespace uhd{ }; /*! - * A reusable barrier to sync multiple threads. - * All threads spin on wait() until count is reset. - */ - class UHD_API reusable_barrier{ - public: - - reusable_barrier():_size (0) {} - - reusable_barrier(const size_t size):_size(size) {} - - //! Resize the barrier for N threads - void resize(const size_t size){ - _size = size; - } - - /*! - * Force the barrier wait to throw a boost::thread_interrupted - * The threads were not getting the interruption_point on windows. - */ - void interrupt(void) - { - _done.inc(); - } - - //! Wait on the barrier condition - UHD_INLINE void wait(void) - { - if (_size == 1) return; - - //entry barrier with condition variable - _entry_counter.inc(); - _entry_counter.cas(0, _size); - boost::mutex::scoped_lock lock(_mutex); - while (_entry_counter.read() != 0) - { - this->check_interrupt(); - _cond.timed_wait(lock, boost::posix_time::milliseconds(1)); - } - lock.unlock(); //unlock before notify - _cond.notify_one(); - - //exit barrier to ensure known condition of entry count - _exit_counter.inc(); - _exit_counter.cas(0, _size); - while (_exit_counter.read() != 0) this->check_interrupt(); - } - - //! Wait on the barrier condition - UHD_INLINE void wait_others(void) - { - while (_entry_counter.read() != (_size-1)) this->check_interrupt(); - } - - private: - size_t _size; - atomic_uint32_t _entry_counter; - atomic_uint32_t _exit_counter; - atomic_uint32_t _done; - boost::mutex _mutex; - boost::condition_variable _cond; - - UHD_INLINE void check_interrupt(void) - { - if (_done.read() != 0) throw boost::thread_interrupted(); - boost::this_thread::interruption_point(); - boost::this_thread::yield(); - } - }; - - /*! * Spin-wait on a condition with a timeout. * \param cond an atomic variable to compare * \param value compare to atomic for true/false diff --git a/host/include/uhd/version.hpp.in b/host/include/uhd/version.hpp.in index 8cfc7b8c6..c16739a78 100644 --- a/host/include/uhd/version.hpp.in +++ b/host/include/uhd/version.hpp.in @@ -24,7 +24,7 @@ * The format is oldest API compatible release - ABI compat number. * The compatibility number allows pre-release ABI to be versioned. */ -#define UHD_VERSION_ABI_STRING "@TRIMMED_VERSION_MAJOR@.@TRIMMED_VERSION_API@.@TRIMMED_VERSION_ABI@" +#define UHD_VERSION_ABI_STRING "@UHD_VERSION_MAJOR@.@UHD_VERSION_API@.@UHD_VERSION_ABI@" /*! * A macro to check UHD version at compile-time. |