aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/include/uhd/rfnoc/block_id.hpp32
-rw-r--r--host/include/uhd/rfnoc/constants.hpp4
-rw-r--r--host/lib/rfnoc/block_id.cpp2
-rw-r--r--host/tests/block_id_test.cpp41
-rw-r--r--host/tests/device3_test.cpp38
5 files changed, 60 insertions, 57 deletions
diff --git a/host/include/uhd/rfnoc/block_id.hpp b/host/include/uhd/rfnoc/block_id.hpp
index 8c4884807..77b2ba5a0 100644
--- a/host/include/uhd/rfnoc/block_id.hpp
+++ b/host/include/uhd/rfnoc/block_id.hpp
@@ -1,5 +1,6 @@
// Copyright 2014 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
+// Copyright 2019 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
@@ -21,17 +22,17 @@ namespace rfnoc {
/*!
* Identifies an RFNoC block.
*
- * An RFNoC block ID is a string such as: 0/FFT_1
+ * An RFNoC block ID is a string such as: 0/FFT#1
*
* The rules for formatting such a string are:
*
- * DEVICE/BLOCKNAME_COUNTER
+ * DEVICE/BLOCKNAME#COUNTER
*
* DEVICE: Identifies the device (usually the motherboard index)
* BLOCKNAME: A name given to this block
* COUNTER: If is are more than one block with a BLOCKNAME, this counts up.
*
- * So, 0/FFT_1 means we're addressing the second block called FFT
+ * So, 0/FFT#1 means we're addressing the second block called FFT
* on the first device.
*
* This class can represent these block IDs.
@@ -48,7 +49,7 @@ public:
const std::string& block_name,
const size_t block_ctr = 0);
- //! Return a string like this: "0/FFT_1" (includes all components, if set)
+ //! Return a string like this: "0/FFT#1" (includes all components, if set)
std::string to_string() const;
//! Check if a given string is valid as a block name.
@@ -56,8 +57,9 @@ public:
// Note: This only applies to the block *name*, not the entire block ID.
// Examples:
// * is_valid_blockname("FFT") will return true.
- // * is_valid_blockname("FIR_Filter") will return false, because an underscore
- // is not allowed in a block name.
+ // * is_valid_blockname("FIR#Filter") will return false, because a # symbol
+ // is not allowed in a block name. Only alphanumerical characters and
+ // underscores are allowed.
//
// Internally, this matches the string with uhd::rfnoc::VALID_BLOCKNAME_REGEX.
static bool is_valid_blockname(const std::string& block_name);
@@ -69,8 +71,8 @@ public:
//
// Examples:
// * is_valid_block_id("FFT") will return true.
- // * is_valid_block_id("0/Filter_1") will return true.
- // * is_valid_block_id("0/Filter_Foo") will return false.
+ // * is_valid_block_id("0/Filter#1") will return true.
+ // * is_valid_block_id("0/Filter#Foo") will return false.
//
// Internally, this matches the string with uhd::rfnoc::VALID_BLOCKID_REGEX.
static bool is_valid_block_id(const std::string& block_id);
@@ -79,8 +81,8 @@ public:
//
// A match is a less strict version of equality.
// Less specific block IDs will match more specific ones,
- // e.g. "FFT" will match "0/FFT_1", "1/FFT_2", etc.
- // "FFT_1" will only match the former, etc.
+ // e.g. "FFT" will match "0/FFT#1", "1/FFT#2", etc.
+ // "FFT#1" will only match the former, etc.
bool match(const std::string& block_str);
// Getters
@@ -91,10 +93,10 @@ public:
return to_string();
};
- //! Like get(), but only returns the local part ("FFT_1")
+ //! Like get(), but only returns the local part ("FFT#1")
std::string get_local() const;
- //! Returns the property tree root for this block (e.g. "/mboards/0/xbar/FFT_1/")
+ //! Returns the property tree root for this block (e.g. "/mboards/0/xbar/FFT#1/")
uhd::fs_path get_tree_root() const;
//! Return device number
@@ -117,7 +119,7 @@ public:
// Setters
- //! Set from string such as "0/FFT_1", "FFT_0", ...
+ //! Set from string such as "0/FFT#1", "FFT#0", ...
// Returns true if successful (i.e. if string valid)
bool set(const std::string& new_name);
@@ -203,14 +205,14 @@ public:
return to_string();
}
- //! Increment the block count ("FFT_1" -> "FFT_2")
+ //! Increment the block count ("FFT#1" -> "FFT_2")
block_id_t operator++()
{
_block_ctr++;
return *this;
}
- //! Increment the block count ("FFT_1" -> "FFT_2")
+ //! Increment the block count ("FFT#1" -> "FFT_2")
block_id_t operator++(int)
{
_block_ctr++;
diff --git a/host/include/uhd/rfnoc/constants.hpp b/host/include/uhd/rfnoc/constants.hpp
index c3a638258..d18494d4c 100644
--- a/host/include/uhd/rfnoc/constants.hpp
+++ b/host/include/uhd/rfnoc/constants.hpp
@@ -98,9 +98,9 @@ static const size_t ANY_PORT = size_t(~0);
static const size_t MAX_NUM_PORTS = 16;
// Regular expressions
-static const std::string VALID_BLOCKNAME_REGEX = "[A-Za-z][A-Za-z0-9]*";
+static const std::string VALID_BLOCKNAME_REGEX = "[A-Za-z][A-Za-z0-9_]*";
static const std::string VALID_BLOCKID_REGEX =
- "(?:(\\d+)(?:/))?([A-Za-z][A-Za-z0-9]*)(?:(?:_)(\\d\\d?))?";
+ "(?:(\\d+)(?:/))?([A-Za-z][A-Za-z0-9]*)(?:(?:#)(\\d\\d?))?";
}} /* namespace uhd::rfnoc */
diff --git a/host/lib/rfnoc/block_id.cpp b/host/lib/rfnoc/block_id.cpp
index 1cef4c9c8..573b393e5 100644
--- a/host/lib/rfnoc/block_id.cpp
+++ b/host/lib/rfnoc/block_id.cpp
@@ -53,7 +53,7 @@ std::string block_id_t::to_string() const
std::string block_id_t::get_local() const
{
- return str(boost::format("%s_%d") % get_block_name() % get_block_count());
+ return str(boost::format("%s#%d") % get_block_name() % get_block_count());
}
uhd::fs_path block_id_t::get_tree_root() const
diff --git a/host/tests/block_id_test.cpp b/host/tests/block_id_test.cpp
index 7c068e4d2..fb11daf1f 100644
--- a/host/tests/block_id_test.cpp
+++ b/host/tests/block_id_test.cpp
@@ -14,17 +14,18 @@ using namespace uhd::rfnoc;
BOOST_AUTO_TEST_CASE(test_block_id)
{
- BOOST_CHECK(block_id_t::is_valid_block_id("00/Filter_1"));
- BOOST_CHECK(not block_id_t::is_valid_block_id("0/MAG_SQUARE"));
+ BOOST_CHECK(block_id_t::is_valid_block_id("00/Filter#1"));
+ BOOST_CHECK(not block_id_t::is_valid_block_id("0/MAG#SQUARE"));
BOOST_CHECK(block_id_t::is_valid_blockname("FilterFoo"));
- BOOST_CHECK(not block_id_t::is_valid_blockname("Filter_Foo"));
+ BOOST_CHECK(block_id_t::is_valid_blockname("Filter_Foo"));
+ BOOST_CHECK(not block_id_t::is_valid_blockname("Filter#Foo"));
BOOST_CHECK(not block_id_t::is_valid_blockname("Filter/Foo"));
BOOST_CHECK(not block_id_t::is_valid_blockname("0Filter/Foo"));
BOOST_CHECK(not block_id_t::is_valid_blockname("0/Filter/Foo"));
BOOST_REQUIRE_THROW(block_id_t invalid_block_id("0Filter/1"), uhd::value_error);
- block_id_t block_id("0/FFT_1");
+ block_id_t block_id("0/FFT#1");
BOOST_CHECK_EQUAL(block_id.get_device_no(), 0);
BOOST_CHECK_EQUAL(block_id.get_block_name(), "FFT");
BOOST_CHECK_EQUAL(block_id.get_block_count(), 1);
@@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE(test_block_id)
BOOST_CHECK_EQUAL(block_id.get_block_name(), "FooBar");
BOOST_CHECK_EQUAL(block_id.get_block_count(), 11);
- BOOST_CHECK(not block_id.set_block_name("Foo_Bar"));
+ BOOST_CHECK(not block_id.set_block_name("Foo%Bar"));
BOOST_CHECK_EQUAL(block_id.get_device_no(), 17);
BOOST_CHECK_EQUAL(
block_id.get_block_name(), "FooBar"); // Is unchanged because invalid
@@ -59,28 +60,28 @@ BOOST_AUTO_TEST_CASE(test_block_id)
BOOST_CHECK_EQUAL(other_block_id.get_device_no(), 7);
BOOST_CHECK_EQUAL(other_block_id.get_block_name(), "BlockName");
BOOST_CHECK_EQUAL(other_block_id.get_block_count(), 3);
- BOOST_CHECK_EQUAL(other_block_id.to_string(), "7/BlockName_3");
+ BOOST_CHECK_EQUAL(other_block_id.to_string(), "7/BlockName#3");
// Cast
std::string block_id_str = std::string(other_block_id);
- std::cout << "Should print '7/BlockName_3': " << block_id_str << std::endl;
- BOOST_CHECK_EQUAL(block_id_str, "7/BlockName_3");
+ std::cout << "Should print '7/BlockName#3': " << block_id_str << std::endl;
+ BOOST_CHECK_EQUAL(block_id_str, "7/BlockName#3");
// Operators
std::cout << "Testing ostream printing (<<): " << other_block_id << std::endl;
BOOST_CHECK_EQUAL(other_block_id, block_id_str);
- BOOST_CHECK_EQUAL(other_block_id, "7/BlockName_3");
+ BOOST_CHECK_EQUAL(other_block_id, "7/BlockName#3");
// match()
BOOST_CHECK(other_block_id.match("BlockName"));
BOOST_CHECK(other_block_id.match("7/BlockName"));
- BOOST_CHECK(other_block_id.match("BlockName_3"));
- BOOST_CHECK(other_block_id.match("7/BlockName_3"));
+ BOOST_CHECK(other_block_id.match("BlockName#3"));
+ BOOST_CHECK(other_block_id.match("7/BlockName#3"));
BOOST_CHECK(not other_block_id.match("8/BlockName"));
- BOOST_CHECK(not other_block_id.match("8/BlockName_3"));
- BOOST_CHECK(not other_block_id.match("Block_Name_3"));
- BOOST_CHECK(not other_block_id.match("BlockName_4"));
- BOOST_CHECK(not other_block_id.match("BlockName_X"));
+ BOOST_CHECK(not other_block_id.match("8/BlockName#3"));
+ BOOST_CHECK(not other_block_id.match("Block_Name#3"));
+ BOOST_CHECK(not other_block_id.match("BlockName#4"));
+ BOOST_CHECK(not other_block_id.match("BlockName#X"));
BOOST_CHECK(not other_block_id.match("2093ksdjfflsdkjf"));
}
@@ -96,7 +97,7 @@ BOOST_AUTO_TEST_CASE(test_block_id_set)
BOOST_CHECK_EQUAL(block_id_for_set.get_device_no(), 1);
BOOST_CHECK_EQUAL(block_id_for_set.get_block_name(), "FirFilter2");
BOOST_CHECK_EQUAL(block_id_for_set.get_block_count(), 9);
- block_id_for_set.set("Sync_3");
+ block_id_for_set.set("Sync#3");
BOOST_CHECK_EQUAL(block_id_for_set.get_device_no(), 1);
BOOST_CHECK_EQUAL(block_id_for_set.get_block_name(), "Sync");
BOOST_CHECK_EQUAL(block_id_for_set.get_block_count(), 3);
@@ -104,8 +105,8 @@ BOOST_AUTO_TEST_CASE(test_block_id_set)
BOOST_AUTO_TEST_CASE(test_block_id_cmp)
{
- BOOST_CHECK(block_id_t("0/FFT_1") == block_id_t("0/FFT_1"));
- BOOST_CHECK(block_id_t("0/FFT_1") != block_id_t("1/FFT_1"));
- BOOST_CHECK(block_id_t("0/FFT_1") < block_id_t("1/aaaaaaaaa_0"));
- BOOST_CHECK(not(block_id_t("0/FFT_1") > block_id_t("1/aaaaaaaaa_0")));
+ BOOST_CHECK(block_id_t("0/FFT#1") == block_id_t("0/FFT#1"));
+ BOOST_CHECK(block_id_t("0/FFT#1") != block_id_t("1/FFT#1"));
+ BOOST_CHECK(block_id_t("0/FFT#1") < block_id_t("1/aaaaaaaaa#0"));
+ BOOST_CHECK(not(block_id_t("0/FFT#1") > block_id_t("1/aaaaaaaaa#0")));
}
diff --git a/host/tests/device3_test.cpp b/host/tests/device3_test.cpp
index 43f5fe45b..b737e7012 100644
--- a/host/tests/device3_test.cpp
+++ b/host/tests/device3_test.cpp
@@ -120,15 +120,15 @@ BOOST_AUTO_TEST_CASE(test_device3)
block_ctrl_base::sptr block0 =
my_device->get_block_ctrl(my_device->find_blocks("Block")[0]);
BOOST_REQUIRE(block0);
- BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block_0");
+ BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block#0");
std::cout << "Checking block 1..." << std::endl;
- BOOST_REQUIRE(my_device->has_block(block_id_t("0/Block_1")));
+ BOOST_REQUIRE(my_device->has_block(block_id_t("0/Block#1")));
std::cout << "Getting block 1..." << std::endl;
- block_ctrl_base::sptr block1 = my_device->get_block_ctrl(block_id_t("0/Block_1"));
+ block_ctrl_base::sptr block1 = my_device->get_block_ctrl(block_id_t("0/Block#1"));
BOOST_REQUIRE(block1);
- BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block_1");
+ BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block#1");
}
@@ -141,28 +141,28 @@ BOOST_AUTO_TEST_CASE(test_device3_graph)
std::cout << "Getting block 0..." << std::endl;
auto block0 = my_device->get_block_ctrl(my_device->find_blocks("Block")[0]);
BOOST_REQUIRE(block0);
- BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block_0");
+ BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block#0");
std::cout << "Checking block 1..." << std::endl;
- BOOST_REQUIRE(my_device->has_block(block_id_t("0/Block_1")));
+ BOOST_REQUIRE(my_device->has_block(block_id_t("0/Block#1")));
std::cout << "Getting block 1..." << std::endl;
- auto block1 = my_device->get_block_ctrl(block_id_t("0/Block_1"));
+ auto block1 = my_device->get_block_ctrl(block_id_t("0/Block#1"));
BOOST_REQUIRE(block1);
- BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block_1");
+ BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block#1");
std::cout << "Creating graph..." << std::endl;
auto graph = my_device->create_graph("test_graph");
BOOST_CHECK(graph);
std::cout << "Connecting block_0 to block_1 ..." << std::endl;
- graph->connect(block_id_t("0/Block_0"), 0, block_id_t("0/Block_1"), 0);
+ graph->connect(block_id_t("0/Block#0"), 0, block_id_t("0/Block#1"), 0);
BOOST_CHECK_EQUAL(block0->list_upstream_nodes().size(), 0);
BOOST_CHECK_EQUAL(block0->list_downstream_nodes().size(), 1);
BOOST_CHECK_EQUAL(
- block0->list_downstream_nodes()[0].lock()->unique_id(), "0/Block_1");
+ block0->list_downstream_nodes()[0].lock()->unique_id(), "0/Block#1");
BOOST_CHECK_EQUAL(block1->list_upstream_nodes().size(), 1);
BOOST_CHECK_EQUAL(block1->list_downstream_nodes().size(), 0);
- BOOST_CHECK_EQUAL(block1->list_upstream_nodes()[0].lock()->unique_id(), "0/Block_0");
+ BOOST_CHECK_EQUAL(block1->list_upstream_nodes()[0].lock()->unique_id(), "0/Block#0");
}
BOOST_AUTO_TEST_CASE(test_device3_cast)
@@ -171,30 +171,30 @@ BOOST_AUTO_TEST_CASE(test_device3_cast)
std::cout << "Getting block 0..." << std::endl;
block_ctrl::sptr block0 =
- my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block_0"));
+ my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block#0"));
BOOST_REQUIRE(block0);
- BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block_0");
+ BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block#0");
std::cout << "Getting block 1..." << std::endl;
block_ctrl_base::sptr block1 =
- my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block_1"));
- BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block_1");
+ my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block#1"));
+ BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block#1");
}
BOOST_AUTO_TEST_CASE(test_device3_fail)
{
device3::sptr my_device = make_mock_device();
- BOOST_CHECK(not my_device->has_block(block_id_t("0/FooBarBlock_0")));
- BOOST_CHECK(not my_device->has_block<mock_block_ctrl>(block_id_t("0/Block_1")));
+ BOOST_CHECK(not my_device->has_block(block_id_t("0/FooBarBlock#0")));
+ BOOST_CHECK(not my_device->has_block<mock_block_ctrl>(block_id_t("0/Block#1")));
BOOST_CHECK(my_device->find_blocks("FooBarBlock").size() == 0);
BOOST_CHECK(my_device->find_blocks<block_ctrl>("FooBarBlock").size() == 0);
BOOST_REQUIRE_THROW(
- my_device->get_block_ctrl(block_id_t("0/FooBarBlock_17")), uhd::lookup_error);
+ my_device->get_block_ctrl(block_id_t("0/FooBarBlock#17")), uhd::lookup_error);
BOOST_REQUIRE_THROW(
- my_device->get_block_ctrl<mock_block_ctrl>(block_id_t("0/Block_1")),
+ my_device->get_block_ctrl<mock_block_ctrl>(block_id_t("0/Block#1")),
uhd::lookup_error);
}