16#include <unordered_map>
17#include <boost/format.hpp>
20namespace uhd {
namespace rfnoc {
37 write_memory[addr] = data;
38 _poke_cb(addr, data, time, ack);
42 const std::vector<uint32_t> data,
46 if (addrs.size() != data.size()) {
49 for (
size_t i = 0; i < addrs.size(); i++) {
50 poke32(addrs[i], data[i], time, ack);
55 const std::vector<uint32_t> data,
59 for (
size_t i = 0; i < data.size(); i++) {
60 poke32(first_addr + 4 * i, data[i], timestamp, ack);
68 return read_memory.at(addr);
69 }
catch (
const std::out_of_range&) {
71 str(boost::format(
"No data defined for address: 0x%04X") % addr));
78 std::vector<uint32_t> result(length, 0);
79 for (
size_t i = 0; i < length; ++i) {
80 result[i] = peek32(first_addr + i * 4, time);
96 if ((peek32(addr, time) &
mask) == data) {
97 UHD_LOG_INFO(
"MOCK_REG_IFACE",
"poll32() successful at addr " << addr);
99 UHD_LOG_INFO(
"MOCK_REG_IFACE",
"poll32() not successful at addr " << addr);
121 "Requested to set policy for " << name <<
" to " << args.
to_string());
134 bool force_timeout =
false;
164 template <
typename block_type = noc_block_base>
167 return std::dynamic_pointer_cast<block_type>(factory(std::move(make_args)));
182 const size_t num_inputs = 1,
183 const size_t num_outputs = 1,
185 const size_t mtu = 8000,
187 std::shared_ptr<mock_reg_iface_t> client_reg_iface =
nullptr);
Definition: device_addr.hpp:38
std::string to_string(void) const
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:217
Definition: mock_block.hpp:27
void poll32(uint32_t addr, uint32_t data, uint32_t mask, uhd::time_spec_t, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool=false)
Definition: mock_block.hpp:85
mock_reg_iface_t()=default
void multi_poke32(const std::vector< uint32_t > addrs, const std::vector< uint32_t > data, uhd::time_spec_t time, bool ack)
Definition: mock_block.hpp:41
std::vector< uint32_t > block_peek32(uint32_t first_addr, size_t length, uhd::time_spec_t time)
Definition: mock_block.hpp:75
std::unordered_map< uint32_t, uint32_t > write_memory
All peeks read from this map. A peek will fail if the address has not.
Definition: mock_block.hpp:140
void register_async_msg_handler(async_msg_callback_t)
Definition: mock_block.hpp:113
virtual void _peek_cb(uint32_t, uhd::time_spec_t)
Definition: mock_block.hpp:148
uint16_t get_port_num() const
Definition: mock_block.hpp:129
uint16_t get_src_epid() const
Definition: mock_block.hpp:124
void poke32(uint32_t addr, uint32_t data, uhd::time_spec_t time, bool ack)
Definition: mock_block.hpp:35
void sleep(uhd::time_spec_t, bool)
Definition: mock_block.hpp:103
uint32_t peek32(uint32_t addr, uhd::time_spec_t time)
Definition: mock_block.hpp:64
std::unordered_map< uint32_t, uint32_t > read_memory
All pokes end up writing to this map.
Definition: mock_block.hpp:137
void set_policy(const std::string &name, const uhd::device_addr_t &args)
Definition: mock_block.hpp:118
void register_async_msg_validator(async_msg_validator_t)
Definition: mock_block.hpp:108
virtual void _poke_cb(uint32_t, uint32_t, uhd::time_spec_t, bool)
Definition: mock_block.hpp:143
void block_poke32(uint32_t first_addr, const std::vector< uint32_t > data, uhd::time_spec_t timestamp, bool ack)
Definition: mock_block.hpp:54
virtual ~mock_reg_iface_t()=default
std::unique_ptr< make_args_t > make_args_ptr
Opaque pointer to the constructor arguments.
Definition: noc_block_base.hpp:53
std::shared_ptr< noc_block_base > sptr
Definition: noc_block_base.hpp:47
Definition: register_iface.hpp:28
std::function< void(uint32_t addr, const std::vector< uint32_t > &data, boost::optional< uint64_t >)> async_msg_callback_t
Definition: register_iface.hpp:56
std::function< bool(uint32_t addr, const std::vector< uint32_t > &data)> async_msg_validator_t
Definition: register_iface.hpp:43
Definition: time_spec.hpp:31
static constexpr double ASAP
Definition: time_spec.hpp:34
#define UHD_API
Definition: config.h:67
#define UHD_LOG_INFO(component,...)
Definition: log.h:55
uint16_t device_type_t
Device Type.
Definition: defaults.hpp:58
uint32_t noc_id_t
Definition: defaults.hpp:54
UHD_API mock_block_container get_mock_block(const noc_id_t noc_id, const size_t num_inputs=1, const size_t num_outputs=1, const uhd::device_addr_t &args=uhd::device_addr_t(), const size_t mtu=8000, const device_type_t device_id=ANY_DEVICE, std::shared_ptr< mock_reg_iface_t > client_reg_iface=nullptr)
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:87
Definition: build_info.hpp:12
Definition: exception.hpp:252
Definition: mock_block.hpp:154
uhd::property_tree::sptr tree
Reference to the prop tree object the block sees.
Definition: mock_block.hpp:160
std::shared_ptr< block_type > get_block()
Use this to retrieve a reference to the block controller. Make sure that.
Definition: mock_block.hpp:165
std::function< noc_block_base::sptr(noc_block_base::make_args_ptr)> factory
Factory to get the block. Use get_block() instead.
Definition: mock_block.hpp:171
std::shared_ptr< mock_reg_iface_t > reg_iface
Reference to the register interface object.
Definition: mock_block.hpp:157
noc_block_base::make_args_ptr make_args
Definition: mock_block.hpp:176
Definition: exception.hpp:133
Definition: exception.hpp:109