17 #include <unordered_map> 18 #include <boost/format.hpp> 21 namespace uhd {
namespace rfnoc {
38 write_memory[addr] = data;
39 _poke_cb(addr, data, time, ack);
43 const std::vector<uint32_t> data,
47 if (addrs.size() != data.size()) {
50 for (
size_t i = 0; i < addrs.size(); i++) {
51 poke32(addrs[i], data[i], time, ack);
56 const std::vector<uint32_t> data,
60 for (
size_t i = 0; i < data.size(); i++) {
61 poke32(first_addr + 4 * i, data[i], timestamp, ack);
69 return read_memory.at(addr);
70 }
catch (
const std::out_of_range&) {
72 str(boost::format(
"No data defined for address: 0x%04X") % addr));
79 std::vector<uint32_t> result(length, 0);
80 for (
size_t i = 0; i < length; ++i) {
81 result[i] = peek32(first_addr + i * 4, time);
91 bool =
false)
override 97 if ((peek32(addr, time) & mask) == data) {
98 UHD_LOG_INFO(
"MOCK_REG_IFACE",
"poll32() successful at addr " << addr);
100 UHD_LOG_INFO(
"MOCK_REG_IFACE",
"poll32() not successful at addr " << addr);
122 "Requested to set policy for " << name <<
" to " << args.
to_string());
135 bool force_timeout =
false;
165 template <
typename block_type = noc_block_base>
168 return std::dynamic_pointer_cast<block_type>(factory(std::move(make_args)));
172 std::function<noc_block_base::sptr(noc_block_base::make_args_ptr)>
factory;
183 const size_t num_inputs = 1,
184 const size_t num_outputs = 1,
186 const size_t mtu = 8000,
188 std::shared_ptr<mock_reg_iface_t> client_reg_iface =
nullptr,
void multi_poke32(const std::vector< uint32_t > addrs, const std::vector< uint32_t > data, uhd::time_spec_t time, bool ack) override
Definition: mock_block.hpp:42
std::string to_string(void) const
#define UHD_LOG_INFO(component,...)
Definition: log.h:53
virtual void _peek_cb(uint32_t, uhd::time_spec_t)
Definition: mock_block.hpp:149
uint32_t peek32(uint32_t addr, uhd::time_spec_t time) override
Definition: mock_block.hpp:65
Definition: time_spec.hpp:28
Definition: mock_block.hpp:27
Definition: exception.hpp:131
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) override
Definition: mock_block.hpp:86
static constexpr double ASAP
Definition: time_spec.hpp:34
uint16_t get_src_epid() const override
Definition: mock_block.hpp:125
Definition: exception.hpp:107
void register_async_msg_validator(async_msg_validator_t) override
Definition: mock_block.hpp:109
void set_policy(const std::string &name, const uhd::device_addr_t &args) override
Definition: mock_block.hpp:119
Definition: build_info.hpp:12
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, mb_controller::sptr mbc=nullptr)
void poke32(uint32_t addr, uint32_t data, uhd::time_spec_t time, bool ack) override
Definition: mock_block.hpp:36
virtual void _poke_cb(uint32_t, uint32_t, uhd::time_spec_t, bool)
Definition: mock_block.hpp:144
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:172
noc_block_base::make_args_ptr make_args
Definition: mock_block.hpp:177
std::function< bool(uint32_t addr, const std::vector< uint32_t > &data)> async_msg_validator_t
Definition: register_iface.hpp:43
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
uint16_t device_type_t
Device Type.
Definition: defaults.hpp:55
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:141
std::shared_ptr< mock_reg_iface_t > reg_iface
Reference to the register interface object.
Definition: mock_block.hpp:158
std::shared_ptr< mb_controller > sptr
Definition: mb_controller.hpp:30
#define UHD_API
Definition: config.h:87
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:86
Definition: exception.hpp:250
void sleep(uhd::time_spec_t, bool) override
Definition: mock_block.hpp:104
uint32_t noc_id_t
Definition: defaults.hpp:51
std::unordered_map< uint32_t, uint32_t > read_memory
All pokes end up writing to this map.
Definition: mock_block.hpp:138
uint16_t get_port_num() const override
Definition: mock_block.hpp:130
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:223
uhd::property_tree::sptr tree
Reference to the prop tree object the block sees.
Definition: mock_block.hpp:161
std::unique_ptr< make_args_t > make_args_ptr
Opaque pointer to the constructor arguments.
Definition: noc_block_base.hpp:54
Definition: mock_block.hpp:154
std::shared_ptr< block_type > get_block()
Use this to retrieve a reference to the block controller. Make sure that.
Definition: mock_block.hpp:166
void register_async_msg_handler(async_msg_callback_t) override
Definition: mock_block.hpp:114
Definition: register_iface.hpp:27
Definition: device_addr.hpp:37
void block_poke32(uint32_t first_addr, const std::vector< uint32_t > data, uhd::time_spec_t timestamp, bool ack) override
Definition: mock_block.hpp:55
std::vector< uint32_t > block_peek32(uint32_t first_addr, size_t length, uhd::time_spec_t time) override
Definition: mock_block.hpp:76