From 49520bfecb5e13126224ee915208c2cd936f911c Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 1 Nov 2016 16:45:29 -0700 Subject: rfnoc: ctrl_iface cleanup - ctrl_iface is now longer a wb_iface. All it can do now is send command packets, and receive responses to those. - ctrl_iface does not store command time or tick rate - wb_iface_adapter is no longer a set of functors, but a wrapper around ctrl_iface. Command times are stored once, in the block. - DMA FIFO and radio block controllers have an easier time getting access to a timed_wb_iface --- host/tests/device3_test.cpp | 63 +++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'host/tests') diff --git a/host/tests/device3_test.cpp b/host/tests/device3_test.cpp index a5639a346..62b90920e 100644 --- a/host/tests/device3_test.cpp +++ b/host/tests/device3_test.cpp @@ -5,14 +5,15 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include -#include -#include +#include "../lib/rfnoc/ctrl_iface.hpp" #include #include #include #include #include +#include +#include +#include using namespace uhd; using namespace uhd::rfnoc; @@ -22,39 +23,35 @@ static const sid_t TEST_SID0 = 0x00000200; // 0.0.2.0 static const sid_t TEST_SID1 = 0x00000210; // 0.0.2.F // Pseudo-wb-iface -class pseudo_wb_iface_impl : public uhd::wb_iface +class pseudo_ctrl_iface_impl : public ctrl_iface { public: - pseudo_wb_iface_impl() {}; - ~pseudo_wb_iface_impl() {}; - - void poke64(const wb_addr_type addr, const uint64_t data) { - std::cout << str(boost::format("[PSEUDO] poke64 to addr: %016X, data == %016X") % addr % data) << std::endl; - }; - - uint64_t peek64(const wb_addr_type addr) { - std::cout << str(boost::format("[PSEUDO] peek64 to addr: %016X") % addr) << std::endl; - switch (addr) { - case SR_READBACK_REG_ID: - return TEST_NOC_ID; - case SR_READBACK_REG_FIFOSIZE: - return 0x000000000000000B; - case SR_READBACK_REG_USER: - return 0x0123456789ABCDEF; - default: - return 0; + pseudo_ctrl_iface_impl() {}; + ~pseudo_ctrl_iface_impl() {}; + + uint64_t send_cmd_pkt( + const size_t addr, + const size_t data, + const bool readback=false, + const uint64_t timestamp=0 + ) { + if (not readback) { + std::cout << str(boost::format("[PSEUDO] poke to addr: %016X, data == %016X") % addr % data) << std::endl; + } else { + std::cout << str(boost::format("[PSEUDO] peek64 to addr: %016X") % data) << std::endl; + switch (data) { + case SR_READBACK_REG_ID: + return TEST_NOC_ID; + case SR_READBACK_REG_FIFOSIZE: + return 0x000000000000000B; + case SR_READBACK_REG_USER: + return 0x0123456789ABCDEF; + default: + return 0; + } } return 0; } - - void poke32(const wb_addr_type addr, const uint32_t data) { - std::cout << str(boost::format("poke32 to addr: %08X, data == %08X") % addr % data) << std::endl; - } - - uint32_t peek32(const wb_addr_type addr) { - std::cout << str(boost::format("peek32 to addr: %08X") % addr) << std::endl; - return 0; - } }; // Pseudo-device @@ -67,8 +64,8 @@ class pseudo_device3_impl : public uhd::device3 _tree->create("/name").set("Test Pseudo-Device3"); // We can re-use this: - std::map ctrl_ifaces = boost::assign::map_list_of - (0, wb_iface::sptr(new pseudo_wb_iface_impl())) + std::map ctrl_ifaces = boost::assign::map_list_of + (0, ctrl_iface::sptr(new pseudo_ctrl_iface_impl())) ; // Add two block controls: -- cgit v1.2.3