diff options
Diffstat (limited to 'host/lib/rfnoc')
26 files changed, 317 insertions, 285 deletions
diff --git a/host/lib/rfnoc/block_ctrl_base.cpp b/host/lib/rfnoc/block_ctrl_base.cpp index a6eecc20b..e9d6c0030 100644 --- a/host/lib/rfnoc/block_ctrl_base.cpp +++ b/host/lib/rfnoc/block_ctrl_base.cpp @@ -20,16 +20,15 @@ #include "ctrl_iface.hpp" #include "nocscript/block_iface.hpp" -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> #include <uhd/rfnoc/constants.hpp> #include <boost/format.hpp> -#include <boost/foreach.hpp> #include <boost/bind.hpp> -#define UHD_BLOCK_LOG() UHD_LOGV(never) +#define UHD_BLOCK_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd; using namespace uhd::rfnoc; @@ -48,17 +47,16 @@ inline uint32_t _sr_to_addr64(uint32_t reg) { return reg * 8; }; // for peek64 block_ctrl_base::block_ctrl_base( const make_args_t &make_args ) : _tree(make_args.tree), - _transport_is_big_endian(make_args.is_big_endian), _ctrl_ifaces(make_args.ctrl_ifaces), _base_address(make_args.base_address & 0xFFF0) { - UHD_BLOCK_LOG() << "block_ctrl_base()" << std::endl; + UHD_BLOCK_LOG() << "block_ctrl_base()" ; /*** Identify this block (NoC-ID, block-ID, and block definition) *******/ // Read NoC-ID (name is passed in through make_args): uint64_t noc_id = sr_read64(SR_READBACK_REG_ID); _block_def = blockdef::make_from_noc_id(noc_id); - if (_block_def) UHD_BLOCK_LOG() << "Found valid blockdef" << std::endl; + if (_block_def) UHD_BLOCK_LOG() << "Found valid blockdef" ; if (not _block_def) _block_def = blockdef::make_from_noc_id(DEFAULT_NOC_ID); UHD_ASSERT_THROW(_block_def); @@ -70,7 +68,7 @@ block_ctrl_base::block_ctrl_base( } UHD_BLOCK_LOG() << "NOC ID: " << str(boost::format("0x%016X ") % noc_id) - << "Block ID: " << _block_id << std::endl; + << "Block ID: " << _block_id ; /*** Initialize property tree *******************************************/ _root_path = "xbar/" + _block_id.get_local(); @@ -81,7 +79,7 @@ block_ctrl_base::block_ctrl_base( /*** Configure ports ****************************************************/ size_t n_valid_input_buffers = 0; - BOOST_FOREACH(const size_t ctrl_port, get_ctrl_ports()) { + for(const size_t ctrl_port: get_ctrl_ports()) { // Set source addresses: sr_write(SR_BLOCK_SID, get_address(ctrl_port), ctrl_port); // Set sink buffer sizes: @@ -95,7 +93,7 @@ block_ctrl_base::block_ctrl_base( /*** Register names *****************************************************/ blockdef::registers_t sregs = _block_def->get_settings_registers(); - BOOST_FOREACH(const std::string ®_name, sregs.keys()) { + for(const std::string ®_name: sregs.keys()) { if (DEFAULT_NAMED_SR.has_key(reg_name)) { throw uhd::runtime_error(str( boost::format("Register name %s is already defined!") @@ -106,7 +104,7 @@ block_ctrl_base::block_ctrl_base( .set(sregs.get(reg_name)); } blockdef::registers_t rbacks = _block_def->get_readback_registers(); - BOOST_FOREACH(const std::string ®_name, rbacks.keys()) { + for(const std::string ®_name: rbacks.keys()) { _tree->create<size_t>(_root_path / "registers"/ "rb" / reg_name) .set(rbacks.get(reg_name)); } @@ -116,10 +114,10 @@ block_ctrl_base::block_ctrl_base( _init_port_defs("out", _block_def->get_output_ports()); // FIXME this warning always fails until the input buffer code above is fixed if (_tree->list(_root_path / "ports/in").size() != n_valid_input_buffers) { - UHD_MSG(warning) << + UHD_LOGGER_WARNING("RFNOC") << boost::format("[%s] defines %d input buffer sizes, but %d input ports") % get_block_id().get() % n_valid_input_buffers % _tree->list(_root_path / "ports/in").size() - << std::endl; + ; } /*** Init default block args ********************************************/ @@ -138,14 +136,14 @@ void block_ctrl_base::_init_port_defs( const size_t first_port_index ) { size_t port_index = first_port_index; - BOOST_FOREACH(const blockdef::port_t &port_def, ports) { + for(const blockdef::port_t &port_def: ports) { fs_path port_path = _root_path / "ports" / direction / port_index; if (not _tree->exists(port_path)) { _tree->create<blockdef::port_t>(port_path); } UHD_RFNOC_BLOCK_TRACE() << "Adding port definition at " << port_path << boost::format(": type = '%s' pkt_size = '%s' vlen = '%s'") % port_def["type"] % port_def["pkt_size"] % port_def["vlen"] - << std::endl; + ; _tree->access<blockdef::port_t>(port_path).set(port_def); port_index++; } @@ -155,12 +153,12 @@ void block_ctrl_base::_init_block_args() { blockdef::args_t args = _block_def->get_args(); fs_path arg_path = _root_path / "args"; - BOOST_FOREACH(const size_t port, get_ctrl_ports()) { + for(const size_t port: get_ctrl_ports()) { _tree->create<std::string>(arg_path / port); } // First, create all nodes. - BOOST_FOREACH(const blockdef::arg_t &arg, args) { + for(const blockdef::arg_t &arg: args) { fs_path arg_type_path = arg_path / arg["port"] / arg["name"] / "type"; _tree->create<std::string>(arg_type_path).set(arg["type"]); fs_path arg_val_path = arg_path / arg["port"] / arg["name"] / "value"; @@ -174,7 +172,7 @@ void block_ctrl_base::_init_block_args() // TODO: Add coercer #define _SUBSCRIBE_CHECK_AND_RUN(type, arg_tag, error_message) \ _tree->access<type>(arg_val_path).add_coerced_subscriber(boost::bind((&nocscript::block_iface::run_and_check), _nocscript_iface, arg[#arg_tag], error_message)) - BOOST_FOREACH(const blockdef::arg_t &arg, args) { + for(const blockdef::arg_t &arg: args) { fs_path arg_val_path = arg_path / arg["port"] / arg["name"] / "value"; if (not arg["check"].empty()) { if (arg["type"] == "string") { _SUBSCRIBE_CHECK_AND_RUN(string, check, arg["check_message"]); } @@ -193,7 +191,7 @@ void block_ctrl_base::_init_block_args() } // Finally: Set the values. This will call subscribers, if we have any. - BOOST_FOREACH(const blockdef::arg_t &arg, args) { + for(const blockdef::arg_t &arg: args) { fs_path arg_val_path = arg_path / arg["port"] / arg["name"] / "value"; if (not arg["value"].empty()) { if (arg["type"] == "int_vector") { throw uhd::runtime_error("not yet implemented: int_vector"); } @@ -218,7 +216,7 @@ std::vector<size_t> block_ctrl_base::get_ctrl_ports() const std::vector<size_t> ctrl_ports; ctrl_ports.reserve(_ctrl_ifaces.size()); std::pair<size_t, wb_iface::sptr> it; - BOOST_FOREACH(it, _ctrl_ifaces) { + for(auto it: _ctrl_ifaces) { ctrl_ports.push_back(it.first); } return ctrl_ports; @@ -227,7 +225,7 @@ std::vector<size_t> block_ctrl_base::get_ctrl_ports() const void block_ctrl_base::sr_write(const uint32_t reg, const uint32_t data, const size_t port) { //UHD_BLOCK_LOG() << " "; - //UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%d, %08X, %d)") % reg % data % port << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%d, %08X, %d)") % reg % data % port ; if (not _ctrl_ifaces.count(port)) { throw uhd::key_error(str(boost::format("[%s] sr_write(): No such port: %d") % get_block_id().get() % port)); } @@ -254,7 +252,7 @@ void block_ctrl_base::sr_write(const std::string ®, const uint32_t data, cons reg_addr = uint32_t(_tree->access<size_t>(_root_path / "registers" / "sr" / reg).get()); } UHD_BLOCK_LOG() << " "; - UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%s, %08X) ==> ") % reg % data << std::endl; + UHD_RFNOC_BLOCK_TRACE() << boost::format("sr_write(%s, %08X) ==> ") % reg % data ; return sr_write(reg_addr, data, port); } @@ -341,7 +339,7 @@ void block_ctrl_base::set_command_time( const size_t port ) { if (port == ANY_PORT) { - BOOST_FOREACH(const size_t specific_port, get_ctrl_ports()) { + for(const size_t specific_port: get_ctrl_ports()) { set_command_time(time_spec, specific_port); } return; @@ -379,7 +377,7 @@ void block_ctrl_base::set_command_tick_rate( const size_t port ) { if (port == ANY_PORT) { - BOOST_FOREACH(const size_t specific_port, get_ctrl_ports()) { + for(const size_t specific_port: get_ctrl_ports()) { set_command_tick_rate(tick_rate, specific_port); } return; @@ -412,11 +410,11 @@ void block_ctrl_base::clear_command_time(const size_t port) void block_ctrl_base::clear() { - UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::clear() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::clear() " ; // Call parent... node_ctrl_base::clear(); // ...then child - BOOST_FOREACH(const size_t port_index, get_ctrl_ports()) { + for(const size_t port_index: get_ctrl_ports()) { _clear(port_index); } } @@ -431,7 +429,7 @@ uint32_t block_ctrl_base::get_address(size_t block_port) { **********************************************************************/ void block_ctrl_base::set_args(const uhd::device_addr_t &args, const size_t port) { - BOOST_FOREACH(const std::string &key, args.keys()) { + for(const std::string &key: args.keys()) { if (_tree->exists(get_arg_path(key, port))) { set_arg(key, args.get(key), port); } @@ -474,7 +472,7 @@ void block_ctrl_base::set_arg(const std::string &key, const std::string &val, co device_addr_t block_ctrl_base::get_args(const size_t port) const { device_addr_t args; - BOOST_FOREACH(const std::string &key, _tree->list(_root_path / "args" / port)) { + for(const std::string &key: _tree->list(_root_path / "args" / port)) { args[key] = get_arg(key); } return args; @@ -535,7 +533,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def } else { stream_sig.item_type = port_def["type"]; } - //UHD_RFNOC_BLOCK_TRACE() << " item type: " << stream_sig.item_type << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << " item type: " << stream_sig.item_type ; // Vector length if (port_def.is_variable("vlen")) { @@ -546,7 +544,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def } else { stream_sig.vlen = boost::lexical_cast<size_t>(port_def["vlen"]); } - //UHD_RFNOC_BLOCK_TRACE() << " vector length: " << stream_sig.vlen << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << " vector length: " << stream_sig.vlen ; // Packet size if (port_def.is_variable("pkt_size")) { @@ -568,7 +566,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def } else { stream_sig.packet_size = boost::lexical_cast<size_t>(port_def["pkt_size"]); } - //UHD_RFNOC_BLOCK_TRACE() << " packet size: " << stream_sig.vlen << std::endl; + //UHD_RFNOC_BLOCK_TRACE() << " packet size: " << stream_sig.vlen ; return stream_sig; } @@ -579,7 +577,7 @@ stream_sig_t block_ctrl_base::_resolve_port_def(const blockdef::port_t &port_def **********************************************************************/ void block_ctrl_base::_clear(const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::_clear() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "block_ctrl_base::_clear() " ; sr_write(SR_CLEAR_TX_FC, 0x00C1EA12, port); // 'CLEAR', but we can write anything, really sr_write(SR_CLEAR_RX_FC, 0x00C1EA12, port); // 'CLEAR', but we can write anything, really } diff --git a/host/lib/rfnoc/block_ctrl_base_factory.cpp b/host/lib/rfnoc/block_ctrl_base_factory.cpp index 0e2d5ae03..9e32b81d7 100644 --- a/host/lib/rfnoc/block_ctrl_base_factory.cpp +++ b/host/lib/rfnoc/block_ctrl_base_factory.cpp @@ -16,12 +16,12 @@ // #include <boost/format.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/rfnoc/blockdef.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> -#define UHD_FACTORY_LOG() UHD_LOGV(never) +#define UHD_FACTORY_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd; using namespace uhd::rfnoc; @@ -59,7 +59,7 @@ static void lookup_block_key(uint64_t noc_id, make_args_t &make_args) make_args.block_name = bd->get_name(); return; } catch (std::exception &e) { - UHD_MSG(warning) << str(boost::format("Error while looking up name for NoC-ID %016X.\n%s") % noc_id % e.what()) << std::endl; + UHD_LOGGER_WARNING("RFNOC") << str(boost::format("Error while looking up name for NoC-ID %016X.\n%s") % noc_id % e.what()) ; } make_args.block_key = DEFAULT_BLOCK_NAME; @@ -71,7 +71,7 @@ block_ctrl_base::sptr block_ctrl_base::make( const make_args_t &make_args_, uint64_t noc_id ) { - UHD_FACTORY_LOG() << "[RFNoC Factory] block_ctrl_base::make() " << std::endl; + UHD_FACTORY_LOG() << "[RFNoC Factory] block_ctrl_base::make() " ; make_args_t make_args = make_args_; // Check if a block key was specified, in this case, we *must* either @@ -90,7 +90,7 @@ block_ctrl_base::sptr block_ctrl_base::make( make_args.block_name = make_args.block_key; } - UHD_FACTORY_LOG() << "[RFNoC Factory] Using controller key '" << make_args.block_key << "' and block name '" << make_args.block_name << "'" << std::endl; + UHD_FACTORY_LOG() << "[RFNoC Factory] Using controller key '" << make_args.block_key << "' and block name '" << make_args.block_name << "'" ; return get_block_fcn_regs()[make_args.block_key](make_args); } diff --git a/host/lib/rfnoc/blockdef_xml_impl.cpp b/host/lib/rfnoc/blockdef_xml_impl.cpp index 78d1995d1..5f8af232d 100644 --- a/host/lib/rfnoc/blockdef_xml_impl.cpp +++ b/host/lib/rfnoc/blockdef_xml_impl.cpp @@ -18,10 +18,9 @@ #include <uhd/exception.hpp> #include <uhd/rfnoc/constants.hpp> #include <uhd/rfnoc/blockdef.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/paths.hpp> #include <boost/assign/list_of.hpp> -#include <boost/foreach.hpp> #include <boost/format.hpp> #include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> @@ -57,7 +56,7 @@ blockdef::port_t::port_t() { // This guarantees that we can access these keys // even if they were never initialized: - BOOST_FOREACH(const std::string &key, PORT_ARGS.keys()) { + for(const std::string &key: PORT_ARGS.keys()) { set(key, PORT_ARGS[key]); } } @@ -77,7 +76,7 @@ bool blockdef::port_t::is_keyword(const std::string &key) const bool blockdef::port_t::is_valid() const { // Check we have all the keys: - BOOST_FOREACH(const std::string &key, PORT_ARGS.keys()) { + for(const std::string &key: PORT_ARGS.keys()) { if (not has_key(key)) { return false; } @@ -90,7 +89,7 @@ bool blockdef::port_t::is_valid() const std::string blockdef::port_t::to_string() const { std::string result; - BOOST_FOREACH(const std::string &key, PORT_ARGS.keys()) { + for(const std::string &key: PORT_ARGS.keys()) { if (has_key(key)) { result += str(boost::format("%s=%s,") % key % get(key)); } @@ -125,7 +124,7 @@ blockdef::arg_t::arg_t() { // This guarantees that we can access these keys // even if they were never initialized: - BOOST_FOREACH(const std::string &key, ARG_ARGS.keys()) { + for(const std::string &key: ARG_ARGS.keys()) { set(key, ARG_ARGS[key]); } } @@ -133,7 +132,7 @@ blockdef::arg_t::arg_t() bool blockdef::arg_t::is_valid() const { // 1. Check we have all the keys: - BOOST_FOREACH(const std::string &key, ARG_ARGS.keys()) { + for(const std::string &key: ARG_ARGS.keys()) { if (not has_key(key)) { return false; } @@ -151,7 +150,7 @@ bool blockdef::arg_t::is_valid() const std::string blockdef::arg_t::to_string() const { std::string result; - BOOST_FOREACH(const std::string &key, ARG_ARGS.keys()) { + for(const std::string &key: ARG_ARGS.keys()) { if (has_key(key)) { result += str(boost::format("%s=%s,") % key % get(key)); } @@ -218,13 +217,13 @@ public: pt::ptree propt; try { read_xml(filename.string(), propt); - BOOST_FOREACH(pt::ptree::value_type &v, propt.get_child("nocblock.ids")) { + for(pt::ptree::value_type &v: propt.get_child("nocblock.ids")) { if (v.first == "id" and match_noc_id(v.second.data(), noc_id)) { return true; } } } catch (std::exception &e) { - UHD_MSG(warning) << "has_noc_id(): caught exception " << e.what() << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "has_noc_id(): caught exception " << e.what() ; return false; } return false; @@ -234,7 +233,7 @@ public: _type(type), _noc_id(noc_id) { - //UHD_MSG(status) << "Reading XML file: " << filename.string().c_str() << std::endl; + //UHD_LOGGER_INFO("RFNOC") << "Reading XML file: " << filename.string().c_str() ; read_xml(filename.string(), _pt); try { // Check key is valid @@ -302,11 +301,11 @@ public: std::set<size_t> port_numbers; size_t n_ports = 0; ports_t ports; - BOOST_FOREACH(pt::ptree::value_type &v, _pt.get_child("nocblock.ports")) { + for(pt::ptree::value_type &v: _pt.get_child("nocblock.ports")) { if (v.first != port_type) continue; // Now we have the correct sink or source node: port_t port; - BOOST_FOREACH(const std::string &key, port_t::PORT_ARGS.keys()) { + for(const std::string &key: port_t::PORT_ARGS.keys()) { port[key] = v.second.get(key, port_t::PORT_ARGS[key]); } // We have to be extra-careful with the port numbers: @@ -338,10 +337,10 @@ public: std::vector<size_t> get_all_port_numbers() { std::set<size_t> set_ports; - BOOST_FOREACH(const port_t &port, get_input_ports()) { + for(const port_t &port: get_input_ports()) { set_ports.insert(boost::lexical_cast<size_t>(port["port"])); } - BOOST_FOREACH(const port_t &port, get_output_ports()) { + for(const port_t &port: get_output_ports()) { set_ports.insert(boost::lexical_cast<size_t>(port["port"])); } return std::vector<size_t>(set_ports.begin(), set_ports.end()); @@ -353,17 +352,17 @@ public: args_t args; bool is_valid = true; pt::ptree def; - BOOST_FOREACH(pt::ptree::value_type &v, _pt.get_child("nocblock.args", def)) { + for(pt::ptree::value_type &v: _pt.get_child("nocblock.args", def)) { arg_t arg; if (v.first != "arg") continue; - BOOST_FOREACH(const std::string &key, arg_t::ARG_ARGS.keys()) { + for(const std::string &key: arg_t::ARG_ARGS.keys()) { arg[key] = v.second.get(key, arg_t::ARG_ARGS[key]); } if (arg["type"].empty()) { arg["type"] = "string"; } if (not arg.is_valid()) { - UHD_MSG(warning) << boost::format("Found invalid argument: %s") % arg.to_string() << std::endl; + UHD_LOGGER_WARNING("RFNOC") << boost::format("Found invalid argument: %s") % arg.to_string() ; is_valid = false; } args.push_back(arg); @@ -391,7 +390,7 @@ public: { registers_t registers; pt::ptree def; - BOOST_FOREACH(pt::ptree::value_type &v, _pt.get_child("nocblock.registers", def)) { + for(pt::ptree::value_type &v: _pt.get_child("nocblock.registers", def)) { if (v.first != reg_type) continue; registers[v.second.get<std::string>("name")] = boost::lexical_cast<size_t>(v.second.get<size_t>("address")); @@ -419,7 +418,7 @@ blockdef::sptr blockdef::make_from_noc_id(uint64_t noc_id) std::vector<fs::path> valid; // Check if any of the paths exist - BOOST_FOREACH(const fs::path &base_path, paths) { + for(const fs::path &base_path: paths) { fs::path this_path = base_path / XML_BLOCKS_SUBDIR; if (fs::exists(this_path) and fs::is_directory(this_path)) { valid.push_back(this_path); @@ -436,7 +435,7 @@ blockdef::sptr blockdef::make_from_noc_id(uint64_t noc_id) } // Iterate over all paths - BOOST_FOREACH(const fs::path &path, valid) { + for(const fs::path &path: valid) { // Iterate over all .xml files fs::directory_iterator end_itr; for (fs::directory_iterator i(path); i != end_itr; ++i) { diff --git a/host/lib/rfnoc/ctrl_iface.cpp b/host/lib/rfnoc/ctrl_iface.cpp index b2ac1778e..3a16f7ec1 100644 --- a/host/lib/rfnoc/ctrl_iface.cpp +++ b/host/lib/rfnoc/ctrl_iface.cpp @@ -16,9 +16,8 @@ // #include "ctrl_iface.hpp" -#include "async_packet_handler.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/byteswap.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/transport/bounded_buffer.hpp> @@ -37,7 +36,6 @@ using namespace uhd::transport; static const double ACK_TIMEOUT = 2.0; //supposed to be worst case practical timeout static const double MASSIVE_TIMEOUT = 10.0; //for when we wait on a timed command -static const size_t SR_READBACK = 32; ctrl_iface::~ctrl_iface(void){ /* NOP */ @@ -60,13 +58,12 @@ public: _name(name), _seq_out(0), _timeout(ACK_TIMEOUT), - _resp_queue(128/*max response msgs*/), - _resp_queue_size(_resp_xport ? _resp_xport->get_num_recv_frames() : 3), + _resp_queue_size(_resp_xport->get_num_recv_frames()), _rb_address(uhd::rfnoc::SR_READBACK) { - if (resp_xport) { - while (resp_xport->get_recv_buff(0.0)) {} //flush - } + UHD_ASSERT_THROW(_ctrl_xport); + UHD_ASSERT_THROW(_resp_xport); + while (resp_xport->get_recv_buff(0.0)) {} //flush this->set_time(uhd::time_spec_t(0.0)); this->set_tick_rate(1.0); //something possible but bogus } @@ -76,7 +73,6 @@ public: _timeout = ACK_TIMEOUT; //reset timeout to something small UHD_SAFE_CALL( this->peek32(0);//dummy peek with the purpose of ack'ing all packets - _async_task.reset();//now its ok to release the task ) } @@ -172,7 +168,7 @@ private: //load payload pkt[packet_info.num_header_words32+0] = (_bige)? uhd::htonx(addr) : uhd::htowx(addr); pkt[packet_info.num_header_words32+1] = (_bige)? uhd::htonx(data) : uhd::htowx(data); - //UHD_MSG(status) << boost::format("0x%08x, 0x%08x\n") % addr % data; + //UHD_LOGGER_INFO("RFNOC") << boost::format("0x%08x, 0x%08x\n") % addr % data; //send the buffer over the interface _outstanding_seqs.push(_seq_out); buff->commit(sizeof(uint32_t)*(packet_info.num_packet_words32)); @@ -196,50 +192,16 @@ private: uint32_t const *pkt = NULL; managed_recv_buffer::sptr buff; - //get buffer from response endpoint - or die in timeout - if (_resp_xport) - { - buff = _resp_xport->get_recv_buff(_timeout); - try - { - UHD_ASSERT_THROW(bool(buff)); - UHD_ASSERT_THROW(buff->size() > 0); - } - catch(const std::exception &ex) - { - throw uhd::io_error(str(boost::format("Block ctrl (%s) no response packet - %s") % _name % ex.what())); - } - pkt = buff->cast<const uint32_t *>(); - packet_info.num_packet_words32 = buff->size()/sizeof(uint32_t); + buff = _resp_xport->get_recv_buff(_timeout); + try { + UHD_ASSERT_THROW(bool(buff)); + UHD_ASSERT_THROW(buff->size() > 0); } - - //get buffer from response endpoint - or die in timeout - else - { - /* - * Couldn't get message with haste. - * Now check both possible queues for messages. - * Messages should come in on _resp_queue, - * but could end up in dump_queue. - * If we don't get a message --> Die in timeout. - */ - double accum_timeout = 0.0; - const double short_timeout = 0.005; // == 5ms - while(not ((_resp_queue.pop_with_haste(resp_buff)) - || (check_dump_queue(resp_buff)) - || (_resp_queue.pop_with_timed_wait(resp_buff, short_timeout)) - )){ - /* - * If a message couldn't be received within a given timeout - * --> throw AssertionError! - */ - accum_timeout += short_timeout; - UHD_ASSERT_THROW(accum_timeout < _timeout); - } - - pkt = resp_buff.data; - packet_info.num_packet_words32 = sizeof(resp_buff)/sizeof(uint32_t); + catch(const std::exception &ex) { + throw uhd::io_error(str(boost::format("Block ctrl (%s) no response packet - %s") % _name % ex.what())); } + pkt = buff->cast<const uint32_t *>(); + packet_info.num_packet_words32 = buff->size()/sizeof(uint32_t); //parse the buffer try @@ -250,15 +212,15 @@ private: } catch(const std::exception &ex) { - UHD_MSG(error) << "[" << _name << "] Block ctrl bad VITA packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("RFNOC") << "[" << _name << "] Block ctrl bad VITA packet: " << ex.what() ; if (buff){ - UHD_MSG(status) << boost::format("%08X") % pkt[0] << std::endl; - UHD_MSG(status) << boost::format("%08X") % pkt[1] << std::endl; - UHD_MSG(status) << boost::format("%08X") % pkt[2] << std::endl; - UHD_MSG(status) << boost::format("%08X") % pkt[3] << std::endl; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[0] ; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[1] ; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[2] ; + UHD_LOGGER_INFO("RFNOC") << boost::format("%08X") % pkt[3] ; } else{ - UHD_MSG(status) << "buff is NULL" << std::endl; + UHD_LOGGER_INFO("RFNOC") << "buff is NULL" ; } } @@ -306,48 +268,11 @@ private: return 0; } - /* - * If ctrl_core waits for a message that didn't arrive it can search for it in the dump queue. - * This actually happens during shutdown. - * handle_async_task can't access queue anymore thus it returns the corresponding message. - * msg_task class implements a dump_queue to store such messages. - * With check_dump_queue we can check if a message we are waiting for got stranded there. - * If a message got stuck we get it here and push it onto our own message_queue. - */ - bool check_dump_queue(resp_buff_type& b) { - const size_t min_buff_size = 8; // Same value as in b200_io_impl->handle_async_task - uint32_t recv_sid = (((_sid)<<16)|((_sid)>>16)); - uhd::msg_task::msg_payload_t msg; - do{ - msg = _async_task->get_msg_from_dump_queue(recv_sid); - } - while(msg.size() < min_buff_size && msg.size() != 0); - - if(msg.size() >= min_buff_size) { - memcpy(b.data, &msg.front(), std::min(msg.size(), sizeof(b.data))); - return true; - } - return false; - } - - void push_response(const uint32_t *buff) - { - resp_buff_type resp_buff; - std::memcpy(resp_buff.data, buff, sizeof(resp_buff)); - _resp_queue.push_with_haste(resp_buff); - } - - void hold_task(uhd::msg_task::sptr task) - { - _async_task = task; - } - const vrt::if_packet_info_t::link_type_t _link_type; const vrt::if_packet_info_t::packet_type_t _packet_type; const bool _bige; const uhd::transport::zero_copy_if::sptr _ctrl_xport; const uhd::transport::zero_copy_if::sptr _resp_xport; - uhd::msg_task::sptr _async_task; const uint32_t _sid; const std::string _name; boost::mutex _mutex; @@ -357,7 +282,6 @@ private: double _tick_rate; double _timeout; std::queue<size_t> _outstanding_seqs; - bounded_buffer<resp_buff_type> _resp_queue; const size_t _resp_queue_size; const size_t _rb_address; diff --git a/host/lib/rfnoc/ctrl_iface.hpp b/host/lib/rfnoc/ctrl_iface.hpp index 3690874f9..5e88c3dd6 100644 --- a/host/lib/rfnoc/ctrl_iface.hpp +++ b/host/lib/rfnoc/ctrl_iface.hpp @@ -47,18 +47,6 @@ public: const std::string &name = "0" ); - //! Hold a ref to a task thats feeding push response - virtual void hold_task(uhd::msg_task::sptr task) = 0; - - //! Push a response externall (resp_xport is NULL) - virtual void push_response(const uint32_t *buff) = 0; - - //! Set the command time that will activate - virtual void set_time(const uhd::time_spec_t &time) = 0; - - //! Get the command time that will activate - virtual uhd::time_spec_t get_time(void) = 0; - //! Set the tick rate (converting time into ticks) virtual void set_tick_rate(const double rate) = 0; }; diff --git a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp index 8c8b07afd..b0b510cde 100644 --- a/host/lib/rfnoc/ddc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/ddc_block_ctrl_impl.cpp @@ -17,7 +17,7 @@ #include "dsp_core_utils.hpp" #include <uhd/rfnoc/ddc_block_ctrl.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/types/ranges.hpp> #include <boost/math/special_functions/round.hpp> @@ -150,10 +150,10 @@ public: const uhd::stream_cmd_t &stream_cmd_, const size_t chan ) { - UHD_RFNOC_BLOCK_TRACE() << "ddc_block_ctrl_base::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "ddc_block_ctrl_base::issue_stream_cmd()" ; if (list_upstream_nodes().count(chan) == 0) { - UHD_MSG(status) << "No upstream blocks." << std::endl; + UHD_LOGGER_INFO("RFNOC") << "No upstream blocks." ; return; } @@ -241,7 +241,7 @@ private: sr_write("M", 1, chan); if (decim > 1 and hb_enable == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("RFNOC") << boost::format( "The requested decimation is odd; the user should expect passband CIC rolloff.\n" "Select an even decimation to ensure that a halfband filter is enabled.\n" "Decimations factorable by 4 will enable 2 halfbands, those factorable by 8 will enable 3 halfbands.\n" diff --git a/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp b/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp index aea7c591c..93f599314 100644 --- a/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp @@ -19,7 +19,7 @@ #include "dma_fifo_core_3000.hpp" #include "wb_iface_adapter.hpp" #include <uhd/convert.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/wb_iface.hpp> #include <boost/make_shared.hpp> #include <boost/thread/mutex.hpp> @@ -64,18 +64,18 @@ public: _perifs[i].depth = DEFAULT_SIZE; _perifs[i].core = dma_fifo_core_3000::make(_perifs[i].ctrl, USER_SR_BASE, USER_RB_BASE); _perifs[i].core->resize(_perifs[i].base_addr, _perifs[i].depth); - UHD_MSG(status) << boost::format("[DMA FIFO] Running BIST for FIFO %d... ") % i; + UHD_LOGGER_INFO("RFNOC") << boost::format("[DMA FIFO] Running BIST for FIFO %d... ") % i; if (_perifs[i].core->ext_bist_supported()) { uint32_t bisterr = _perifs[i].core->run_bist(); if (bisterr != 0) { throw uhd::runtime_error(str(boost::format("BIST failed! (code: %d)\n") % bisterr)); } else { double throughput = _perifs[i].core->get_bist_throughput(BUS_CLK_RATE); - UHD_MSG(status) << (boost::format("pass (Throughput: %.1fMB/s)") % (throughput/1e6)) << std::endl; + UHD_LOGGER_INFO("RFNOC") << (boost::format("pass (Throughput: %.1fMB/s)") % (throughput/1e6)) ; } } else { if (_perifs[i].core->run_bist() == 0) { - UHD_MSG(status) << "pass\n"; + UHD_LOGGER_INFO("RFNOC") << "pass\n"; } else { throw uhd::runtime_error("BIST failed!\n"); } diff --git a/host/lib/rfnoc/duc_block_ctrl_impl.cpp b/host/lib/rfnoc/duc_block_ctrl_impl.cpp index d755bf519..d0742a6d0 100644 --- a/host/lib/rfnoc/duc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/duc_block_ctrl_impl.cpp @@ -17,7 +17,7 @@ #include "dsp_core_utils.hpp" #include <uhd/rfnoc/duc_block_ctrl.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/types/ranges.hpp> #include <boost/math/special_functions/round.hpp> @@ -141,7 +141,7 @@ public: const uhd::stream_cmd_t &stream_cmd_, const size_t chan ) { - UHD_RFNOC_BLOCK_TRACE() << "duc_block_ctrl_base::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "duc_block_ctrl_base::issue_stream_cmd()" ; uhd::stream_cmd_t stream_cmd = stream_cmd_; if (stream_cmd.stream_mode == uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE or @@ -150,7 +150,7 @@ public: stream_cmd.num_samps *= interpolation; } - BOOST_FOREACH(const node_ctrl_base::node_map_pair_t upstream_node, list_upstream_nodes()) { + for(const node_ctrl_base::node_map_pair_t upstream_node: list_upstream_nodes()) { source_node_ctrl::sptr this_upstream_block_ctrl = boost::dynamic_pointer_cast<source_node_ctrl>(upstream_node.second.lock()); this_upstream_block_ctrl->issue_stream_cmd(stream_cmd, chan); @@ -226,7 +226,7 @@ private: sr_write("M", std::pow(2.0, double(hb_enable)) * (interp & 0xff), chan); if (interp > 1 and hb_enable == 0) { - UHD_MSG(warning) << boost::format( + UHD_LOGGER_WARNING("RFNOC") << boost::format( "The requested interpolation is odd; the user should expect passband CIC rolloff.\n" "Select an even interpolation to ensure that a halfband filter is enabled.\n" "interpolation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" diff --git a/host/lib/rfnoc/graph_impl.cpp b/host/lib/rfnoc/graph_impl.cpp index 64c6f6abe..005e23815 100644 --- a/host/lib/rfnoc/graph_impl.cpp +++ b/host/lib/rfnoc/graph_impl.cpp @@ -18,7 +18,7 @@ #include "graph_impl.hpp" #include <uhd/rfnoc/source_block_ctrl_base.hpp> #include <uhd/rfnoc/sink_block_ctrl_base.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd::rfnoc; @@ -85,10 +85,10 @@ void graph_impl::connect( dst->set_upstream_port(actual_dst_block_port, actual_src_block_port); // At this point, ports are locked and no one else can simply connect // into them. - //UHD_MSG(status) + //UHD_LOGGER_INFO("RFNOC") //<< "[" << _name << "] Connecting " //<< src_block << ":" << actual_src_block_port << " --> " - //<< dst_block << ":" << actual_dst_block_port << std::endl; + //<< dst_block << ":" << actual_dst_block_port ; /******************************************************************** * 2. Check IO signatures match @@ -120,7 +120,7 @@ void graph_impl::connect( ********************************************************************/ size_t pkt_size = (pkt_size_ != 0) ? pkt_size_ : src->get_output_signature(src_block_port).packet_size; if (pkt_size == 0) { // Unspecified packet rate. Assume max packet size. - UHD_MSG(status) << "Assuming max packet size for " << src->get_block_id() << std::endl; + UHD_LOGGER_INFO("RFNOC") << "Assuming max packet size for " << src->get_block_id() ; pkt_size = uhd::rfnoc::MAX_PACKET_SIZE; } // FC window (in packets) depends on FIFO size... ...and packet size. diff --git a/host/lib/rfnoc/legacy_compat.cpp b/host/lib/rfnoc/legacy_compat.cpp index bf653a89a..70fe067f8 100644 --- a/host/lib/rfnoc/legacy_compat.cpp +++ b/host/lib/rfnoc/legacy_compat.cpp @@ -26,14 +26,14 @@ #include <uhd/types/stream_cmd.hpp> #include <uhd/types/direction.hpp> #include <uhd/types/ranges.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/transport/chdr.hpp> #include <uhd/usrp/multi_usrp.hpp> #include <boost/make_shared.hpp> #include <boost/assign.hpp> -#define UHD_LEGACY_LOG() UHD_LOGV(never) +#define UHD_LEGACY_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd::rfnoc; using uhd::usrp::subdev_spec_t; @@ -97,16 +97,6 @@ size_t calc_num_tx_chans_per_radio( ); } -double lambda_const_double(const double d) -{ - return d; -} - -uhd::meta_range_t lambda_const_meta_range(const double start, const double stop, const double step) -{ - return uhd::meta_range_t(start, stop, step); -} - /*! Recreate passed property without bound subscribers. Maintains current property value. */ template <typename T> @@ -115,6 +105,7 @@ static void recreate_property(const uhd::fs_path &path, uhd::property_tree::sptr tree->remove(path); tree->create<T>(path).set(temp); } + /************************************************************************ * Class Definition ***********************************************************************/ @@ -154,16 +145,16 @@ public: } connect_blocks(); if (args.has_key("skip_ddc")) { - UHD_LEGACY_LOG() << "[legacy_compat] Skipping DDCs by user request." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Skipping DDCs by user request." ; } else if (not _has_ddcs) { - UHD_MSG(warning) + UHD_LOGGER_WARNING("RFNOC") << "[legacy_compat] No DDCs detected. You will only be able to receive at the radio frontend rate." - << std::endl; + ; } if (args.has_key("skip_duc")) { - UHD_LEGACY_LOG() << "[legacy_compat] Skipping DUCs by user request." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Skipping DUCs by user request." ; } else if (not _has_ducs) { - UHD_MSG(warning) << "[legacy_compat] No DUCs detected. You will only be able to transmit at the radio frontend rate." << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "[legacy_compat] No DUCs detected. You will only be able to transmit at the radio frontend rate." ; } if (args.has_key("skip_dram")) { UHD_LEGACY_LOG() << "[legacy_compat] Skipping DRAM by user request." << std::endl; @@ -172,7 +163,7 @@ public: UHD_LEGACY_LOG() << "[legacy_compat] Skipping SRAM by user request." << std::endl; } if (not _has_dmafifo and not _has_sramfifo) { - UHD_MSG(warning) << "[legacy_compat] No FIFO detected. Higher transmit rates may encounter errors." << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "[legacy_compat] No FIFO detected. Higher transmit rates may encounter errors."; } for (size_t mboard = 0; mboard < _num_mboards; mboard++) { @@ -256,7 +247,7 @@ public: void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t mboard, size_t chan) { - UHD_LEGACY_LOG() << "[legacy_compat] issue_stream_cmd() " << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] issue_stream_cmd() " ; const size_t &radio_index = _rx_channel_map[mboard][chan].radio_index; const size_t &port_index = _rx_channel_map[mboard][chan].port_index; if (_has_ddcs) { @@ -274,9 +265,9 @@ public: args.otw_format = "sc16"; } _update_stream_args_for_streaming<uhd::RX_DIRECTION>(args, _rx_channel_map); - UHD_LEGACY_LOG() << "[legacy_compat] rx stream args: " << args.args.to_string() << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] rx stream args: " << args.args.to_string() ; uhd::rx_streamer::sptr streamer = _device->get_rx_stream(args); - BOOST_FOREACH(const size_t chan, args.channels) { + for(const size_t chan: args.channels) { _rx_stream_cache[chan] = streamer; } return streamer; @@ -291,9 +282,9 @@ public: args.otw_format = "sc16"; } _update_stream_args_for_streaming<uhd::TX_DIRECTION>(args, _tx_channel_map); - UHD_LEGACY_LOG() << "[legacy_compat] tx stream args: " << args.args.to_string() << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] tx stream args: " << args.args.to_string() ; uhd::tx_streamer::sptr streamer = _device->get_tx_stream(args); - BOOST_FOREACH(const size_t chan, args.channels) { + for(const size_t chan: args.channels) { _tx_stream_cache[chan] = streamer; } return streamer; @@ -347,14 +338,14 @@ public: if (_rx_stream_cache.count(chan)) { uhd::rx_streamer::sptr str_ptr = _rx_stream_cache[chan].lock(); if (str_ptr) { - BOOST_FOREACH(const rx_stream_map_type::value_type &chan_streamer_pair, _rx_stream_cache) { + for(const rx_stream_map_type::value_type &chan_streamer_pair: _rx_stream_cache) { if (chan_streamer_pair.second.lock() == str_ptr) { chans_to_change.insert(chan_streamer_pair.first); } } } } - BOOST_FOREACH(const size_t this_chan, chans_to_change) { + for(const size_t this_chan: chans_to_change) { size_t mboard, mb_chan; chan_to_mcp<uhd::RX_DIRECTION>(this_chan, _rx_channel_map, mboard, mb_chan); const size_t dsp_index = _rx_channel_map[mboard][mb_chan].radio_index; @@ -390,14 +381,14 @@ public: if (_tx_stream_cache.count(chan)) { uhd::tx_streamer::sptr str_ptr = _tx_stream_cache[chan].lock(); if (str_ptr) { - BOOST_FOREACH(const tx_stream_map_type::value_type &chan_streamer_pair, _tx_stream_cache) { + for(const tx_stream_map_type::value_type &chan_streamer_pair: _tx_stream_cache) { if (chan_streamer_pair.second.lock() == str_ptr) { chans_to_change.insert(chan_streamer_pair.first); } } } } - BOOST_FOREACH(const size_t this_chan, chans_to_change) { + for(const size_t this_chan: chans_to_change) { size_t mboard, mb_chan; chan_to_mcp<uhd::TX_DIRECTION>(this_chan, _tx_channel_map, mboard, mb_chan); const size_t dsp_index = _tx_channel_map[mboard][mb_chan].radio_index; @@ -590,7 +581,7 @@ private: // methods const size_t this_spp = get_block_ctrl<radio_ctrl>(i, RADIO_BLOCK_NAME, k)->get_arg<int>("spp"); if (this_spp != _rx_spp) { - UHD_LOG << str( + UHD_LOGGER_WARNING("RFNOC") << str( boost::format("[legacy compat] Radios have differing spp values: %s has %d, others have %d. UHD will use smaller spp value for all connections. Performance might be not optimal.") % radio_block_id.to_string() % this_spp % _rx_spp ); @@ -653,10 +644,10 @@ private: // methods ) ; _tree->create<double>(rx_dsp_base_path / "freq/value") - .set_publisher(boost::bind(&lambda_const_double, 0.0)) + .set_publisher([](){ return 0.0; }) ; _tree->create<uhd::meta_range_t>(rx_dsp_base_path / "freq/range") - .set_publisher(boost::bind(&lambda_const_meta_range, 0.0, 0.0, 0.0)) + .set_publisher([](){ return uhd::meta_range_t(0.0, 0.0, 0.0); }) ; } } @@ -686,10 +677,10 @@ private: // methods ) ; _tree->create<double>(tx_dsp_base_path / "freq/value") - .set_publisher(boost::bind(&lambda_const_double, 0.0)) + .set_publisher([](){ return 0.0; }) ; _tree->create<uhd::meta_range_t>(tx_dsp_base_path / "freq/range") - .set_publisher(boost::bind(&lambda_const_meta_range, 0.0, 0.0, 0.0)) + .set_publisher([](){ return uhd::meta_range_t(0.0, 0.0, 0.0); }) ; } } @@ -898,7 +889,7 @@ legacy_compat::sptr legacy_compat::make( if (legacy_cache.count(device.get()) and not legacy_cache.at(device.get()).expired()) { legacy_compat::sptr legacy_compat_copy = legacy_cache.at(device.get()).lock(); UHD_ASSERT_THROW(bool(legacy_compat_copy)); - UHD_LEGACY_LOG() << "[legacy_compat] Using existing legacy compat object for this device." << std::endl; + UHD_LEGACY_LOG() << "[legacy_compat] Using existing legacy compat object for this device." ; return legacy_compat_copy; } diff --git a/host/lib/rfnoc/nocscript/block_iface.cpp b/host/lib/rfnoc/nocscript/block_iface.cpp index 0d301e5bc..544593def 100644 --- a/host/lib/rfnoc/nocscript/block_iface.cpp +++ b/host/lib/rfnoc/nocscript/block_iface.cpp @@ -18,12 +18,12 @@ #include "block_iface.hpp" #include "function_table.hpp" #include <uhd/exception.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/assign.hpp> #include <boost/bind.hpp> #include <boost/format.hpp> -#define UHD_NOCSCRIPT_LOG() UHD_LOGV(never) +#define UHD_NOCSCRIPT_LOG() UHD_LOGGER_TRACE("RFNOC") using namespace uhd::rfnoc; using namespace uhd::rfnoc::nocscript; @@ -116,7 +116,7 @@ void block_iface::run_and_check(const std::string &code, const std::string &erro { boost::mutex::scoped_lock local_interpreter_lock(_lil_mutex); - UHD_NOCSCRIPT_LOG() << "[NocScript] Executing and asserting code: " << code << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Executing and asserting code: " << code ; expression::sptr e = _parser->create_expr_tree(code); expression_literal result = e->eval(); if (not result.to_bool()) { @@ -143,12 +143,12 @@ expression_literal block_iface::_nocscript__sr_write(expression_container::expr_ const uint32_t reg_val = uint32_t(args[1]->eval().get_int()); bool result = true; try { - UHD_NOCSCRIPT_LOG() << "[NocScript] Executing SR_WRITE() " << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Executing SR_WRITE() " ; _block_ptr->sr_write(reg_name, reg_val); } catch (const uhd::exception &e) { - UHD_MSG(error) << boost::format("[NocScript] Error while executing SR_WRITE(%s, 0x%X):\n%s") + UHD_LOGGER_ERROR("RFNOC") << boost::format("[NocScript] Error while executing SR_WRITE(%s, 0x%X):\n%s") % reg_name % reg_val % e.what() - << std::endl; + ; result = false; } @@ -195,7 +195,7 @@ expression_literal block_iface::_nocscript__arg_set_int(const expression_contain if (args.size() == 3) { port = size_t(args[2]->eval().get_int()); } - UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name ; _block_ptr->set_arg<int>(var_name, val, port); return expression_literal(true); } @@ -208,7 +208,7 @@ expression_literal block_iface::_nocscript__arg_set_string(const expression_cont if (args.size() == 3) { port = size_t(args[2]->eval().get_int()); } - UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name ; _block_ptr->set_arg<std::string>(var_name, val, port); return expression_literal(true); } @@ -221,7 +221,7 @@ expression_literal block_iface::_nocscript__arg_set_double(const expression_cont if (args.size() == 3) { port = size_t(args[2]->eval().get_int()); } - UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name << std::endl; + UHD_NOCSCRIPT_LOG() << "[NocScript] Setting $" << var_name ; _block_ptr->set_arg<double>(var_name, val, port); return expression_literal(true); } @@ -239,8 +239,8 @@ block_iface::sptr block_iface::make(uhd::rfnoc::block_ctrl_base* block_ptr) expression_literal block_iface::_nocscript__var_get(const expression_container::expr_list_type &args) { expression_literal expr = _vars[args[0]->eval().get_string()]; - //std::cout << "[NocScript] Getting var " << args[0]->eval().get_string() << " == " << expr << std::endl; - //std::cout << "[NocScript] Type " << expr.infer_type() << std::endl; + //std::cout << "[NocScript] Getting var " << args[0]->eval().get_string() << " == " << expr ; + //std::cout << "[NocScript] Type " << expr.infer_type() ; //return _vars[args[0]->eval().get_string()]; return expr; } @@ -248,8 +248,8 @@ expression_literal block_iface::_nocscript__var_get(const expression_container:: expression_literal block_iface::_nocscript__var_set(const expression_container::expr_list_type &args) { _vars[args[0]->eval().get_string()] = args[1]->eval(); - //std::cout << "[NocScript] Set var " << args[0]->eval().get_string() << " to " << _vars[args[0]->eval().get_string()] << std::endl; - //std::cout << "[NocScript] Type " << _vars[args[0]->eval().get_string()].infer_type() << std::endl; + //std::cout << "[NocScript] Set var " << args[0]->eval().get_string() << " to " << _vars[args[0]->eval().get_string()] ; + //std::cout << "[NocScript] Type " << _vars[args[0]->eval().get_string()].infer_type() ; return expression_literal(true); } diff --git a/host/lib/rfnoc/nocscript/expression.cpp b/host/lib/rfnoc/nocscript/expression.cpp index 38d6e2128..257e0b447 100644 --- a/host/lib/rfnoc/nocscript/expression.cpp +++ b/host/lib/rfnoc/nocscript/expression.cpp @@ -18,7 +18,6 @@ #include "expression.hpp" #include "function_table.hpp" #include <uhd/utils/cast.hpp> -#include <boost/foreach.hpp> #include <boost/format.hpp> #include <boost/assign.hpp> #include <boost/algorithm/string.hpp> @@ -77,7 +76,7 @@ expression_literal::expression_literal( std::string str_vec = _val.substr(1, _val.size()-2); std::vector<std::string> subtoken_list; boost::split(subtoken_list, str_vec, boost::is_any_of(", "), boost::token_compress_on); - BOOST_FOREACH(const std::string &t, subtoken_list) { + for(const std::string &t: subtoken_list) { _int_vector_val.push_back(boost::lexical_cast<int>(t)); } break; @@ -299,7 +298,7 @@ expression_literal expression_container::eval() } expression_literal ret_val; - BOOST_FOREACH(const expression::sptr &sub_expr, _sub_exprs) { + for(const expression::sptr &sub_expr: _sub_exprs) { ret_val = sub_expr->eval(); if (_combiner == COMBINE_AND and ret_val.to_bool() == false) { return ret_val; @@ -319,7 +318,7 @@ std::string expression_function::to_string(const std::string &name, const argtyp { std::string s = name; int arg_count = 0; - BOOST_FOREACH(const expression::type_t type, types) { + for(const expression::type_t type: types) { if (arg_count == 0) { s += "("; } else { diff --git a/host/lib/rfnoc/nocscript/function_table.cpp b/host/lib/rfnoc/nocscript/function_table.cpp index a4e36c1a1..aabaef635 100644 --- a/host/lib/rfnoc/nocscript/function_table.cpp +++ b/host/lib/rfnoc/nocscript/function_table.cpp @@ -18,7 +18,6 @@ #include "function_table.hpp" #include "basic_functions.hpp" #include <boost/bind.hpp> -#include <boost/foreach.hpp> #include <boost/format.hpp> #include <map> diff --git a/host/lib/rfnoc/node_ctrl_base.cpp b/host/lib/rfnoc/node_ctrl_base.cpp index b4d0a30ff..e9424d319 100644 --- a/host/lib/rfnoc/node_ctrl_base.cpp +++ b/host/lib/rfnoc/node_ctrl_base.cpp @@ -16,7 +16,7 @@ // #include <uhd/rfnoc/node_ctrl_base.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <boost/range/adaptor/map.hpp> using namespace uhd::rfnoc; @@ -30,7 +30,7 @@ std::string node_ctrl_base::unique_id() const void node_ctrl_base::clear() { - UHD_RFNOC_BLOCK_TRACE() << "node_ctrl_base::clear() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "node_ctrl_base::clear() " ; // Reset connections: _upstream_nodes.clear(); _downstream_nodes.clear(); diff --git a/host/lib/rfnoc/radio_ctrl_impl.cpp b/host/lib/rfnoc/radio_ctrl_impl.cpp index c43d39f71..69c9fb68c 100644 --- a/host/lib/rfnoc/radio_ctrl_impl.cpp +++ b/host/lib/rfnoc/radio_ctrl_impl.cpp @@ -16,11 +16,10 @@ // #include "wb_iface_adapter.hpp" -#include <boost/foreach.hpp> #include <boost/format.hpp> #include <boost/bind.hpp> #include <uhd/convert.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/direction.hpp> #include "radio_ctrl_impl.hpp" @@ -30,6 +29,7 @@ using namespace uhd; using namespace uhd::rfnoc; static const size_t BYTES_PER_SAMPLE = 4; +const std::string radio_ctrl::ALL_LOS = "all"; /**************************************************************************** * Structors and init @@ -137,7 +137,6 @@ radio_ctrl_impl::radio_ctrl_impl() : void radio_ctrl_impl::_register_loopback_self_test(size_t chan) { - UHD_MSG(status) << "[RFNoC Radio] Performing register loopback test... " << std::flush; size_t hash = size_t(time(NULL)); for (size_t i = 0; i < 100; i++) { @@ -145,12 +144,12 @@ void radio_ctrl_impl::_register_loopback_self_test(size_t chan) sr_write(regs::TEST, uint32_t(hash), chan); uint32_t result = user_reg_read32(regs::RB_TEST, chan); if (result != uint32_t(hash)) { - UHD_MSG(status) << "fail" << std::endl; - UHD_MSG(status) << boost::format("expected: %x result: %x") % uint32_t(hash) % result << std::endl; + UHD_LOGGER_ERROR("RFNOC RADIO") << "Register loopback test failed"; + UHD_LOGGER_ERROR("RFNOC RADIO") << boost::format("expected: %x result: %x") % uint32_t(hash) % result ; return; // exit on any failure } } - UHD_MSG(status) << "pass" << std::endl; + UHD_LOGGER_INFO("RFNOC RADIO") << "Register loopback test passed"; } /**************************************************************************** @@ -196,6 +195,11 @@ double radio_ctrl_impl::set_rx_gain(const double gain, const size_t chan) return _rx_gain[chan] = gain; } +double radio_ctrl_impl::set_rx_bandwidth(const double bandwidth, const size_t chan) +{ + return _rx_bandwidth[chan] = bandwidth; +} + void radio_ctrl_impl::set_time_sync(const uhd::time_spec_t &time) { _time64->set_time_sync(time); @@ -236,6 +240,56 @@ double radio_ctrl_impl::get_rx_gain(const size_t chan) /* const */ return _rx_gain[chan]; } +double radio_ctrl_impl::get_rx_bandwidth(const size_t chan) /* const */ +{ + return _rx_bandwidth[chan]; +} + +std::vector<std::string> radio_ctrl_impl::get_rx_lo_names(const size_t /* chan */) +{ + return std::vector<std::string>(); +} + +std::vector<std::string> radio_ctrl_impl::get_rx_lo_sources(const std::string & /* name */, const size_t /* chan */) +{ + return std::vector<std::string>(); +} + +freq_range_t radio_ctrl_impl::get_rx_lo_freq_range(const std::string & /* name */, const size_t /* chan */) +{ + return freq_range_t(); +} + +void radio_ctrl_impl::set_rx_lo_source(const std::string & /* src */, const std::string & /* name */, const size_t /* chan */) +{ + throw uhd::not_implemented_error("set_rx_lo_source is not supported on this radio"); +} + +const std::string radio_ctrl_impl::get_rx_lo_source(const std::string & /* name */, const size_t /* chan */) +{ + return "internal"; +} + +void radio_ctrl_impl::set_rx_lo_export_enabled(bool /* enabled */, const std::string & /* name */, const size_t /* chan */) +{ + throw uhd::not_implemented_error("set_rx_lo_export_enabled is not supported on this radio"); +} + +bool radio_ctrl_impl::get_rx_lo_export_enabled(const std::string & /* name */, const size_t /* chan */) +{ + return false; // Not exporting non-existant LOs +} + +double radio_ctrl_impl::set_rx_lo_freq(double /* freq */, const std::string & /* name */, const size_t /* chan */) +{ + throw uhd::not_implemented_error("set_rx_lo_freq is not supported on this radio"); +} + +double radio_ctrl_impl::get_rx_lo_freq(const std::string & /* name */, const size_t /* chan */) +{ + return 0; +} + /*********************************************************************** * RX Streamer-related methods (from source_block_ctrl_base) **********************************************************************/ @@ -243,9 +297,9 @@ double radio_ctrl_impl::get_rx_gain(const size_t chan) /* const */ void radio_ctrl_impl::issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd, const size_t chan) { boost::mutex::scoped_lock lock(_mutex); - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() " << chan << " " << char(stream_cmd.stream_mode) << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() " << chan << " " << char(stream_cmd.stream_mode) ; if (not _is_streamer_active(uhd::RX_DIRECTION, chan)) { - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() called on inactive channel. Skipping." << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::issue_stream_cmd() called on inactive channel. Skipping." ; return; } UHD_ASSERT_THROW(stream_cmd.num_samps <= 0x0fffffff); @@ -284,7 +338,7 @@ std::vector<size_t> radio_ctrl_impl::get_active_rx_ports() { std::vector<size_t> active_rx_ports; typedef std::map<size_t, bool> map_t; - BOOST_FOREACH(map_t::value_type &m, _rx_streamer_active) { + for(map_t::value_type &m: _rx_streamer_active) { if (m.second) { active_rx_ports.push_back(m.first); } @@ -297,7 +351,7 @@ std::vector<size_t> radio_ctrl_impl::get_active_rx_ports() **********************************************************************/ void radio_ctrl_impl::set_rx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_rx_streamer() " << port << " -> " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_rx_streamer() " << port << " -> " << active ; if (port > _num_rx_channels) { throw uhd::value_error(str( boost::format("[%s] Can't (un)register RX streamer on port %d (invalid port)") @@ -315,7 +369,7 @@ void radio_ctrl_impl::set_rx_streamer(bool active, const size_t port) void radio_ctrl_impl::set_tx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_tx_streamer() " << port << " -> " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::set_tx_streamer() " << port << " -> " << active ; if (port > _num_tx_channels) { throw uhd::value_error(str( boost::format("[%s] Can't (un)register TX streamer on port %d (invalid port)") @@ -336,11 +390,11 @@ void radio_ctrl_impl::set_tx_streamer(bool active, const size_t port) void radio_ctrl_impl::_update_spp(int spp) { boost::mutex::scoped_lock lock(_mutex); - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Requested spp: " << spp << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Requested spp: " << spp ; if (spp == 0) { spp = DEFAULT_PACKET_SIZE / BYTES_PER_SAMPLE; } - UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Setting spp to: " << spp << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "radio_ctrl_impl::_update_spp(): Setting spp to: " << spp ; for (size_t i = 0; i < _num_rx_channels; i++) { sr_write(regs::RX_CTRL_MAXLEN, uint32_t(spp), i); } @@ -356,7 +410,6 @@ void radio_ctrl_impl::set_time_next_pps(const time_spec_t &time_spec) _time64->set_time_next_pps(time_spec); } - time_spec_t radio_ctrl_impl::get_time_now() { return _time64->get_time_now(); @@ -367,3 +420,52 @@ time_spec_t radio_ctrl_impl::get_time_last_pps() return _time64->get_time_last_pps(); } +void radio_ctrl_impl::set_time_source(const std::string &source) +{ + _tree->access<std::string>("time_source/value").set(source); +} + +std::string radio_ctrl_impl::get_time_source() +{ + return _tree->access<std::string>("time_source/value").get(); +} + +std::vector<std::string> radio_ctrl_impl::get_time_sources() +{ + return _tree->access<std::vector<std::string>>("time_source/options").get(); +} + +void radio_ctrl_impl::set_clock_source(const std::string &source) +{ + _tree->access<std::string>("clock_source/value").set(source); +} + +std::string radio_ctrl_impl::get_clock_source() +{ + return _tree->access<std::string>("clock_source/value").get(); +} + +std::vector<std::string> radio_ctrl_impl::get_clock_sources() +{ + return _tree->access<std::vector<std::string>>("clock_source/options").get(); +} + + +std::vector<std::string> radio_ctrl_impl::get_gpio_banks() const +{ + return std::vector<std::string>(); +} + +void radio_ctrl_impl::set_gpio_attr( + const std::string &bank, + const std::string &attr, + const uint32_t value, + const uint32_t mask +) { + throw uhd::not_implemented_error("set_gpio_attr was not defined for this radio"); +} + +uint32_t radio_ctrl_impl::get_gpio_attr(const std::string &bank, const std::string &attr) +{ + throw uhd::not_implemented_error("get_gpio_attr was not defined for this radio"); +} diff --git a/host/lib/rfnoc/radio_ctrl_impl.hpp b/host/lib/rfnoc/radio_ctrl_impl.hpp index d6b402120..6f0c82504 100644 --- a/host/lib/rfnoc/radio_ctrl_impl.hpp +++ b/host/lib/rfnoc/radio_ctrl_impl.hpp @@ -60,6 +60,7 @@ public: virtual double set_rx_frequency(const double freq, const size_t chan); virtual double set_tx_gain(const double gain, const size_t chan); virtual double set_rx_gain(const double gain, const size_t chan); + virtual double set_rx_bandwidth(const double bandwidth, const size_t chan); virtual double get_rate() const; virtual std::string get_tx_antenna(const size_t chan) /* const */; @@ -68,12 +69,41 @@ public: virtual double get_rx_frequency(const size_t) /* const */; virtual double get_tx_gain(const size_t) /* const */; virtual double get_rx_gain(const size_t) /* const */; + virtual double get_rx_bandwidth(const size_t) /* const */; + + virtual std::vector<std::string> get_rx_lo_names(const size_t chan); + virtual std::vector<std::string> get_rx_lo_sources(const std::string &name, const size_t chan); + virtual freq_range_t get_rx_lo_freq_range(const std::string &name, const size_t chan); + + virtual void set_rx_lo_source(const std::string &src, const std::string &name, const size_t chan); + virtual const std::string get_rx_lo_source(const std::string &name, const size_t chan); + + virtual void set_rx_lo_export_enabled(bool enabled, const std::string &name, const size_t chan); + virtual bool get_rx_lo_export_enabled(const std::string &name, const size_t chan); + + virtual double set_rx_lo_freq(double freq, const std::string &name, const size_t chan); + virtual double get_rx_lo_freq(const std::string &name, const size_t chan); void set_time_now(const time_spec_t &time_spec); void set_time_next_pps(const time_spec_t &time_spec); void set_time_sync(const uhd::time_spec_t &time); time_spec_t get_time_now(); time_spec_t get_time_last_pps(); + virtual void set_time_source(const std::string &source); + virtual std::string get_time_source(); + virtual std::vector<std::string> get_time_sources(); + virtual void set_clock_source(const std::string &source); + virtual std::string get_clock_source(); + virtual std::vector<std::string> get_clock_sources(); + + virtual std::vector<std::string> get_gpio_banks() const; + virtual void set_gpio_attr( + const std::string &bank, + const std::string &attr, + const uint32_t value, + const uint32_t mask + ); + virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr); /*********************************************************************** * Block control API calls @@ -199,6 +229,7 @@ private: std::map<size_t, double> _rx_freq; std::map<size_t, double> _tx_gain; std::map<size_t, double> _rx_gain; + std::map<size_t, double> _rx_bandwidth; std::vector<bool> _continuous_streaming; }; /* class radio_ctrl_impl */ diff --git a/host/lib/rfnoc/rx_stream_terminator.cpp b/host/lib/rfnoc/rx_stream_terminator.cpp index 43b3664fc..e05d9cd49 100644 --- a/host/lib/rfnoc/rx_stream_terminator.cpp +++ b/host/lib/rfnoc/rx_stream_terminator.cpp @@ -18,10 +18,9 @@ #include "rx_stream_terminator.hpp" #include "radio_ctrl_impl.hpp" #include "../transport/super_recv_packet_handler.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/source_node_ctrl.hpp> #include <boost/format.hpp> -#include <boost/foreach.hpp> using namespace uhd::rfnoc; @@ -48,8 +47,8 @@ void rx_stream_terminator::set_tx_streamer(bool, const size_t) void rx_stream_terminator::set_rx_streamer(bool active, const size_t) { // TODO this is identical to source_node_ctrl::set_rx_streamer() -> factor out - UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::set_rx_streamer() " << active << std::endl; - BOOST_FOREACH(const node_ctrl_base::node_map_pair_t upstream_node, _upstream_nodes) { + UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::set_rx_streamer() " << active; + for(const node_ctrl_base::node_map_pair_t upstream_node: _upstream_nodes) { source_node_ctrl::sptr curr_upstream_block_ctrl = boost::dynamic_pointer_cast<source_node_ctrl>(upstream_node.second.lock()); if (curr_upstream_block_ctrl) { @@ -71,16 +70,16 @@ void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> stre return; } - UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::handle_overrun()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::handle_overrun()" ; boost::shared_ptr<uhd::transport::sph::recv_packet_streamer> my_streamer = boost::dynamic_pointer_cast<uhd::transport::sph::recv_packet_streamer>(streamer.lock()); if (not my_streamer) return; //If the rx_streamer has expired then overflow handling makes no sense. bool in_continuous_streaming_mode = true; int num_channels = 0; - BOOST_FOREACH(const boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> &node, upstream_radio_nodes) { + for(const boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> &node: upstream_radio_nodes) { num_channels += node->get_active_rx_ports().size(); - BOOST_FOREACH(const size_t port, node->get_active_rx_ports()) { + for(const size_t port: node->get_active_rx_ports()) { in_continuous_streaming_mode = in_continuous_streaming_mode && node->in_continuous_streaming_mode(port); } } @@ -101,8 +100,8 @@ void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> stre ///////////////////////////////////////////////////////////// // MIMO overflow recovery time ///////////////////////////////////////////////////////////// - BOOST_FOREACH(const boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> &node, upstream_radio_nodes) { - BOOST_FOREACH(const size_t port, node->get_active_rx_ports()) { + for(const boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> &node: upstream_radio_nodes) { + for(const size_t port: node->get_active_rx_ports()) { // check all the ports on all the radios node->rx_ctrl_clear_cmds(port); node->issue_stream_cmd(stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS, port); @@ -116,8 +115,8 @@ void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> stre stream_cmd.stream_now = false; stream_cmd.time_spec = upstream_radio_nodes[0]->get_time_now() + time_spec_t(0.05); - BOOST_FOREACH(const boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> &node, upstream_radio_nodes) { - BOOST_FOREACH(const size_t port, node->get_active_rx_ports()) { + for(const boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> &node: upstream_radio_nodes) { + for(const size_t port: node->get_active_rx_ports()) { node->issue_stream_cmd(stream_cmd, port); } } @@ -126,7 +125,7 @@ void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> stre rx_stream_terminator::~rx_stream_terminator() { - UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::~rx_stream_terminator() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "rx_stream_terminator::~rx_stream_terminator() " ; set_rx_streamer(false, 0); } diff --git a/host/lib/rfnoc/sink_block_ctrl_base.cpp b/host/lib/rfnoc/sink_block_ctrl_base.cpp index 55d502ede..48291e02f 100644 --- a/host/lib/rfnoc/sink_block_ctrl_base.cpp +++ b/host/lib/rfnoc/sink_block_ctrl_base.cpp @@ -18,7 +18,7 @@ #include "utils.hpp" #include <uhd/rfnoc/sink_block_ctrl_base.hpp> #include <uhd/rfnoc/constants.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> using namespace uhd; using namespace uhd::rfnoc; @@ -45,7 +45,7 @@ std::vector<size_t> sink_block_ctrl_base::get_input_ports() const { std::vector<size_t> input_ports; input_ports.reserve(_tree->list(_root_path / "ports" / "in").size()); - BOOST_FOREACH(const std::string port, _tree->list(_root_path / "ports" / "in")) { + for(const std::string port: _tree->list(_root_path / "ports" / "in")) { input_ports.push_back(boost::lexical_cast<size_t>(port)); } return input_ports; @@ -66,7 +66,7 @@ void sink_block_ctrl_base::configure_flow_control_in( size_t packets, size_t block_port ) { - UHD_RFNOC_BLOCK_TRACE() << boost::format("sink_block_ctrl_base::configure_flow_control_in(cycles=%d, packets=%d)") % cycles % packets << std::endl; + UHD_RFNOC_BLOCK_TRACE() << boost::format("sink_block_ctrl_base::configure_flow_control_in(cycles=%d, packets=%d)") % cycles % packets ; uint32_t cycles_word = 0; if (cycles) { cycles_word = (1<<31) | cycles; diff --git a/host/lib/rfnoc/sink_node_ctrl.cpp b/host/lib/rfnoc/sink_node_ctrl.cpp index 8398641fd..c570b8eca 100644 --- a/host/lib/rfnoc/sink_node_ctrl.cpp +++ b/host/lib/rfnoc/sink_node_ctrl.cpp @@ -16,7 +16,7 @@ // #include "utils.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/sink_node_ctrl.hpp> #include <uhd/rfnoc/source_node_ctrl.hpp> @@ -35,10 +35,10 @@ size_t sink_node_ctrl::connect_upstream( void sink_node_ctrl::set_tx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "sink_node_ctrl::set_tx_streamer() " << active << " " << port << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "sink_node_ctrl::set_tx_streamer() " << active << " " << port ; /* Enable all downstream connections: - BOOST_FOREACH(const node_ctrl_base::node_map_pair_t downstream_node, list_downstream_nodes()) { + for(const node_ctrl_base::node_map_pair_t downstream_node: list_downstream_nodes()) { sptr curr_downstream_block_ctrl = boost::dynamic_pointer_cast<sink_node_ctrl>(downstream_node.second.lock()); if (curr_downstream_block_ctrl) { diff --git a/host/lib/rfnoc/source_block_ctrl_base.cpp b/host/lib/rfnoc/source_block_ctrl_base.cpp index 94e271541..4cc889545 100644 --- a/host/lib/rfnoc/source_block_ctrl_base.cpp +++ b/host/lib/rfnoc/source_block_ctrl_base.cpp @@ -17,7 +17,7 @@ #include "utils.hpp" #include <uhd/rfnoc/source_block_ctrl_base.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/constants.hpp> using namespace uhd; @@ -30,13 +30,13 @@ void source_block_ctrl_base::issue_stream_cmd( const uhd::stream_cmd_t &stream_cmd, const size_t chan ) { - UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::issue_stream_cmd()" ; if (_upstream_nodes.empty()) { - UHD_MSG(warning) << "issue_stream_cmd() not implemented for " << get_block_id() << std::endl; + UHD_LOGGER_WARNING("RFNOC") << "issue_stream_cmd() not implemented for " << get_block_id() ; return; } - BOOST_FOREACH(const node_ctrl_base::node_map_pair_t upstream_node, _upstream_nodes) { + for(const node_ctrl_base::node_map_pair_t upstream_node: _upstream_nodes) { source_node_ctrl::sptr this_upstream_block_ctrl = boost::dynamic_pointer_cast<source_node_ctrl>(upstream_node.second.lock()); this_upstream_block_ctrl->issue_stream_cmd(stream_cmd, chan); @@ -64,7 +64,7 @@ std::vector<size_t> source_block_ctrl_base::get_output_ports() const { std::vector<size_t> output_ports; output_ports.reserve(_tree->list(_root_path / "ports" / "out").size()); - BOOST_FOREACH(const std::string port, _tree->list(_root_path / "ports" / "out")) { + for(const std::string port: _tree->list(_root_path / "ports" / "out")) { output_ports.push_back(boost::lexical_cast<size_t>(port)); } return output_ports; @@ -77,10 +77,10 @@ void source_block_ctrl_base::set_destination( uint32_t next_address, size_t output_block_port ) { - UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::set_destination() " << uhd::sid_t(next_address) << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::set_destination() " << uhd::sid_t(next_address) ; sid_t new_sid(next_address); new_sid.set_src(get_address(output_block_port)); - UHD_RFNOC_BLOCK_TRACE() << " Setting SID: " << new_sid << std::endl << " "; + UHD_RFNOC_BLOCK_TRACE() << " Setting SID: " << new_sid << " "; sr_write(SR_NEXT_DST_SID, (1<<16) | next_address, output_block_port); } @@ -89,7 +89,7 @@ void source_block_ctrl_base::configure_flow_control_out( size_t block_port, UHD_UNUSED(const uhd::sid_t &sid) ) { - UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::configure_flow_control_out() buf_size_pkts==" << buf_size_pkts << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_block_ctrl_base::configure_flow_control_out() buf_size_pkts==" << buf_size_pkts ; if (buf_size_pkts < 2) { throw uhd::runtime_error(str( boost::format("Invalid window size %d for block %s. Window size must at least be 2.") diff --git a/host/lib/rfnoc/source_node_ctrl.cpp b/host/lib/rfnoc/source_node_ctrl.cpp index c97c72354..1b9d427b9 100644 --- a/host/lib/rfnoc/source_node_ctrl.cpp +++ b/host/lib/rfnoc/source_node_ctrl.cpp @@ -16,7 +16,7 @@ // #include "utils.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/rfnoc/source_node_ctrl.hpp> #include <uhd/rfnoc/sink_node_ctrl.hpp> @@ -35,10 +35,10 @@ size_t source_node_ctrl::connect_downstream( void source_node_ctrl::set_rx_streamer(bool active, const size_t port) { - UHD_RFNOC_BLOCK_TRACE() << "source_node_ctrl::set_rx_streamer() " << port << " -> " << active << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "source_node_ctrl::set_rx_streamer() " << port << " -> " << active ; /* This will enable all upstream blocks: - BOOST_FOREACH(const node_ctrl_base::node_map_pair_t upstream_node, list_upstream_nodes()) { + for(const node_ctrl_base::node_map_pair_t upstream_node: list_upstream_nodes()) { sptr curr_upstream_block_ctrl = boost::dynamic_pointer_cast<source_node_ctrl>(upstream_node.second.lock()); if (curr_upstream_block_ctrl) { diff --git a/host/lib/rfnoc/tick_node_ctrl.cpp b/host/lib/rfnoc/tick_node_ctrl.cpp index 5548194ae..625771945 100644 --- a/host/lib/rfnoc/tick_node_ctrl.cpp +++ b/host/lib/rfnoc/tick_node_ctrl.cpp @@ -47,7 +47,7 @@ double tick_node_ctrl::get_tick_rate( ); } // neighbouring_tick_nodes is now initialized double ret_val = RATE_UNDEFINED; - BOOST_FOREACH(const sptr &node, neighbouring_tick_nodes) { + for(const sptr &node: neighbouring_tick_nodes) { if (_explored_nodes.count(node)) { continue; } diff --git a/host/lib/rfnoc/tx_stream_terminator.cpp b/host/lib/rfnoc/tx_stream_terminator.cpp index ee856843d..1d2653d47 100644 --- a/host/lib/rfnoc/tx_stream_terminator.cpp +++ b/host/lib/rfnoc/tx_stream_terminator.cpp @@ -44,8 +44,8 @@ void tx_stream_terminator::set_rx_streamer(bool, const size_t) void tx_stream_terminator::set_tx_streamer(bool active, const size_t /* port */) { // TODO this is identical to sink_node_ctrl::set_tx_streamer() -> factor out - UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::set_tx_streamer() " << active << std::endl; - BOOST_FOREACH(const node_ctrl_base::node_map_pair_t downstream_node, _downstream_nodes) { + UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::set_tx_streamer() " << active; + for(const node_ctrl_base::node_map_pair_t downstream_node: _downstream_nodes) { sink_node_ctrl::sptr curr_downstream_block_ctrl = boost::dynamic_pointer_cast<sink_node_ctrl>(downstream_node.second.lock()); if (curr_downstream_block_ctrl) { @@ -61,7 +61,7 @@ void tx_stream_terminator::set_tx_streamer(bool active, const size_t /* port */) tx_stream_terminator::~tx_stream_terminator() { - UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::~tx_stream_terminator() " << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::~tx_stream_terminator() " ; set_tx_streamer(false, 0); } diff --git a/host/lib/rfnoc/tx_stream_terminator.hpp b/host/lib/rfnoc/tx_stream_terminator.hpp index 169d7cd6a..dd2b991f6 100644 --- a/host/lib/rfnoc/tx_stream_terminator.hpp +++ b/host/lib/rfnoc/tx_stream_terminator.hpp @@ -24,7 +24,7 @@ #include <uhd/rfnoc/scalar_node_ctrl.hpp> #include <uhd/rfnoc/terminator_node_ctrl.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> // For the block macros -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> namespace uhd { namespace rfnoc { @@ -51,7 +51,7 @@ public: void issue_stream_cmd(const uhd::stream_cmd_t &, const size_t) { - UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::issue_stream_cmd()" << std::endl; + UHD_RFNOC_BLOCK_TRACE() << "tx_stream_terminator::issue_stream_cmd()" ; } // If this is called, then by a send terminator at the other end diff --git a/host/lib/rfnoc/utils.hpp b/host/lib/rfnoc/utils.hpp index ecd3d7cfb..1ee10397c 100644 --- a/host/lib/rfnoc/utils.hpp +++ b/host/lib/rfnoc/utils.hpp @@ -47,7 +47,7 @@ namespace uhd { namespace rfnoc { namespace utils { port++; } } else { - BOOST_FOREACH(const size_t allowed_port, allowed_ports) { + for(const size_t allowed_port: allowed_ports) { if (not nodes.count(port)) { return allowed_port; } @@ -65,7 +65,7 @@ namespace uhd { namespace rfnoc { namespace utils { template <typename T> static std::set<T> str_list_to_set(const std::vector<std::string> &list) { std::set<T> return_set; - BOOST_FOREACH(const std::string &S, list) { + for(const std::string &S: list) { return_set.insert(boost::lexical_cast<T>(S)); } return return_set; diff --git a/host/lib/rfnoc/xports.hpp b/host/lib/rfnoc/xports.hpp index 98cf71b6d..7bd4f2fc8 100644 --- a/host/lib/rfnoc/xports.hpp +++ b/host/lib/rfnoc/xports.hpp @@ -16,6 +16,7 @@ // #include <uhd/types/sid.hpp> +#include <uhd/types/endianness.hpp> #include <uhd/transport/zero_copy.hpp> namespace uhd { @@ -31,6 +32,7 @@ namespace uhd { size_t send_buff_size; uhd::sid_t send_sid; uhd::sid_t recv_sid; + uhd::endianness_t endianness; }; }; |