18 #ifndef INCLUDED_LIBUHD_BLOCK_CTRL_BASE_HPP 19 #define INCLUDED_LIBUHD_BLOCK_CTRL_BASE_HPP 32 #include <boost/cstdint.hpp> 33 #include <boost/shared_ptr.hpp> 34 #include <boost/lexical_cast.hpp> 74 #define UHD_RFNOC_BLOCK_OBJECT(class_name) \ 75 typedef boost::shared_ptr< class_name > sptr; 78 #define UHD_RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \ 80 const make_args_t &make_args \ 81 ) : block_ctrl_base(make_args) 85 #define UHD_RFNOC_BLOCK_REGISTER(CLASS_NAME, BLOCK_NAME) \ 86 block_ctrl_base::sptr CLASS_NAME##_make( \ 87 const make_args_t &make_args \ 89 return block_ctrl_base::sptr(new CLASS_NAME##_impl(make_args)); \ 91 UHD_STATIC_BLOCK(register_rfnoc_##CLASS_NAME) \ 93 uhd::rfnoc::block_ctrl_base::register_block(&CLASS_NAME##_make, BLOCK_NAME); \ 112 typedef boost::shared_ptr<block_ctrl_base>
sptr;
113 typedef boost::function<sptr(const make_args_t &)>
make_t;
129 static void register_block(
const make_t &make,
const std::string &name);
145 static sptr make(
const make_args_t &make_args, boost::uint64_t noc_id = ~0);
155 boost::uint32_t get_address(
size_t block_port=0);
163 std::string
unique_id()
const {
return _block_id.to_string(); };
171 std::vector<size_t> get_ctrl_ports()
const;
181 void sr_write(
const boost::uint32_t reg,
const boost::uint32_t data,
const size_t port = 0);
193 void sr_write(
const std::string ®,
const boost::uint32_t data,
const size_t port = 0);
223 boost::uint64_t user_reg_read64(
const boost::uint32_t addr,
const size_t port = 0);
236 boost::uint64_t user_reg_read64(
const std::string ®,
const size_t port = 0);
248 boost::uint32_t user_reg_read32(
const boost::uint32_t addr,
const size_t port = 0);
260 boost::uint32_t user_reg_read32(
const std::string ®,
const size_t port = 0);
268 void set_command_time(
const time_spec_t &time_spec,
const size_t port = ANY_PORT);
274 time_spec_t get_command_time(
const size_t port = 0);
281 void set_command_tick_rate(
const double tick_rate,
const size_t port = ANY_PORT);
290 void clear_command_time(
const size_t port);
310 void clear(
const size_t port = 0);
324 void set_arg(
const std::string &key,
const std::string &val,
const size_t port = 0);
327 template <
typename T>
328 void set_arg(
const std::string &key,
const T &val,
const size_t port = 0) {
329 _tree->access<T>(get_arg_path(key, port) /
"value").
set(val);
336 std::string get_arg(
const std::string &key,
const size_t port = 0)
const;
339 template <
typename T>
340 T
get_arg(
const std::string &key,
const size_t port = 0)
const {
341 return _tree->access<T>(get_arg_path(key, port) /
"value").
get();
344 std::string get_arg_type(
const std::string &key,
const size_t port = 0)
const;
370 return _root_path /
"args" / port / key;
383 virtual void _clear(
const size_t port = 0);
403 void _init_port_defs(
404 const std::string &direction,
406 const size_t first_port_index=0
410 void _init_block_args();
416 std::map<size_t, wb_iface::sptr> _ctrl_ifaces;
419 uint32_t _base_address;
425 boost::shared_ptr<nocscript::block_iface> _nocscript_iface;
uhd::property_tree::sptr _tree
Property sub-tree.
Definition: block_ctrl_base.hpp:390
void set_arg(const std::string &key, const T &val, const size_t port=0)
Direct access to set a block argument.
Definition: block_ctrl_base.hpp:328
boost::shared_ptr< wb_iface > sptr
Definition: wb_iface.hpp:32
std::string block_name
The name of the block as it will be addressed.
Definition: block_ctrl_base.hpp:67
std::map< size_t, uhd::wb_iface::sptr > ctrl_ifaces
A valid interface that allows us to do peeks and pokes.
Definition: block_ctrl_base.hpp:56
Definition: property_tree.hpp:204
make_args_t(const std::string &key="")
Definition: block_ctrl_base.hpp:48
bool is_big_endian
Definition: block_ctrl_base.hpp:65
Definition: time_spec.hpp:39
blockdef::sptr _block_def
Block definition (stores info about the block such as ports)
Definition: block_ctrl_base.hpp:399
uint32_t base_address
This block's base address (address of block port 0)
Definition: block_ctrl_base.hpp:58
Definition: block_ctrl_base.hpp:106
boost::function< sptr(const make_args_t &)> make_t
Definition: block_ctrl_base.hpp:113
uhd::fs_path _root_path
Root node of this block's properties.
Definition: block_ctrl_base.hpp:393
settingsbus_reg_t
Settings register readback.
Definition: constants.hpp:76
boost::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:220
block_id_t get_block_id() const
Definition: block_ctrl_base.hpp:159
Definition: block_id.hpp:49
uhd::fs_path get_arg_path(const std::string &key, size_t port=0) const
Return the property tree path to a block argument key on port.
Definition: block_ctrl_base.hpp:369
bool _transport_is_big_endian
Endianness of underlying transport (for data transport)
Definition: block_ctrl_base.hpp:396
Definition: build_info.hpp:25
std::string unique_id() const
Definition: block_ctrl_base.hpp:163
class UHD_RFNOC_API block_ctrl_base
Base class for all RFNoC block controller objects.
Definition: block_ctrl_base.hpp:105
std::string block_key
The key of the block, i.e. how it was registered.
Definition: block_ctrl_base.hpp:69
#define UHD_RFNOC_API
Definition: config.hpp:103
Definition: block_ctrl_base.hpp:46
uhd::property_tree::sptr tree
A property tree for this motherboard. Example: If the root a device's.
Definition: block_ctrl_base.hpp:64
T get_arg(const std::string &key, const size_t port=0) const
Direct access to get a block argument.
Definition: block_ctrl_base.hpp:340
boost::shared_ptr< block_ctrl_base > sptr
Definition: block_ctrl_base.hpp:112
boost::shared_ptr< blockdef > sptr
Definition: blockdef.hpp:35
block_ctrl_base(void)
Definition: block_ctrl_base.hpp:350
Describes port options for a block definition.
Definition: blockdef.hpp:44
Definition: stream_sig.hpp:33
std::vector< port_t > ports_t
Definition: blockdef.hpp:61
Definition: device_addr.hpp:47
size_t device_index
The device index (or motherboard index).
Definition: block_ctrl_base.hpp:60
Definition: node_ctrl_base.hpp:40