add internal linker to technology library

This commit is contained in:
tangxifan 2020-01-17 15:04:00 -07:00
parent edaaa00c1d
commit 313922f03f
2 changed files with 56 additions and 6 deletions

View File

@ -48,8 +48,16 @@ std::string TechnologyLibrary::device_name(const TechnologyDeviceId& device_id)
return device_names_[device_id]; return device_names_[device_id];
} }
/* Access the id of a technology device by name */ /* Access the id of a technology device by name,
* If the name is valid, we return a valid id
* Otherwise, return an invalid id
*/
TechnologyDeviceId TechnologyLibrary::device(const std::string& name) const { TechnologyDeviceId TechnologyLibrary::device(const std::string& name) const {
std::map<std::string, TechnologyDeviceId>::const_iterator it = device_name2ids_.find(name);
if (it != device_name2ids_.end()) {
return TechnologyDeviceId::INVALID();
}
return device_name2ids_.at(name); return device_name2ids_.at(name);
} }
@ -207,8 +215,16 @@ std::string TechnologyLibrary::variation_name(const TechnologyVariationId& varia
return variation_names_[variation_id]; return variation_names_[variation_id];
} }
/* Access the id of a technology variation by name */ /* Access the id of a technology variation by name
* If the name is valid, we return a valid id
* Otherwise, return an invalid id
*/
TechnologyVariationId TechnologyLibrary::variation(const std::string& name) const { TechnologyVariationId TechnologyLibrary::variation(const std::string& name) const {
std::map<std::string, TechnologyVariationId>::const_iterator it = variation_name2ids_.find(name);
if (it != variation_name2ids_.end()) {
return TechnologyVariationId::INVALID();
}
return variation_name2ids_.at(name); return variation_name2ids_.at(name);
} }
@ -471,6 +487,38 @@ void TechnologyLibrary::set_variation_num_sigma(const TechnologyVariationId& var
return; return;
} }
/************************************************************************
* Public mutators: linkers
***********************************************************************/
/* This function builds the links between devices and variations,
* which have been defined in the technology library
*/
void TechnologyLibrary::link_devices_to_variations() {
for (const TechnologyDeviceId& device : devices()) {
/* For transistors, find the variation name for each model and build a link */
if (TECH_LIB_DEVICE_TRANSISTOR == device_type(device)) {
/* PMOS transistor, if a variation name is specified, we try to build a link
* Otherwise, we assign any invalid id */
const std::string& pmos_var_name = transistor_model_variation_names_[device][TECH_LIB_TRANSISTOR_PMOS];
transistor_model_variation_ids_[device][TECH_LIB_TRANSISTOR_PMOS] = variation(pmos_var_name);
/* NMOS transistor, if a variation name is specified, we try to build a link
* Otherwise, we assign any invalid id
*/
const std::string& nmos_var_name = transistor_model_variation_names_[device][TECH_LIB_TRANSISTOR_NMOS];
transistor_model_variation_ids_[device][TECH_LIB_TRANSISTOR_NMOS] = variation(nmos_var_name);
/* Finish for transistors, go to the next */
continue;
}
/* Reach here it means an RRAM device, we find the variation name and try to build a link */
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device));
const std::string& rram_var_name = rram_variation_names_[device];
rram_variation_ids_[device] = variation(rram_var_name);
/* Finish for RRAMs, go to the next */
}
}
/************************************************************************ /************************************************************************
* Internal invalidators/validators * Internal invalidators/validators
***********************************************************************/ ***********************************************************************/

View File

@ -52,12 +52,12 @@ constexpr std::array<const char*, NUM_TECH_LIB_DEVICE_TYPES> TECH_LIB_DEVICE_TYP
* 2. PMOS transistor * 2. PMOS transistor
*******************************************************************/ *******************************************************************/
enum e_tech_lib_trans_type { enum e_tech_lib_trans_type {
TECH_LIB_TRANS_PMOS, TECH_LIB_TRANSISTOR_PMOS,
TECH_LIB_TRANS_NMOS, TECH_LIB_TRANSISTOR_NMOS,
NUM_TECH_LIB_TRANS_TYPES NUM_TECH_LIB_TRANSISTOR_TYPES
}; };
/* Strings correspond to transistor type */ /* Strings correspond to transistor type */
constexpr std::array<const char*, NUM_TECH_LIB_TRANS_TYPES> TECH_LIB_TRANS_TYPE_STRING = {{"pmos", "nmos"}}; constexpr std::array<const char*, NUM_TECH_LIB_TRANSISTOR_TYPES> TECH_LIB_TRANSISTOR_TYPE_STRING = {{"pmos", "nmos"}};
/******************************************************************** /********************************************************************
* Process corners supported * Process corners supported
@ -155,6 +155,8 @@ class TechnologyLibrary {
TechnologyVariationId add_variation(const std::string& name); TechnologyVariationId add_variation(const std::string& name);
void set_variation_abs_value(const TechnologyVariationId& variation_id, const float& abs_value); void set_variation_abs_value(const TechnologyVariationId& variation_id, const float& abs_value);
void set_variation_num_sigma(const TechnologyVariationId& variation_id, const size_t& num_sigma); void set_variation_num_sigma(const TechnologyVariationId& variation_id, const size_t& num_sigma);
public: /* Public Mutators: linkers */
void link_devices_to_variations();
public: /* Public invalidators/validators */ public: /* Public invalidators/validators */
bool valid_device_id(const TechnologyDeviceId& device_id) const; bool valid_device_id(const TechnologyDeviceId& device_id) const;
bool valid_variation_id(const TechnologyVariationId& variation_id) const; bool valid_variation_id(const TechnologyVariationId& variation_id) const;