Loading...
Searching...
No Matches
noc_block_base.hpp
Go to the documentation of this file.
//
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <uhd/property_tree.hpp>
#include <uhd/rfnoc/block_id.hpp>
#include <uhd/rfnoc/defaults.hpp>
#include <uhd/rfnoc/node.hpp>
#include <uhd/rfnoc/register_iface_holder.hpp>
#include <uhd/rfnoc/rfnoc_types.hpp>
#include <uhd/types/device_addr.hpp>
#define RFNOC_BLOCK_CONSTRUCTOR(CLASS_NAME) \
CLASS_NAME##_impl(make_args_ptr make_args) : CLASS_NAME(std::move(make_args))
#define RFNOC_DECLARE_BLOCK(CLASS_NAME) \
using sptr = std::shared_ptr<CLASS_NAME>; \
CLASS_NAME(make_args_ptr make_args) : noc_block_base(std::move(make_args)) {}
namespace uhd { namespace rfnoc {
class clock_iface;
class mb_controller;
class UHD_API noc_block_base : public node_t, public register_iface_holder
{
public:
using sptr = std::shared_ptr<noc_block_base>;
struct make_args_t;
using make_args_ptr = std::unique_ptr<make_args_t>;
~noc_block_base() override;
/**************************************************************************
* node_t API calls
*************************************************************************/
std::string get_unique_id() const override
{
return get_block_id().to_string();
}
size_t get_num_input_ports() const override
{
return _num_input_ports;
}
size_t get_num_output_ports() const override
{
return _num_output_ports;
}
/**************************************************************************
* RFNoC-block specific API calls
*************************************************************************/
noc_id_t get_noc_id() const
{
return _noc_id;
}
const block_id_t& get_block_id() const
{
return _block_id;
}
double get_tick_rate() const;
size_t get_mtu(const res_source_info& edge);
size_t get_chdr_hdr_len(const bool account_for_ts = true) const;
size_t get_max_payload_size(
const res_source_info& edge, const bool account_for_ts = true);
uhd::device_addr_t get_block_args() const
{
return _block_args;
}
uhd::property_tree::sptr& get_tree() const
{
return _tree;
}
uhd::property_tree::sptr& get_tree()
{
return _tree;
}
std::shared_ptr<mb_controller> get_mb_controller();
protected:
noc_block_base(make_args_ptr make_args);
void set_num_input_ports(const size_t num_ports);
void set_num_output_ports(const size_t num_ports);
void set_tick_rate(const double tick_rate);
void set_mtu_forwarding_policy(const forwarding_policy_t policy);
void set_mtu(const res_source_info& edge, const size_t new_mtu);
property_base_t* get_mtu_prop_ref(const res_source_info& edge);
virtual void deinit();
private:
friend class block_initializer;
void _set_tick_rate(const double tick_rate);
void shutdown() override;
void post_init();
/**************************************************************************
* Attributes
**************************************************************************/
noc_id_t _noc_id;
//
// The framework will guarantee that no one else has the same block ID
block_id_t _block_id;
size_t _num_input_ports;
size_t _num_output_ports;
// for all in- and output edges.
std::vector<property_t<double>> _tick_rate_props;
forwarding_policy_t _mtu_fwd_policy = forwarding_policy_t::ONE_TO_ONE;
bool _mtu_fwd_policy_set = false;
// for all in- and output edges.
std::vector<property_t<size_t>> _mtu_props;
std::unordered_map<res_source_info, size_t> _mtu;
chdr_w_t _chdr_w;
std::shared_ptr<clock_iface> _ctrlport_clock_iface;
std::shared_ptr<clock_iface> _tb_clock_iface;
// block had requested and was granted access
std::shared_ptr<mb_controller> _mb_controller;
const uhd::device_addr_t _block_args;
//
// It is mutable because _tree->access<>(..).get() is not const, but we
// need to do just that in some const contexts
mutable uhd::property_tree::sptr _tree;
}; // class noc_block_base
}} /* namespace uhd::rfnoc */
#include <uhd/rfnoc/noc_block_make_args.hpp>
block_id.hpp
uhd::device_addr_t
Definition device_addr.hpp:39
uhd::property_tree::sptr
std::shared_ptr< property_tree > sptr
Definition property_tree.hpp:224
uhd::rfnoc::block_id_t
Definition block_id.hpp:40
uhd::rfnoc::noc_block_base::get_block_args
uhd::device_addr_t get_block_args() const
Definition noc_block_base.hpp:183
uhd::rfnoc::noc_block_base::make_args_ptr
std::unique_ptr< make_args_t > make_args_ptr
Opaque pointer to the constructor arguments.
Definition noc_block_base.hpp:54
uhd::rfnoc::noc_block_base::set_mtu_forwarding_policy
void set_mtu_forwarding_policy(const forwarding_policy_t policy)
uhd::rfnoc::noc_block_base::get_num_output_ports
size_t get_num_output_ports() const override
Definition noc_block_base.hpp:86
uhd::rfnoc::noc_block_base::get_mtu
size_t get_mtu(const res_source_info &edge)
uhd::rfnoc::noc_block_base::block_initializer
friend class block_initializer
Definition noc_block_base.hpp:318
uhd::rfnoc::noc_block_base::set_mtu
void set_mtu(const res_source_info &edge, const size_t new_mtu)
uhd::rfnoc::noc_block_base::get_max_payload_size
size_t get_max_payload_size(const res_source_info &edge, const bool account_for_ts=true)
uhd::rfnoc::noc_block_base::get_tick_rate
double get_tick_rate() const
uhd::rfnoc::noc_block_base::set_num_input_ports
void set_num_input_ports(const size_t num_ports)
uhd::rfnoc::noc_block_base::get_num_input_ports
size_t get_num_input_ports() const override
Definition noc_block_base.hpp:74
uhd::rfnoc::noc_block_base::deinit
virtual void deinit()
uhd::rfnoc::noc_block_base::get_unique_id
std::string get_unique_id() const override
Unique ID for an RFNoC block is its block ID.
Definition noc_block_base.hpp:62
uhd::rfnoc::noc_block_base::noc_block_base
noc_block_base(make_args_ptr make_args)
uhd::rfnoc::noc_block_base::get_tree
uhd::property_tree::sptr & get_tree() const
Return a reference to this block's subtree.
Definition noc_block_base.hpp:189
uhd::rfnoc::noc_block_base::get_chdr_hdr_len
size_t get_chdr_hdr_len(const bool account_for_ts=true) const
uhd::rfnoc::noc_block_base::~noc_block_base
~noc_block_base() override
uhd::rfnoc::noc_block_base::get_tree
uhd::property_tree::sptr & get_tree()
Return a reference to this block's subtree (non-const version).
Definition noc_block_base.hpp:195
uhd::rfnoc::noc_block_base::get_noc_id
noc_id_t get_noc_id() const
Definition noc_block_base.hpp:98
uhd::rfnoc::noc_block_base::get_mb_controller
std::shared_ptr< mb_controller > get_mb_controller()
uhd::rfnoc::noc_block_base::sptr
std::shared_ptr< noc_block_base > sptr
Definition noc_block_base.hpp:48
uhd::rfnoc::noc_block_base::get_block_id
const block_id_t & get_block_id() const
Definition noc_block_base.hpp:107
uhd::rfnoc::noc_block_base::get_mtu_prop_ref
property_base_t * get_mtu_prop_ref(const res_source_info &edge)
uhd::rfnoc::noc_block_base::set_tick_rate
void set_tick_rate(const double tick_rate)
uhd::rfnoc::noc_block_base::set_num_output_ports
void set_num_output_ports(const size_t num_ports)
uhd::rfnoc::node_t::node_t
node_t()
uhd::rfnoc::node_t::forwarding_policy_t
forwarding_policy_t
Types of property/action forwarding for those not defined by the block itself.
Definition node.hpp:46
uhd::rfnoc::node_t::forwarding_policy_t::ONE_TO_ONE
@ ONE_TO_ONE
Forward the property/action to the opposite port with the same index.
Definition node.hpp:49
uhd::rfnoc::property_base_t
Definition property.hpp:26
uhd::rfnoc::register_iface_holder::register_iface_holder
register_iface_holder(register_iface::sptr reg)
Definition register_iface_holder.hpp:21
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
defaults.hpp
device_addr.hpp
uhd::rfnoc::noc_id_t
uint32_t noc_id_t
Definition defaults.hpp:52
uhd::rfnoc::chdr_w_t
chdr_w_t
Type that indicates the CHDR Width in bits.
Definition rfnoc_types.hpp:19
uhd
Definition build_info.hpp:12
noc_block_make_args.hpp
node.hpp
property_tree.hpp
register_iface_holder.hpp
rfnoc_types.hpp
uhd::rfnoc::noc_block_base::make_args_t
Definition noc_block_make_args.hpp:25
uhd::rfnoc::res_source_info
Definition res_source_info.hpp:18