diff options
author | Martin Braun <martin.braun@ettus.com> | 2016-08-01 18:17:41 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-08-09 12:42:52 -0700 |
commit | 3bf4b000f7d9a7f4af82c21753556ede7e8df6e3 (patch) | |
tree | 2228d7eb58c4d83d91192cb9b6a908e4e49f6317 /host/tests/blockdef_test.cpp | |
parent | c5b076173e2d866f3ee99c113a37183c5ec20f0b (diff) | |
download | uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.tar.gz uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.tar.bz2 uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.zip |
Merging RFNoC support for X310
Diffstat (limited to 'host/tests/blockdef_test.cpp')
-rw-r--r-- | host/tests/blockdef_test.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/host/tests/blockdef_test.cpp b/host/tests/blockdef_test.cpp new file mode 100644 index 000000000..2cd06a43a --- /dev/null +++ b/host/tests/blockdef_test.cpp @@ -0,0 +1,94 @@ +// +// Copyright 2014-2015 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#include <iostream> +#include <map> +#include <boost/cstdint.hpp> +#include <boost/assign/list_of.hpp> +#include <boost/test/unit_test.hpp> +#include <boost/format.hpp> +#include <boost/foreach.hpp> +#include <uhd/rfnoc/blockdef.hpp> + +using namespace uhd::rfnoc; + +BOOST_AUTO_TEST_CASE(test_lookup) { + std::map<boost::uint64_t, std::string> blocknames = boost::assign::list_of< std::pair<boost::uint64_t, std::string> > + (0, "NullSrcSink") + (0xFF70000000000000, "FFT") + (0xF112000000000001, "FIR") + (0xF1F0000000000000, "FIFO") + (0xD053000000000000, "Window") + (0x5CC0000000000000, "SchmidlCox") + ; + + std::cout << blocknames.size() << std::endl; + + for (std::map<boost::uint64_t, std::string>::iterator it = blocknames.begin(); it != blocknames.end(); ++it) { + std::cout << "Testing " << it->second << " => " << str(boost::format("%016X") % it->first) << std::endl; + blockdef::sptr block_definition = blockdef::make_from_noc_id(it->first); + // If the previous function fails, it'll return a NULL pointer + BOOST_REQUIRE(block_definition); + BOOST_CHECK(block_definition->is_block()); + BOOST_CHECK_EQUAL(block_definition->get_name(), it->second); + } +} + +BOOST_AUTO_TEST_CASE(test_ports) { + // Create an FFT: + blockdef::sptr block_definition = blockdef::make_from_noc_id(0xFF70000000000000); + blockdef::ports_t in_ports = block_definition->get_input_ports(); + BOOST_REQUIRE_EQUAL(in_ports.size(), 1); + BOOST_CHECK_EQUAL(in_ports[0]["name"], "in"); + BOOST_CHECK_EQUAL(in_ports[0]["type"], "sc16"); + BOOST_CHECK(in_ports[0].has_key("vlen")); + BOOST_CHECK(in_ports[0].has_key("pkt_size")); + + blockdef::ports_t out_ports = block_definition->get_output_ports(); + BOOST_REQUIRE_EQUAL(out_ports.size(), 1); + BOOST_CHECK_EQUAL(out_ports[0]["name"], "out"); + BOOST_CHECK(out_ports[0].has_key("vlen")); + BOOST_CHECK(out_ports[0].has_key("pkt_size")); + + BOOST_CHECK_EQUAL(block_definition->get_all_port_numbers().size(), 1); + BOOST_CHECK_EQUAL(block_definition->get_all_port_numbers()[0], 0); +} + +BOOST_AUTO_TEST_CASE(test_args) { + // Create an FFT: + blockdef::sptr block_definition = blockdef::make_from_noc_id(0xFF70000000000000); + blockdef::args_t args = block_definition->get_args(); + BOOST_REQUIRE(args.size() >= 3); + BOOST_CHECK_EQUAL(args[0]["name"], "spp"); + BOOST_CHECK_EQUAL(args[0]["type"], "int"); + BOOST_CHECK_EQUAL(args[0]["value"], "256"); +} + +BOOST_AUTO_TEST_CASE(test_regs) { + // Create an FFT: + blockdef::sptr block_definition = blockdef::make_from_noc_id(0xFF70000000000000); + blockdef::registers_t sregs = block_definition->get_settings_registers(); + BOOST_REQUIRE_EQUAL(sregs.size(), 3); + BOOST_CHECK_EQUAL(sregs["FFT_RESET"], 131); + BOOST_CHECK_EQUAL(sregs["FFT_SIZE_LOG2"], 132); + BOOST_CHECK_EQUAL(sregs["MAGNITUDE_OUT"], 133); + blockdef::registers_t user_regs = block_definition->get_readback_registers(); + BOOST_REQUIRE_EQUAL(user_regs.size(), 2); + BOOST_CHECK_EQUAL(user_regs["RB_FFT_RESET"], 0); + BOOST_CHECK_EQUAL(user_regs["RB_MAGNITUDE_OUT"], 1); +} + |