1 // 2 // Copyright 2019 Ettus Research, a National Instruments Brand 3 // 4 // SPDX-License-Identifier: GPL-3.0-or-later 5 // 6 7 #include <uhd/convert.hpp> 8 #include <uhd/exception.hpp> 9 #include <uhd/rfnoc/defaults.hpp> 10 #include <uhd/rfnoc/logpwr_block_control.hpp> 11 #include <uhd/rfnoc/property.hpp> 12 #include <uhd/rfnoc/registry.hpp> 13 #include <string> 14 15 using namespace uhd::rfnoc; 16 17 18 class logpwr_block_control_impl : public logpwr_block_control 19 { 20 public: RFNOC_BLOCK_CONSTRUCTOR(logpwr_block_control)21 RFNOC_BLOCK_CONSTRUCTOR(logpwr_block_control) 22 { 23 const size_t num_input_ports = get_num_input_ports(); 24 const size_t num_output_ports = get_num_output_ports(); 25 UHD_ASSERT_THROW(num_output_ports == num_input_ports); 26 27 _prop_type_in.reserve(num_input_ports); 28 _prop_type_out.reserve(num_output_ports); 29 30 for (size_t chan = 0; chan < num_input_ports; chan++) { 31 // register edge properties 32 _prop_type_in.emplace_back(property_t<std::string>{ 33 PROP_KEY_TYPE, IO_TYPE_SC16, {res_source_info::INPUT_EDGE, chan}}); 34 _prop_type_out.emplace_back(property_t<std::string>{ 35 PROP_KEY_TYPE, IO_TYPE_S16, {res_source_info::OUTPUT_EDGE, chan}}); 36 register_property(&_prop_type_in.back()); 37 register_property(&_prop_type_out.back()); 38 39 // add resolvers for type 40 add_property_resolver({&_prop_type_in.back()}, 41 {&_prop_type_in.back()}, 42 [this, chan]() { _prop_type_in.at(chan).set(IO_TYPE_SC16); }); 43 add_property_resolver({&_prop_type_out.back()}, 44 {&_prop_type_out.back()}, 45 [this, chan]() { _prop_type_out.at(chan).set(IO_TYPE_S16); }); 46 } 47 } 48 49 private: 50 /************************************************************************** 51 * Attributes 52 *************************************************************************/ 53 std::vector<property_t<std::string>> _prop_type_in; 54 std::vector<property_t<std::string>> _prop_type_out; 55 }; 56 57 UHD_RFNOC_BLOCK_REGISTER_DIRECT( 58 logpwr_block_control, LOGPWR_BLOCK, "LogPwr", CLOCK_KEY_GRAPH, "bus_clk") 59