8 #ifndef INCLUDED_LIBUHD_BLOCK_CTRL_BASE_HPP 9 #define INCLUDED_LIBUHD_BLOCK_CTRL_BASE_HPP 23 #include <boost/shared_ptr.hpp> 25 namespace uhd {
namespace rfnoc {
37 : device_index(0), block_name(
""), block_key(key)
59 #define UHD_RFNOC_BLOCK_OBJECT(class_name) typedef boost::shared_ptr<class_name> sptr; 62 #define UHD_RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \ 63 CLASS_NAME##_impl(const make_args_t& make_args) : block_ctrl_base(make_args) 67 #define UHD_RFNOC_BLOCK_REGISTER(CLASS_NAME, BLOCK_NAME) \ 68 block_ctrl_base::sptr CLASS_NAME##_make(const make_args_t& make_args) \ 70 return block_ctrl_base::sptr(new CLASS_NAME##_impl(make_args)); \ 72 UHD_STATIC_BLOCK(register_rfnoc_##CLASS_NAME) \ 74 uhd::rfnoc::block_ctrl_base::register_block(&CLASS_NAME##_make, BLOCK_NAME); \ 93 typedef boost::shared_ptr<block_ctrl_base>
sptr;
94 typedef boost::function<sptr(const make_args_t&)>
make_t;
110 static void register_block(
const make_t& make,
const std::string& name);
126 static sptr make(
const make_args_t& make_args, uint64_t noc_id = ~0);
136 uint32_t get_address(
size_t block_port = 0);
149 return _block_id.to_string();
158 std::vector<size_t> get_ctrl_ports()
const;
169 void sr_write(
const uint32_t reg,
const uint32_t data,
const size_t port = 0);
181 void sr_write(
const std::string& reg,
const uint32_t data,
const size_t port = 0);
211 uint64_t user_reg_read64(
const uint32_t addr,
const size_t port = 0);
224 uint64_t user_reg_read64(
const std::string& reg,
const size_t port = 0);
236 uint32_t user_reg_read32(
const uint32_t addr,
const size_t port = 0);
250 uint32_t user_reg_read32(
const std::string& reg,
const size_t port = 0);
258 void set_command_time(
const time_spec_t& time_spec,
const size_t port = ANY_PORT);
264 time_spec_t get_command_time(
const size_t port = 0);
271 void set_command_tick_rate(
const double tick_rate,
const size_t port = ANY_PORT);
280 void clear_command_time(
const size_t port);
314 void set_arg(
const std::string& key,
const std::string& val,
const size_t port = 0);
317 template <
typename T>
318 void set_arg(
const std::string& key,
const T& val,
const size_t port = 0)
320 _tree->access<T>(get_arg_path(key, port) /
"value").
set(val);
327 std::string get_arg(
const std::string& key,
const size_t port = 0)
const;
330 template <
typename T> T
get_arg(
const std::string& key,
const size_t port = 0)
const 332 return _tree->access<T>(get_arg_path(key, port) /
"value").
get();
335 std::string get_arg_type(
const std::string& key,
const size_t port = 0)
const;
361 return _root_path /
"args" / port / key;
373 virtual void _clear(
const size_t port = 0);
377 virtual void _set_command_time(
378 const time_spec_t& time_spec,
const size_t port = ANY_PORT);
394 void _init_port_defs(
const std::string& direction,
396 const size_t first_port_index = 0);
399 void _init_block_args();
402 double get_command_tick_rate(
const size_t port);
405 void _start_drain(
const size_t port = 0);
408 bool _flush(
const size_t port = 0);
414 std::map<size_t, boost::shared_ptr<ctrl_iface> > _ctrl_ifaces;
415 std::map<size_t, time_spec_t> _cmd_timespecs;
416 std::map<size_t, double> _cmd_tickrates;
419 uint32_t _base_address;
425 uint64_t _compat_num;
431 boost::shared_ptr<nocscript::block_iface> _nocscript_iface;
uhd::property_tree::sptr _tree
Property sub-tree.
Definition: block_ctrl_base.hpp:384
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:318
std::string block_name
The name of the block as it will be addressed.
Definition: block_ctrl_base.hpp:52
Definition: property_tree.hpp:199
make_args_t(const std::string &key="")
Definition: block_ctrl_base.hpp:36
Definition: time_spec.hpp:29
blockdef::sptr _block_def
Block definition (stores info about the block such as ports)
Definition: block_ctrl_base.hpp:390
uint32_t base_address
This block's base address (address of block port 0)
Definition: block_ctrl_base.hpp:44
Definition: block_ctrl_base.hpp:87
uhd::fs_path _root_path
Root node of this block's properties.
Definition: block_ctrl_base.hpp:387
std::map< size_t, boost::shared_ptr< ctrl_iface > > ctrl_ifaces
A valid interface that allows us to read and write registers.
Definition: block_ctrl_base.hpp:42
settingsbus_reg_t
Settings register readback.
Definition: constants.hpp:68
boost::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:217
block_id_t get_block_id() const
Definition: block_ctrl_base.hpp:140
Definition: block_id.hpp:39
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:359
Definition: build_info.hpp:13
std::string unique_id() const
Definition: block_ctrl_base.hpp:147
class UHD_RFNOC_API block_ctrl_base
Base class for all RFNoC block controller objects.
Definition: block_ctrl_base.hpp:86
std::string block_key
The key of the block, i.e. how it was registered.
Definition: block_ctrl_base.hpp:54
#define UHD_RFNOC_API
Definition: config.hpp:104
Definition: block_ctrl_base.hpp:34
uhd::property_tree::sptr tree
A property tree for this motherboard. Example: If the root a device's.
Definition: block_ctrl_base.hpp:50
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:330
boost::shared_ptr< block_ctrl_base > sptr
Definition: block_ctrl_base.hpp:93
boost::shared_ptr< blockdef > sptr
Definition: blockdef.hpp:25
block_ctrl_base(void)
Definition: block_ctrl_base.hpp:341
boost::shared_ptr< timed_wb_iface > sptr
Definition: wb_iface.hpp:72
boost::function< sptr(const make_args_t &)> make_t
Definition: block_ctrl_base.hpp:94
Describes port options for a block definition.
Definition: blockdef.hpp:34
Definition: stream_sig.hpp:23
std::vector< port_t > ports_t
Definition: blockdef.hpp:52
Definition: device_addr.hpp:38
size_t device_index
The device index (or motherboard index).
Definition: block_ctrl_base.hpp:46
Definition: node_ctrl_base.hpp:31