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/tests | |
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/tests')
-rw-r--r-- | host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp b/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp index b6c6c21ba..79cb27039 100644 --- a/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp +++ b/host/tests/rfnoc_block_tests/x4xx_radio_block_test.cpp @@ -316,6 +316,112 @@ BOOST_FIXTURE_TEST_CASE(x400_radio_test_graph, x400_radio_fixture) UHD_LOG_INFO("TEST", "Commit complete."); } +/****************************************************************************** + * RFNoC atomic item size property test + * + * This test case ensures that the radio block propagates atomic item size correct + *****************************************************************************/ +BOOST_FIXTURE_TEST_CASE(x400_radio_test_prop_prop, x400_radio_fixture) +{ + detail::graph_t graph{}; + detail::graph_t::graph_edge_t edge_port_info0; + edge_port_info0.src_port = 0; + edge_port_info0.dst_port = 0; + edge_port_info0.property_propagation_active = true; + edge_port_info0.edge = detail::graph_t::graph_edge_t::DYNAMIC; + detail::graph_t::graph_edge_t edge_port_info1; + edge_port_info1.src_port = 1; + edge_port_info1.dst_port = 1; + edge_port_info1.property_propagation_active = true; + edge_port_info1.edge = detail::graph_t::graph_edge_t::DYNAMIC; + + mock_terminator_t mock_sink_term(2, {}, "MOCK_SINK"); + mock_terminator_t mock_source_term(2, {}, "MOCK_SOURCE"); + + UHD_LOG_INFO("TEST", "Priming mock block properties"); + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 1, {res_source_info::OUTPUT_EDGE, 0}); + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 1, {res_source_info::OUTPUT_EDGE, 1}); + mock_source_term.set_edge_property<size_t>( + "mtu", 99, {res_source_info::OUTPUT_EDGE, 0}); + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 999, {res_source_info::INPUT_EDGE, 0}); + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 999, {res_source_info::INPUT_EDGE, 1}); + + UHD_LOG_INFO("TEST", "Creating graph..."); + graph.connect(&mock_source_term, test_radio.get(), edge_port_info0); + graph.connect(&mock_source_term, test_radio.get(), edge_port_info1); + graph.connect(test_radio.get(), &mock_sink_term, edge_port_info0); + graph.connect(test_radio.get(), &mock_sink_term, edge_port_info1); + UHD_LOG_INFO("TEST", "Committing graph..."); + graph.commit(); + + UHD_LOG_INFO("TEST", "Testing atomic item size propagation..."); + + // radio has a sample width of 32 bits (sc16) and spc of 1 by default + // this results in a atomic item size of 4 for the radio + // because property gets propagated immediately after setting in + // the committed graph we can check the result of the propagation + // at the mock edges + + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 1, {res_source_info::OUTPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 0}), 4); + + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 4, {res_source_info::OUTPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property<size_t> + ("atomic_item_size", {res_source_info::OUTPUT_EDGE, 1}), 4); + + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 9, {res_source_info::OUTPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 0}), 36); + + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 10, {res_source_info::OUTPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 1}), 20); + + mock_source_term.set_edge_property<size_t>( + "mtu", 99, {res_source_info::OUTPUT_EDGE, 0}); + mock_source_term.set_edge_property<size_t>( + "atomic_item_size", 25, {res_source_info::OUTPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 0}), 96); + + //repeat for sink + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 1, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::INPUT_EDGE, 0}), 4); + + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 4, {res_source_info::INPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property<size_t> + ("atomic_item_size", {res_source_info::INPUT_EDGE, 1}), 4); + + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 7, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::INPUT_EDGE, 0}), 28); + + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 22, {res_source_info::INPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::INPUT_EDGE, 1}), 44); + + mock_sink_term.set_edge_property<size_t>( + "mtu", 179, {res_source_info::INPUT_EDGE, 0}); + mock_sink_term.set_edge_property<size_t>( + "atomic_item_size", 47, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property<size_t>( + "atomic_item_size", {res_source_info::INPUT_EDGE, 0}), 176); +} + BOOST_FIXTURE_TEST_CASE(zbx_api_freq_tx_test, x400_radio_fixture) { const std::string log = "ZBX_API_TX_FREQUENCY_TEST"; |