[lib] adding subkey feature

This commit is contained in:
tangxifan 2023-07-03 15:53:22 -07:00
parent 1b9aeab2a7
commit 93158bdc62
3 changed files with 51 additions and 0 deletions

View File

@ -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]);
}

View File

@ -47,12 +47,18 @@ class FabricKey {
typedef vtr::vector<FabricWordLineBankId,
FabricWordLineBankId>::const_iterator
fabric_word_line_bank_iterator;
typedef vtr::vector<FabricSubKeyId, FabricSubKeyId>::const_iterator
fabric_sub_key_iterator;
typedef vtr::vector<FabricKeyModuleId, FabricKeyModuleId>::const_iterator
fabric_key_module_iterator;
/* Create range */
typedef vtr::Range<fabric_region_iterator> fabric_region_range;
typedef vtr::Range<fabric_key_iterator> fabric_key_range;
typedef vtr::Range<fabric_bit_line_bank_iterator> fabric_bit_line_bank_range;
typedef vtr::Range<fabric_word_line_bank_iterator>
fabric_word_line_bank_range;
typedef vtr::Range<fabric_sub_key_iterator> fabric_sub_key_range;
typedef vtr::Range<fabric_key_module_iterator> 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<FabricRegionId, FabricRegionId> region_ids_;
@ -199,6 +210,18 @@ class FabricKey {
vtr::vector<FabricRegionId, vtr::vector<FabricWordLineBankId,
std::vector<openfpga::BasicPort>>>
wl_bank_data_ports_;
/* ---- List of sub modules ---- */
vtr::vector<FabricKeyModuleId, FabricKeyModuleId> sub_key_module_ids_;
vtr::vector<FabricKeyModuleId, std::string> sub_key_module_names_;
vtr::vector<FabricKeyModuleId, std::vector<FabricSubKeyId>> module_sub_keys_;
std::map<std::string, FabricKeyModuleId> module2subkey_lookup_;
/* ---- Sub keys ---- */
vtr::vector<FabricSubKeyId, FabricSubKeyId> sub_key_ids_;
vtr::vector<FabricSubKeyId, std::string> sub_key_names_;
vtr::vector<FabricSubKeyId, size_t> sub_key_values_;
vtr::vector<FabricSubKeyId, std::string> sub_key_alias_;
};
#endif

View File

@ -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<fabric_region_id_tag> FabricRegionId;
typedef vtr::StrongId<fabric_key_id_tag> FabricKeyId;
typedef vtr::StrongId<fabric_bit_line_bank_id_tag> FabricBitLineBankId;
typedef vtr::StrongId<fabric_word_line_bank_id_tag> FabricWordLineBankId;
typedef vtr::StrongId<fabric_sub_key_id_tag> FabricSubKeyId;
typedef vtr::StrongId<fabric_key_module_id_tag> FabricKeyModuleId;
/* Short declaration of class */
class FabricKey;