aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/registry_factory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/rfnoc/registry_factory.cpp')
-rw-r--r--host/lib/rfnoc/registry_factory.cpp97
1 files changed, 38 insertions, 59 deletions
diff --git a/host/lib/rfnoc/registry_factory.cpp b/host/lib/rfnoc/registry_factory.cpp
index 117b60e96..bf1bc60a5 100644
--- a/host/lib/rfnoc/registry_factory.cpp
+++ b/host/lib/rfnoc/registry_factory.cpp
@@ -7,8 +7,10 @@
#include <uhd/exception.hpp>
#include <uhd/rfnoc/registry.hpp>
#include <uhd/rfnoc/defaults.hpp>
+#include <uhd/rfnoc/constants.hpp>
#include <uhd/utils/static.hpp>
#include <uhdlib/rfnoc/factory.hpp>
+#include <boost/functional/hash.hpp>
#include <unordered_map>
#include <iomanip>
#include <iostream>
@@ -16,6 +18,10 @@
using namespace uhd::rfnoc;
+/*! Pair type for device depended block definitions. */
+using block_device_pair_t = std::pair<noc_id_t, device_type_t>;
+
+
///////////////////////////////////////////////////////////////////////////////
// There are two registries:
// - The "direct" registry, which is for blocks that do not have a block
@@ -24,8 +30,9 @@ using namespace uhd::rfnoc;
// descriptor file
//
// This is the direct registry:
-using block_direct_reg_t =
- std::unordered_map<noc_block_base::noc_id_t, block_factory_info_t>;
+using block_direct_reg_t = std::unordered_map<block_device_pair_t,
+ block_factory_info_t,
+ boost::hash<block_device_pair_t>>;
UHD_SINGLETON_FCN(block_direct_reg_t, get_direct_block_registry);
//
// This is the descriptor registry:
@@ -34,96 +41,68 @@ using block_descriptor_reg_t =
UHD_SINGLETON_FCN(block_descriptor_reg_t, get_descriptor_block_registry);
///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-// These registries are for blocks that have requested motherboard access
-using block_direct_mb_access_req_t = std::unordered_set<noc_block_base::noc_id_t>;
-UHD_SINGLETON_FCN(block_direct_mb_access_req_t, get_direct_block_mb_access_requested);
-//
-// This is the descriptor registry:
-using block_descriptor_mb_access_req_t = std::unordered_set<std::string>;
-UHD_SINGLETON_FCN(
- block_descriptor_mb_access_req_t, get_descriptor_block_mb_access_requested);
-///////////////////////////////////////////////////////////////////////////////
-
/******************************************************************************
* Registry functions
*
* Note: Don't use UHD_LOG_*, since all of this can be executed in a static
* fashion.
*****************************************************************************/
-void registry::register_block_direct(noc_block_base::noc_id_t noc_id,
+void registry::register_block_direct(noc_id_t noc_id,
+ device_type_t device_id,
const std::string& block_name,
+ bool mb_access,
const std::string& timebase_clock,
const std::string& ctrlport_clock,
factory_t factory_fn)
{
- if (get_direct_block_registry().count(noc_id)) {
+ block_device_pair_t key{noc_id, device_id};
+ if (get_direct_block_registry().count(key)) {
std::cerr
- << "[REGISTRY] WARNING: Attempting to overwrite previously registered RFNoC "
- "block with Noc-ID 0x"
- << std::hex << noc_id << std::dec << std::endl;
+ << "[REGISTRY] WARNING: Attempting to overwrite previously "
+ "registered RFNoC block with noc_id,device_id: " << std::hex
+ << "0x" << noc_id << ", 0x" << device_id <<std::dec << std::endl;
return;
}
- get_direct_block_registry().emplace(noc_id,
- block_factory_info_t{
- block_name, timebase_clock, ctrlport_clock, std::move(factory_fn)});
+ get_direct_block_registry().emplace(key,
+ block_factory_info_t{block_name,
+ mb_access,
+ timebase_clock,
+ ctrlport_clock,
+ std::move(factory_fn)});
}
void registry::register_block_descriptor(
const std::string& block_key, factory_t factory_fn)
{
if (get_descriptor_block_registry().count(block_key)) {
- std::cerr << "WARNING: Attempting to overwriting previously registered RFNoC "
- "block with block key"
- << block_key << std::endl;
+ std::cerr
+ << "[REGISTRY] WARNING: Attempting to overwrite previously "
+ "registered RFNoC block with block key"
+ << block_key << std::endl;
return;
}
get_descriptor_block_registry().emplace(block_key, std::move(factory_fn));
}
-void registry::request_mb_access(noc_block_base::noc_id_t noc_id)
-{
- if (!get_direct_block_mb_access_requested().count(noc_id)) {
- get_direct_block_mb_access_requested().emplace(noc_id);
- }
-}
-
-void registry::request_mb_access(const std::string& block_key)
-{
- if (!get_descriptor_block_mb_access_requested().count(block_key)) {
- get_descriptor_block_mb_access_requested().emplace(block_key);
- }
-}
-
/******************************************************************************
* Factory functions
*****************************************************************************/
-block_factory_info_t factory::get_block_factory(noc_block_base::noc_id_t noc_id)
+block_factory_info_t factory::get_block_factory(noc_id_t noc_id, device_type_t device_id)
{
// First, check the descriptor registry
// FIXME TODO
// Second, check the direct registry
- if (!get_direct_block_registry().count(noc_id)) {
- UHD_LOG_WARNING("RFNOC::BLOCK_FACTORY",
- "Could not find block with Noc-ID "
- << std::hex << std::setw(sizeof(noc_block_base::noc_id_t) * 2) << noc_id);
- noc_id = DEFAULT_NOC_ID;
- }
- return get_direct_block_registry().at(noc_id);
-}
+ block_device_pair_t key{noc_id, device_id};
-bool factory::has_requested_mb_access(noc_block_base::noc_id_t noc_id)
-{
- if (get_direct_block_mb_access_requested().count(noc_id)) {
- return true;
+ if (!get_direct_block_registry().count(key)) {
+ key = block_device_pair_t(noc_id, ANY_DEVICE);
}
-
- // FIXME tbw:
- // - Map noc_id to block key
- // - Check that key's descriptor
- // - If that block has requested MB access, stash the noc ID in
- // get_direct_block_mb_access_requested() for faster lookups in the future
-
- return false;
+ if (!get_direct_block_registry().count(key)) {
+ UHD_LOG_WARNING("RFNOC::BLOCK_FACTORY",
+ "Could not find block with Noc-ID " << std::hex << "0x" << key.first << ", 0x"
+ << key.second << std::dec);
+ key = block_device_pair_t(DEFAULT_NOC_ID, ANY_DEVICE);
+ }
+ return get_direct_block_registry().at(key);
}