diff options
author | Lars Amsel <lars.amsel@ni.com> | 2021-12-03 13:02:09 +0100 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-01-10 14:56:35 -0600 |
commit | 3e5e4eb06c0ea6337464cbda0648a75bf76cca17 (patch) | |
tree | a39eb76a91b19ba5f38aacafd844e869bc459319 /host/lib/rfnoc/rfnoc_tx_streamer.cpp | |
parent | 0e7553cd1a8758a8488afc2efaff7295b351e7fe (diff) | |
download | uhd-3e5e4eb06c0ea6337464cbda0648a75bf76cca17.tar.gz uhd-3e5e4eb06c0ea6337464cbda0648a75bf76cca17.tar.bz2 uhd-3e5e4eb06c0ea6337464cbda0648a75bf76cca17.zip |
rfnoc: Add atomic item size property for RFNoC blocks
An RFNoC block (like the radio) might require a minimal number of
items in each clock cycle, e.g. the radio has to process
SPC (samples per cycle). Because data in RFNoC is transmitted and
processed in packets, we have to make sure the items inside these
packets are a multiple of the items processed in each cycle.
This commit adds an atomic item size properties which is set by
the radio and adapted by the streamers. The streamers adapt the
SPP property of the radio block controller depending on the MTU
value. This might lead to an SPP value which does not align with
the SPC value of the radio block, hence we add a property resolver
for the atomic item size.
Diffstat (limited to 'host/lib/rfnoc/rfnoc_tx_streamer.cpp')
-rw-r--r-- | host/lib/rfnoc/rfnoc_tx_streamer.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/host/lib/rfnoc/rfnoc_tx_streamer.cpp b/host/lib/rfnoc/rfnoc_tx_streamer.cpp index 969c41ae6..411affe62 100644 --- a/host/lib/rfnoc/rfnoc_tx_streamer.cpp +++ b/host/lib/rfnoc/rfnoc_tx_streamer.cpp @@ -47,6 +47,7 @@ rfnoc_tx_streamer::rfnoc_tx_streamer(const size_t num_chans, _tick_rate_out.reserve(num_chans); _type_out.reserve(num_chans); _mtu_out.reserve(num_chans); + _atomic_item_size_out.reserve(num_chans); for (size_t i = 0; i < num_chans; i++) { _register_props(i, stream_args.otw_format); @@ -171,13 +172,16 @@ void rfnoc_tx_streamer::_register_props(const size_t chan, const std::string& ot PROP_KEY_TYPE, otw_format, {res_source_info::OUTPUT_EDGE, chan})); _mtu_out.push_back(property_t<size_t>( PROP_KEY_MTU, get_mtu(), {res_source_info::OUTPUT_EDGE, chan})); + _atomic_item_size_out.push_back( + property_t<size_t>(PROP_KEY_ATOMIC_ITEM_SIZE, 1, {res_source_info::OUTPUT_EDGE, chan})); // Give us some shorthands for the rest of this function - property_t<double>* scaling_out = &_scaling_out.back(); - property_t<double>* samp_rate_out = &_samp_rate_out.back(); - property_t<double>* tick_rate_out = &_tick_rate_out.back(); - property_t<std::string>* type_out = &_type_out.back(); - property_t<size_t>* mtu_out = &_mtu_out.back(); + property_t<double>* scaling_out = &_scaling_out.back(); + property_t<double>* samp_rate_out = &_samp_rate_out.back(); + property_t<double>* tick_rate_out = &_tick_rate_out.back(); + property_t<std::string>* type_out = &_type_out.back(); + property_t<size_t>* mtu_out = &_mtu_out.back(); + property_t<size_t>* atomic_item_size_out = &_atomic_item_size_out.back(); // Register them register_property(scaling_out); @@ -185,6 +189,7 @@ void rfnoc_tx_streamer::_register_props(const size_t chan, const std::string& ot register_property(tick_rate_out); register_property(type_out); register_property(mtu_out); + register_property(atomic_item_size_out); // Add resolvers add_property_resolver( @@ -212,6 +217,23 @@ void rfnoc_tx_streamer::_register_props(const size_t chan, const std::string& ot this->set_tick_rate(tick_rate_out.get()); } }); + add_property_resolver( + {atomic_item_size_out, mtu_out}, {}, [&ais = *atomic_item_size_out, chan, this]() { + const auto UHD_UNUSED(log_chan) = chan; + RFNOC_LOG_TRACE("Calling resolver for `atomic_item_size'@" << chan); + if (ais.is_valid()) { + const auto spp = this->tx_streamer_impl::get_max_num_samps(); + if (spp < ais.get()) { + throw uhd::value_error("samples per package must not be smaller than atomic item size"); + } + const auto misalignment = spp % ais.get(); + RFNOC_LOG_TRACE("Check atomic item size " << ais.get() << " divides spp " << spp); + if (misalignment > 0) { + RFNOC_LOG_TRACE("Reduce spp by " << misalignment << " to align with atomic item size"); + this->tx_streamer_impl::set_max_num_samps(spp - misalignment); + } + } + }); } void rfnoc_tx_streamer::_handle_tx_event_action( |