From 3e5e4eb06c0ea6337464cbda0648a75bf76cca17 Mon Sep 17 00:00:00 2001 From: Lars Amsel Date: Fri, 3 Dec 2021 13:02:09 +0100 Subject: 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. --- .../rfnoc_block_tests/x4xx_radio_block_test.cpp | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'host/tests') 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( + "atomic_item_size", 1, {res_source_info::OUTPUT_EDGE, 0}); + mock_source_term.set_edge_property( + "atomic_item_size", 1, {res_source_info::OUTPUT_EDGE, 1}); + mock_source_term.set_edge_property( + "mtu", 99, {res_source_info::OUTPUT_EDGE, 0}); + mock_sink_term.set_edge_property( + "atomic_item_size", 999, {res_source_info::INPUT_EDGE, 0}); + mock_sink_term.set_edge_property( + "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( + "atomic_item_size", 1, {res_source_info::OUTPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 0}), 4); + + mock_source_term.set_edge_property( + "atomic_item_size", 4, {res_source_info::OUTPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property + ("atomic_item_size", {res_source_info::OUTPUT_EDGE, 1}), 4); + + mock_source_term.set_edge_property( + "atomic_item_size", 9, {res_source_info::OUTPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 0}), 36); + + mock_source_term.set_edge_property( + "atomic_item_size", 10, {res_source_info::OUTPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 1}), 20); + + mock_source_term.set_edge_property( + "mtu", 99, {res_source_info::OUTPUT_EDGE, 0}); + mock_source_term.set_edge_property( + "atomic_item_size", 25, {res_source_info::OUTPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_source_term.get_edge_property( + "atomic_item_size", {res_source_info::OUTPUT_EDGE, 0}), 96); + + //repeat for sink + mock_sink_term.set_edge_property( + "atomic_item_size", 1, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property( + "atomic_item_size", {res_source_info::INPUT_EDGE, 0}), 4); + + mock_sink_term.set_edge_property( + "atomic_item_size", 4, {res_source_info::INPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property + ("atomic_item_size", {res_source_info::INPUT_EDGE, 1}), 4); + + mock_sink_term.set_edge_property( + "atomic_item_size", 7, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property( + "atomic_item_size", {res_source_info::INPUT_EDGE, 0}), 28); + + mock_sink_term.set_edge_property( + "atomic_item_size", 22, {res_source_info::INPUT_EDGE, 1}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property( + "atomic_item_size", {res_source_info::INPUT_EDGE, 1}), 44); + + mock_sink_term.set_edge_property( + "mtu", 179, {res_source_info::INPUT_EDGE, 0}); + mock_sink_term.set_edge_property( + "atomic_item_size", 47, {res_source_info::INPUT_EDGE, 0}); + BOOST_CHECK_EQUAL(mock_sink_term.get_edge_property( + "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"; -- cgit v1.2.3