diff options
author | Martin Braun <martin.braun@ettus.com> | 2022-05-02 15:01:13 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-06-10 13:24:05 -0500 |
commit | 022386279a3ef4fa364ab5e2041eedeb3bd7b07b (patch) | |
tree | f06c647280942c6f056ed8bba07320303936c091 | |
parent | 76156b15b7fa5636281a4139c2c856da0a7b05c5 (diff) | |
download | uhd-022386279a3ef4fa364ab5e2041eedeb3bd7b07b.tar.gz uhd-022386279a3ef4fa364ab5e2041eedeb3bd7b07b.tar.bz2 uhd-022386279a3ef4fa364ab5e2041eedeb3bd7b07b.zip |
rfnoc: Add atomic_item_size property to FFT block
The atomic item size for the FFT block is always equal to the length of
the FFT, multiplied by bytes-per-sample (4). For now, this is all the
FFT block supports.
-rw-r--r-- | host/lib/rfnoc/fft_block_control.cpp | 31 | ||||
-rw-r--r-- | host/tests/rfnoc_block_tests/fft_block_test.cpp | 11 |
2 files changed, 41 insertions, 1 deletions
diff --git a/host/lib/rfnoc/fft_block_control.cpp b/host/lib/rfnoc/fft_block_control.cpp index d2ab368ff..ee973a4d9 100644 --- a/host/lib/rfnoc/fft_block_control.cpp +++ b/host/lib/rfnoc/fft_block_control.cpp @@ -24,7 +24,11 @@ constexpr int DEFAULT_FFT_SCALING = 1706; // Conservative 1/N scaling constexpr int MIN_FFT_LENGTH = 8; constexpr int MAX_FFT_LENGTH = 1024; + const uhd::rfnoc::io_type_t DEFAULT_TYPE = uhd::rfnoc::IO_TYPE_SC16; +// As long as we can only do sc16 in this block, we skip deriving the +// byte-per-sample value from elsewhere +constexpr size_t BYTES_PER_SAMPLE = 4; } // namespace @@ -133,6 +137,7 @@ private: << coerced_length); this->_length.set(coerced_length); } + RFNOC_LOG_TRACE("Setting FFT length to " << coerced_length); this->regs().poke32(REG_LENGTH_LOG2_ADDR, uint32_t(length_log2)); }); @@ -168,10 +173,25 @@ private: this->regs().poke32(REG_SHIFT_CONFIG_ADDR, uint32_t(shift)); }); + // Add resolvers & properties for atomic item size + register_property(&_atomic_item_size_in); + register_property(&_atomic_item_size_out); + add_property_resolver( + {&_length, &_atomic_item_size_in}, {&_atomic_item_size_in}, [this]() { + _atomic_item_size_in = _length.get() * BYTES_PER_SAMPLE; + RFNOC_LOG_TRACE( + "Setting atomic item size in to " << _atomic_item_size_in.get()); + }); + add_property_resolver( + {&_length, &_atomic_item_size_out}, {&_atomic_item_size_out}, [this]() { + _atomic_item_size_out = _length.get() * BYTES_PER_SAMPLE; + RFNOC_LOG_TRACE( + "Setting atomic item size out to " << _atomic_item_size_out.get()); + }); + // register edge properties register_property(&_type_in); register_property(&_type_out); - // add resolvers for type (keeps it constant) add_property_resolver({&_type_in}, {&_type_in}, [& type_in = _type_in]() { type_in.set(IO_TYPE_SC16); @@ -191,6 +211,15 @@ private: property_t<int> _shift = property_t<int>{ PROP_KEY_SHIFT_CONFIG, static_cast<int>(DEFAULT_SHIFT), {res_source_info::USER}}; + // clang-format off + // (clang-format messes up the asterisks) + property_t<size_t> _atomic_item_size_in{PROP_KEY_ATOMIC_ITEM_SIZE, + DEFAULT_LENGTH * BYTES_PER_SAMPLE, + {res_source_info::INPUT_EDGE}}; + property_t<size_t> _atomic_item_size_out{PROP_KEY_ATOMIC_ITEM_SIZE, + DEFAULT_LENGTH * BYTES_PER_SAMPLE, + {res_source_info::OUTPUT_EDGE}}; + // clang-format on property_t<std::string> _type_in = property_t<std::string>{ PROP_KEY_TYPE, IO_TYPE_SC16, {res_source_info::INPUT_EDGE}}; property_t<std::string> _type_out = property_t<std::string>{ diff --git a/host/tests/rfnoc_block_tests/fft_block_test.cpp b/host/tests/rfnoc_block_tests/fft_block_test.cpp index 15e1de8f2..f386a2b5f 100644 --- a/host/tests/rfnoc_block_tests/fft_block_test.cpp +++ b/host/tests/rfnoc_block_tests/fft_block_test.cpp @@ -178,6 +178,8 @@ BOOST_FIXTURE_TEST_CASE(fft_test_graph, fft_block_fixture) node_accessor.init_props(&mock_ddc_block); mock_sink_term.set_edge_property<std::string>( "type", "sc16", {res_source_info::INPUT_EDGE, 0}); + mock_sink_term.set_edge_property<size_t>( + PROP_KEY_ATOMIC_ITEM_SIZE, 1234, {res_source_info::INPUT_EDGE, 0}); UHD_LOG_INFO("TEST", "Creating graph..."); graph.connect(&mock_radio_block, &mock_ddc_block, edge_info); @@ -186,4 +188,13 @@ BOOST_FIXTURE_TEST_CASE(fft_test_graph, fft_block_fixture) UHD_LOG_INFO("TEST", "Committing graph..."); graph.commit(); UHD_LOG_INFO("TEST", "Commit complete."); + + UHD_LOG_INFO("TEST", "Testing atomic item size manipulation..."); + // Try setting the atomic item size to some other value, it should bounce + // back + mock_sink_term.set_edge_property<size_t>( + PROP_KEY_ATOMIC_ITEM_SIZE, 1996, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(test_fft->get_length() * 4, + mock_sink_term.get_edge_property<size_t>( + PROP_KEY_ATOMIC_ITEM_SIZE, {res_source_info::INPUT_EDGE, 0})); } |