added mutators for technology library

This commit is contained in:
tangxifan 2020-01-17 14:46:09 -07:00
parent 6b703a4fc5
commit edaaa00c1d
2 changed files with 288 additions and 3 deletions

View File

@ -192,7 +192,7 @@ float TechnologyLibrary::rram_rhrs(const TechnologyDeviceId& device_id) const {
TechnologyVariationId TechnologyLibrary::rram_variation(const TechnologyDeviceId& device_id) const {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
/* This is only applicable to transistor device */
/* This is only applicable to RRAM device */
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id));
return rram_variation_ids_[device_id];
}
@ -226,6 +226,251 @@ size_t TechnologyLibrary::variation_num_sigma(const TechnologyVariationId& varia
return variation_num_sigmas_[variation_id];
}
/************************************************************************
* Public Mutators: device-related
***********************************************************************/
/* Add a new device to the library, return an id
* This function will check if the name has already been used inside the data structure.
* If used, it will return an invalid id
*/
TechnologyDeviceId TechnologyLibrary::add_device(const std::string& name) {
std::map<std::string, TechnologyDeviceId>::iterator it = device_name2ids_.find(name);
if (it != device_name2ids_.end()) {
return TechnologyDeviceId::INVALID();
}
/* This is a legal name. we can create a new id */
TechnologyDeviceId device = TechnologyDeviceId(device_ids_.size());
device_ids_.push_back(device);
device_names_.push_back(name);
device_types_.emplace_back(NUM_TECH_LIB_DEVICE_TYPES);
device_model_types_.emplace_back(NUM_TECH_LIB_MODEL_TYPES);
device_corners_.emplace_back();
device_model_refs_.emplace_back();
device_lib_paths_.emplace_back();
device_vdds_.push_back(-1);
device_pn_ratios_.push_back(-1);
transistor_model_names_.emplace_back();
transistor_model_chan_lengths_.emplace_back();
transistor_model_min_widths_.emplace_back();
transistor_model_variation_names_.emplace_back();
transistor_model_variation_ids_.emplace_back();
rram_resistances_.emplace_back();
rram_variation_names_.emplace_back();
rram_variation_ids_.emplace_back();
/* Register in the name-to-id map */
device_name2ids_[name] = device;
return device;
}
/* Set the device type of a device in the library */
void TechnologyLibrary::set_device_type(const TechnologyDeviceId& device_id,
const e_tech_lib_device_type& type) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
device_types_[device_id] = type;
return;
}
/* Set the model type of a device in the library */
void TechnologyLibrary::set_device_model_type(const TechnologyDeviceId& device_id,
const e_tech_lib_model_type& model_type) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
device_model_types_[device_id] = model_type;
return;
}
/* Set the process corner of a device in the library */
void TechnologyLibrary::set_device_corner(const TechnologyDeviceId& device_id,
const std::string& corner) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
device_corners_[device_id] = corner;
return;
}
/* Set the string used to model reference of a device in the library */
void TechnologyLibrary::set_device_model_ref(const TechnologyDeviceId& device_id,
const std::string& model_ref) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
device_model_refs_[device_id] = model_ref;
return;
}
/* Set the library file path of a device in the library */
void TechnologyLibrary::set_device_lib_path(const TechnologyDeviceId& device_id,
const std::string& lib_path) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
device_lib_paths_[device_id] = lib_path;
return;
}
/* Set the operating voltage of a device in the library
* This is ONLY applicable to transistors
*/
void TechnologyLibrary::set_device_vdd(const TechnologyDeviceId& device_id,
const float& vdd) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id));
device_vdds_[device_id] = vdd;
return;
}
/* Set the width ratio between PMOS and NMOS of a device in the library
* This is ONLY applicable to transistors
*/
void TechnologyLibrary::set_device_pn_ratio(const TechnologyDeviceId& device_id,
const float& pn_ratio) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id));
device_pn_ratios_[device_id] = pn_ratio;
return;
}
/************************************************************************
* Public Mutators: transistor-related
***********************************************************************/
/* Set the model name for either PMOS or NMOS of a device in the library
* This is ONLY applicable to transistors
*/
void TechnologyLibrary::set_transistor_model_name(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const std::string& model_name) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id));
transistor_model_names_[device_id][transistor_type] = model_name;
return;
}
/* Set the channel length for either PMOS or NMOS of a device in the library
* This is ONLY applicable to transistors
*/
void TechnologyLibrary::set_transistor_model_chan_length(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const float& chan_length) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id));
transistor_model_chan_lengths_[device_id][transistor_type] = chan_length;
return;
}
/* Set the minimum width for either PMOS or NMOS of a device in the library
* This is ONLY applicable to transistors
*/
void TechnologyLibrary::set_transistor_model_min_width(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const float& min_width) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id));
transistor_model_min_widths_[device_id][transistor_type] = min_width;
return;
}
/* Set the variation name for either PMOS or NMOS of a device in the library
* This is ONLY applicable to transistors
*/
void TechnologyLibrary::set_transistor_model_variation_name(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const std::string& variation_name) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id));
transistor_model_variation_names_[device_id][transistor_type] = variation_name;
return;
}
/************************************************************************
* Public Mutators: RRAM-related
***********************************************************************/
/* Set the Low Resistance State (LRS) resistance for a RRAM device in the library
* This is ONLY applicable to RRAM devices
*/
void TechnologyLibrary::set_rram_rlrs(const TechnologyDeviceId& device_id,
const float& rlrs) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id));
rram_resistances_[device_id].set_x(rlrs);
return;
}
/* Set the High Resistance State (HRS) resistance for a RRAM device in the library
* This is ONLY applicable to RRAM devices
*/
void TechnologyLibrary::set_rram_rhrs(const TechnologyDeviceId& device_id,
const float& rhrs) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id));
rram_resistances_[device_id].set_y(rhrs);
return;
}
/* Set the variation name for a RRAM device in the library
* This is ONLY applicable to RRAM devices
*/
void TechnologyLibrary::set_rram_variation_name(const TechnologyDeviceId& device_id,
const std::string& variation_name) {
/* validate the device_id */
VTR_ASSERT(valid_device_id(device_id));
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id));
rram_variation_names_[device_id] = variation_name;
return;
}
/************************************************************************
* Public Mutators: variation-related
***********************************************************************/
/* Add a new variation to the library, return an id
* This function will check if the name has already been used inside the data structure.
* If used, it will return an invalid id
*/
TechnologyVariationId TechnologyLibrary::add_variation(const std::string& name) {
std::map<std::string, TechnologyVariationId>::iterator it = variation_name2ids_.find(name);
if (it != variation_name2ids_.end()) {
return TechnologyVariationId::INVALID();
}
/* This is a legal name. we can create a new id */
TechnologyVariationId variation = TechnologyVariationId(variation_ids_.size());
variation_names_.push_back(name);
variation_abs_values_.push_back(0.);
variation_num_sigmas_.push_back(size_t(-1));
/* Register in the name-to-id map */
variation_name2ids_[name] = variation;
return variation;
}
/* Set the absolute value of a variation */
void TechnologyLibrary::set_variation_abs_value(const TechnologyVariationId& variation_id, const float& abs_value) {
/* validate the variation_id */
VTR_ASSERT(valid_variation_id(variation_id));
variation_abs_values_[variation_id] = abs_value;
return;
}
/* Set the number of sigma of a variation */
void TechnologyLibrary::set_variation_num_sigma(const TechnologyVariationId& variation_id, const size_t& num_sigma) {
/* validate the variation_id */
VTR_ASSERT(valid_variation_id(variation_id));
variation_num_sigmas_[variation_id] = num_sigma;
return;
}
/************************************************************************
* Internal invalidators/validators
***********************************************************************/

View File

@ -115,6 +115,46 @@ class TechnologyLibrary {
TechnologyVariationId variation(const std::string& name) const;
float variation_abs_value(const TechnologyVariationId& variation_id) const;
size_t variation_num_sigma(const TechnologyVariationId& variation_id) const;
public: /* Public Mutators: device-related */
TechnologyDeviceId add_device(const std::string& name);
void set_device_type(const TechnologyDeviceId& device_id,
const e_tech_lib_device_type& type);
void set_device_model_type(const TechnologyDeviceId& device_id,
const e_tech_lib_model_type& model_type);
void set_device_corner(const TechnologyDeviceId& device_id,
const std::string& corner);
void set_device_model_ref(const TechnologyDeviceId& device_id,
const std::string& model_ref);
void set_device_lib_path(const TechnologyDeviceId& device_id,
const std::string& lib_path);
void set_device_vdd(const TechnologyDeviceId& device_id,
const float& vdd);
void set_device_pn_ratio(const TechnologyDeviceId& device_id,
const float& pn_ratio);
public: /* Public Mutators: transistor-related */
void set_transistor_model_name(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const std::string& model_name);
void set_transistor_model_chan_length(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const float& chan_length);
void set_transistor_model_min_width(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const float& min_width);
void set_transistor_model_variation_name(const TechnologyDeviceId& device_id,
const e_tech_lib_trans_type& transistor_type,
const std::string& variation_name);
public: /* Public Mutators: RRAM-related */
void set_rram_rlrs(const TechnologyDeviceId& device_id,
const float& rlrs);
void set_rram_rhrs(const TechnologyDeviceId& device_id,
const float& rhrs);
void set_rram_variation_name(const TechnologyDeviceId& device_id,
const std::string& variation_name);
public: /* Public Mutators: variation-related */
TechnologyVariationId add_variation(const std::string& name);
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);
public: /* Public invalidators/validators */
bool valid_device_id(const TechnologyDeviceId& device_id) const;
bool valid_variation_id(const TechnologyVariationId& variation_id) const;
@ -135,11 +175,11 @@ class TechnologyLibrary {
vtr::vector<TechnologyDeviceId, std::array<float, 2>> transistor_model_chan_lengths_;
vtr::vector<TechnologyDeviceId, std::array<float, 2>> transistor_model_min_widths_;
vtr::vector<TechnologyDeviceId, std::array<std::string, 2>> transistor_model_variation_names_;
vtr::vector<TechnologyDeviceId, std::array<TechnologyVariationId,2 >> transistor_model_variation_ids_;
vtr::vector<TechnologyDeviceId, std::array<TechnologyVariationId, 2>> transistor_model_variation_ids_;
/* ReRAM-related fundamental information: LRS -> x(); HRS -> y() */
vtr::vector<TechnologyDeviceId, vtr::Point<float>> rram_resistances_;
vtr::vector<TechnologyDeviceId, float> rram_variation_names_;
vtr::vector<TechnologyDeviceId, std::string> rram_variation_names_;
vtr::vector<TechnologyDeviceId, TechnologyVariationId> rram_variation_ids_;
/* Variation-related fundamental information */