diff --git a/libs/libfabrickey/src/base/fabric_key.cpp b/libs/libfabrickey/src/base/fabric_key.cpp index f9c84103d..0ae52b821 100644 --- a/libs/libfabrickey/src/base/fabric_key.cpp +++ b/libs/libfabrickey/src/base/fabric_key.cpp @@ -39,6 +39,20 @@ FabricKey::fabric_word_line_bank_range FabricKey::wl_banks( wl_bank_ids_[region_id].end()); } +FabricKey::fabric_key_module_range FabricKey::modules() const { + return vtr::make_range(sub_key_module_ids_.begin(), + sub_key_module_ids_.end()); +} + +FabricKey::fabric_sub_key_range FabricKey::sub_keys( + const FabricKeyModuleId& module_id) const { + VTR_ASSERT(valid_module_id(module_id)); + return vtr::make_range( + sub_key_ids_.begin() + size_t(module_sub_keys_[module_id][0]), + sub_key_ids_.begin() + size_t(module_sub_keys_[module_id][0]) + + size_t(module_sub_keys_[module_id].size() - 1)); +} + /************************************************************************ * Public Accessors : Basic data query ***********************************************************************/ @@ -297,3 +311,13 @@ bool FabricKey::valid_wl_bank_id(const FabricRegionId& region_id, return (size_t(bank_id) < wl_bank_ids_[region_id].size()) && (bank_id == wl_bank_ids_[region_id][bank_id]); } + +bool FabricKey::valid_module_id(const FabricKeyModuleId& module_id) const { + return (size_t(module_id) < sub_key_module_ids_.size()) && + (module_id == sub_key_module_ids_[module_id]); +} + +bool FabricKey::valid_sub_key_id(const FabricSubKeyId& sub_key_id) const { + return (size_t(sub_key_id) < sub_key_ids_.size()) && + (sub_key_id == sub_key_ids_[sub_key_id]); +} diff --git a/libs/libfabrickey/src/base/fabric_key.h b/libs/libfabrickey/src/base/fabric_key.h index 53c9f89ac..3089b8638 100644 --- a/libs/libfabrickey/src/base/fabric_key.h +++ b/libs/libfabrickey/src/base/fabric_key.h @@ -47,12 +47,18 @@ class FabricKey { typedef vtr::vector::const_iterator fabric_word_line_bank_iterator; + typedef vtr::vector::const_iterator + fabric_sub_key_iterator; + typedef vtr::vector::const_iterator + fabric_key_module_iterator; /* Create range */ typedef vtr::Range fabric_region_range; typedef vtr::Range fabric_key_range; typedef vtr::Range fabric_bit_line_bank_range; typedef vtr::Range fabric_word_line_bank_range; + typedef vtr::Range fabric_sub_key_range; + typedef vtr::Range fabric_key_module_range; public: /* Constructors */ FabricKey(); @@ -62,6 +68,8 @@ class FabricKey { fabric_region_range regions() const; fabric_bit_line_bank_range bl_banks(const FabricRegionId& region_id) const; fabric_word_line_bank_range wl_banks(const FabricRegionId& region_id) const; + fabric_key_module_range modules() const; + fabric_sub_key_range sub_keys(const FabricKeyModuleId& module_id) const; public: /* Public Accessors: Basic data query */ /* Access all the keys of a region */ @@ -156,8 +164,11 @@ class FabricKey { const FabricBitLineBankId& bank_id) const; bool valid_wl_bank_id(const FabricRegionId& region_id, const FabricWordLineBankId& bank_id) const; + bool valid_module_id(const FabricKeyModuleId& module_id) const; + bool valid_sub_key_id(const FabricSubKeyId& sub_key_id) const; private: /* Internal data */ + /* ---- Top-level keys and regions ---- */ /* Unique ids for each region */ vtr::vector region_ids_; @@ -199,6 +210,18 @@ class FabricKey { vtr::vector>> wl_bank_data_ports_; + + /* ---- List of sub modules ---- */ + vtr::vector sub_key_module_ids_; + vtr::vector sub_key_module_names_; + vtr::vector> module_sub_keys_; + std::map module2subkey_lookup_; + + /* ---- Sub keys ---- */ + vtr::vector sub_key_ids_; + vtr::vector sub_key_names_; + vtr::vector sub_key_values_; + vtr::vector sub_key_alias_; }; #endif diff --git a/libs/libfabrickey/src/base/fabric_key_fwd.h b/libs/libfabrickey/src/base/fabric_key_fwd.h index 0c282092f..628f849d4 100644 --- a/libs/libfabrickey/src/base/fabric_key_fwd.h +++ b/libs/libfabrickey/src/base/fabric_key_fwd.h @@ -16,11 +16,15 @@ struct fabric_region_id_tag; struct fabric_key_id_tag; struct fabric_bit_line_bank_id_tag; struct fabric_word_line_bank_id_tag; +struct fabric_sub_key_id_tag; +struct fabric_key_module_id_tag; typedef vtr::StrongId FabricRegionId; typedef vtr::StrongId FabricKeyId; typedef vtr::StrongId FabricBitLineBankId; typedef vtr::StrongId FabricWordLineBankId; +typedef vtr::StrongId FabricSubKeyId; +typedef vtr::StrongId FabricKeyModuleId; /* Short declaration of class */ class FabricKey;