rename some methods in technology library and start building associated XML parser

This commit is contained in:
tangxifan 2020-01-17 16:44:57 -07:00
parent b1501223cc
commit 88a96673e3
6 changed files with 368 additions and 370 deletions

View File

@ -9,32 +9,34 @@
--> -->
<openfpga_architecture> <openfpga_architecture>
<technology_library> <technology_library>
<device name="logic" type="transistor"> <device_library>
<model type="academia" corner="TOP_TT" ref="M" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/45nm.pm"/> <device_model name="logic" type="transistor">
<design vdd="0.9" pn_ratio="2"/> <lib type="academia" corner="TOP_TT" ref="M" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/45nm.pm"/>
<nmos name="nch" chan_length="40e-9" min_width="140e-9" variation="logic_transistor_var"/> <design vdd="0.9" pn_ratio="2"/>
<pmos name="pch" chan_length="40e-9" min_width="140e-9" variation="logic_transistor_var"/> <nmos name="nch" chan_length="40e-9" min_width="140e-9" variation="logic_transistor_var"/>
</device> <pmos name="pch" chan_length="40e-9" min_width="140e-9" variation="logic_transistor_var"/>
<device name="io" type="transistor"/> </device_model>
<model type="academia" corner="TT" ref="M" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/45nm.pm"/> <device_model name="io" type="transistor"/>
<design vdd="2.5" pn_ratio="3"/> <lib type="academia" corner="TT" ref="M" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/45nm.pm"/>
<nmos name="nch_25" chan_length="270e-9" min_width="320e-9" variation="io_transistor_var"/> <design vdd="2.5" pn_ratio="3"/>
<pmos name="pch_25" chan_length="270e-9" min_width="320e-9" variation="io_transistor_var"/> <nmos name="nch_25" chan_length="270e-9" min_width="320e-9" variation="io_transistor_var"/>
</device> <pmos name="pch_25" chan_length="270e-9" min_width="320e-9" variation="io_transistor_var"/>
<device name="mem_rram" type="rram"> </device_model>
<model type="academia" ref="X" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/rram.pm"/> <device_model name="mem_rram" type="rram">
<rram rlrs="1e4" rhrs="1e5" variation="mem_rram_var"/> <lib type="academia" ref="X" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/rram.pm"/>
</device> <rram rlrs="1e4" rhrs="1e5" variation="mem_rram_var"/>
<device name="logic_rram" type="rram"> </device_model>
<model type="academia" ref="X" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/rram.pm"/> <device_model name="logic_rram" type="rram">
<rram rlrs="5e3" rhrs="20e6" variation="logic_rram_var"/> <lib type="academia" ref="X" path="${OPENFPGA_PATH}/openfpga_flow/tech/PTM_45nm/rram.pm"/>
</device> <rram rlrs="5e3" rhrs="20e6" variation="logic_rram_var"/>
<device_variation> </device_model>
</device_library>
<variation_library>
<variation name="logic_transistor_var" abs_variation="0.1" num_sigma="3"/> <variation name="logic_transistor_var" abs_variation="0.1" num_sigma="3"/>
<variation name="io_transistor_var" abs_variation="0.1" num_sigma="3"/> <variation name="io_transistor_var" abs_variation="0.1" num_sigma="3"/>
<variation name="mem_rram_var" abs_variation="0.1" num_sigma="3"/> <variation name="mem_rram_var" abs_variation="0.1" num_sigma="3"/>
<variation name="logic_rram_var" abs_variation="0.1" num_sigma="3"/> <variation name="logic_rram_var" abs_variation="0.1" num_sigma="3"/>
</device_variation> </variation_library>
</technology_library> </technology_library>
<circuit_library> <circuit_library>
<circuit_model type="inv_buf" name="INVTX1" prefix="INVTX1" is_default="true"> <circuit_model type="inv_buf" name="INVTX1" prefix="INVTX1" is_default="true">

View File

@ -2,6 +2,7 @@
#define OPENFPGA_ARCH_H #define OPENFPGA_ARCH_H
#include "circuit_library.h" #include "circuit_library.h"
#include "technology_library.h"
/* namespace openfpga begins */ /* namespace openfpga begins */
namespace openfpga { namespace openfpga {
@ -11,6 +12,7 @@ namespace openfpga {
*/ */
struct Arch { struct Arch {
CircuitLibrary circuit_lib; CircuitLibrary circuit_lib;
TechnologyLibrary tech_lib;
}; };
} /* namespace openfpga ends */ } /* namespace openfpga ends */

View File

@ -13,6 +13,7 @@
#include "arch_error.h" #include "arch_error.h"
#include "read_xml_util.h" #include "read_xml_util.h"
#include "read_xml_technology_library.h"
#include "read_xml_circuit_library.h" #include "read_xml_circuit_library.h"
#include "read_xml_openfpga_arch.h" #include "read_xml_openfpga_arch.h"
@ -33,12 +34,12 @@ openfpga::Arch read_xml_openfpga_arch(const char* arch_file_name) {
loc_data = pugiutil::load_xml(doc, arch_file_name); loc_data = pugiutil::load_xml(doc, arch_file_name);
/* First node should be <openfpga_architecture> */ /* First node should be <openfpga_architecture> */
auto xml_circuit_settings = get_single_child(doc, "openfpga_architecture", loc_data); auto xml_openfpga_arch = get_single_child(doc, "openfpga_architecture", loc_data);
/* Parse circuit_models to circuit library /* Parse circuit_models to circuit library
* under the node <module_circuit_models> * under the node <module_circuit_models>
*/ */
auto xml_circuit_models = get_single_child(xml_circuit_settings, "circuit_library", loc_data); auto xml_circuit_models = get_single_child(xml_openfpga_arch, "circuit_library", loc_data);
openfpga_arch.circuit_lib = read_xml_circuit_library(xml_circuit_models, loc_data); openfpga_arch.circuit_lib = read_xml_circuit_library(xml_circuit_models, loc_data);
/* Build the internal links for the circuit library */ /* Build the internal links for the circuit library */
@ -47,6 +48,10 @@ openfpga::Arch read_xml_openfpga_arch(const char* arch_file_name) {
/* Build the timing graph inside the circuit library */ /* Build the timing graph inside the circuit library */
openfpga_arch.circuit_lib.build_timing_graphs(); openfpga_arch.circuit_lib.build_timing_graphs();
/* Parse technology library */
auto xml_tech_lib = get_single_child(xml_openfpga_arch, "technology_library", loc_data);
openfpga_arch.tech_lib = read_xml_technology_library(xml_tech_lib, loc_data);
/* Second node should be <openfpga_simulation_setting> */ /* Second node should be <openfpga_simulation_setting> */
auto xml_simulation_settings = get_single_child(doc, "openfpga_simulation_setting", loc_data); auto xml_simulation_settings = get_single_child(doc, "openfpga_simulation_setting", loc_data);

View File

@ -16,20 +16,20 @@ TechnologyLibrary::TechnologyLibrary() {
/************************************************************************ /************************************************************************
* Public Accessors : aggregates * Public Accessors : aggregates
***********************************************************************/ ***********************************************************************/
TechnologyLibrary::technology_device_range TechnologyLibrary::devices() const { TechnologyLibrary::technology_model_range TechnologyLibrary::models() const {
return vtr::make_range(device_ids_.begin(), device_ids_.end()); return vtr::make_range(model_ids_.begin(), model_ids_.end());
} }
TechnologyLibrary::technology_variation_range TechnologyLibrary::variations() const { TechnologyLibrary::technology_variation_range TechnologyLibrary::variations() const {
return vtr::make_range(variation_ids_.begin(), variation_ids_.end()); return vtr::make_range(variation_ids_.begin(), variation_ids_.end());
} }
/* Find technology devices in the same type (defined by users) and return a list of ids */ /* Find technology models in the same type (defined by users) and return a list of ids */
std::vector<TechnologyDeviceId> TechnologyLibrary::devices_by_type(const enum e_tech_lib_device_type& type) const { std::vector<TechnologyModelId> TechnologyLibrary::models_by_type(const enum e_tech_lib_model_type& type) const {
std::vector<TechnologyDeviceId> type_ids; std::vector<TechnologyModelId> type_ids;
for (auto id : devices()) { for (auto id : models()) {
/* Skip unmatched types */ /* Skip unmatched types */
if (type != device_type(id)) { if (type != model_type(id)) {
continue; continue;
} }
/* Matched type, update the vector */ /* Matched type, update the vector */
@ -39,170 +39,170 @@ std::vector<TechnologyDeviceId> TechnologyLibrary::devices_by_type(const enum e_
} }
/************************************************************************ /************************************************************************
* Public Accessors : Basic data query on technology devices * Public Accessors : Basic data query on technology models
***********************************************************************/ ***********************************************************************/
/* Access the name of a technology device */ /* Access the name of a technology model */
std::string TechnologyLibrary::device_name(const TechnologyDeviceId& device_id) const { std::string TechnologyLibrary::model_name(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
return device_names_[device_id]; return model_names_[model_id];
} }
/* Access the id of a technology device by name, /* Access the id of a technology model by name,
* If the name is valid, we return a valid id * If the name is valid, we return a valid id
* Otherwise, return an invalid id * Otherwise, return an invalid id
*/ */
TechnologyDeviceId TechnologyLibrary::device(const std::string& name) const { TechnologyModelId TechnologyLibrary::model(const std::string& name) const {
std::map<std::string, TechnologyDeviceId>::const_iterator it = device_name2ids_.find(name); std::map<std::string, TechnologyModelId>::const_iterator it = model_name2ids_.find(name);
if (it != device_name2ids_.end()) { if (it != model_name2ids_.end()) {
return TechnologyDeviceId::INVALID(); return TechnologyModelId::INVALID();
} }
return device_name2ids_.at(name); return model_name2ids_.at(name);
} }
/* Access the type of a technology device */ /* Access the type of a technology model */
enum e_tech_lib_device_type TechnologyLibrary::device_type(const TechnologyDeviceId& device_id) const { enum e_tech_lib_model_type TechnologyLibrary::model_type(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
return device_types_[device_id]; return model_types_[model_id];
} }
/* Access the model type of a technology device */ /* Access the model type of a technology model */
enum e_tech_lib_model_type TechnologyLibrary::device_model_type(const TechnologyDeviceId& device_id) const { enum e_tech_lib_type TechnologyLibrary::model_lib_type(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
return device_model_types_[device_id]; return model_lib_types_[model_id];
} }
/* Access the process corner name of a technology device */ /* Access the process corner name of a technology model */
std::string TechnologyLibrary::device_corner(const TechnologyDeviceId& device_id) const { std::string TechnologyLibrary::model_corner(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
return device_corners_[device_id]; return model_corners_[model_id];
} }
/* Access the model reference name of a technology device */ /* Access the model reference name of a technology model */
std::string TechnologyLibrary::device_model_ref(const TechnologyDeviceId& device_id) const { std::string TechnologyLibrary::model_ref(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
return device_model_refs_[device_id]; return model_refs_[model_id];
} }
/* Access the path of library for a technology device */ /* Access the path of library for a technology model */
std::string TechnologyLibrary::device_lib_path(const TechnologyDeviceId& device_id) const { std::string TechnologyLibrary::model_lib_path(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
return device_lib_paths_[device_id]; return model_lib_paths_[model_id];
} }
/* Access the VDD of a technology device /* Access the VDD of a technology model
* Note: This is ONLY applicable to transistor device * Note: This is ONLY applicable to transistor model
*/ */
float TechnologyLibrary::device_vdd(const TechnologyDeviceId& device_id) const { float TechnologyLibrary::model_vdd(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
return device_vdds_[device_id]; return model_vdds_[model_id];
} }
/* Access the width ratio between PMOS and NMOS for a technology device /* Access the width ratio between PMOS and NMOS for a technology model
* Note: This is ONLY applicable to transistor device * Note: This is ONLY applicable to transistor model
*/ */
float TechnologyLibrary::device_pn_ratio(const TechnologyDeviceId& device_id) const { float TechnologyLibrary::model_pn_ratio(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
return device_pn_ratios_[device_id]; return model_pn_ratios_[model_id];
} }
/************************************************************************ /************************************************************************
* Public Accessors : Basic data query on transistors * Public Accessors : Basic data query on transistors
***********************************************************************/ ***********************************************************************/
/* Access the model name of a transistor (either PMOS or NMOS) for a technology device /* Access the model name of a transistor (either PMOS or NMOS) for a technology model
* Note: This is ONLY applicable to transistor device * Note: This is ONLY applicable to transistor model
*/ */
std::string TechnologyLibrary::transistor_model_name(const TechnologyDeviceId& device_id, std::string TechnologyLibrary::transistor_model_name(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const { const e_tech_lib_transistor_type& transistor_type) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
return transistor_model_names_[device_id][transistor_type]; return transistor_model_names_[model_id][transistor_type];
} }
/* Access the channel length of a transistor (either PMOS or NMOS) for a technology device /* Access the channel length of a transistor (either PMOS or NMOS) for a technology model
* Note: This is ONLY applicable to transistor device * Note: This is ONLY applicable to transistor model
*/ */
float TechnologyLibrary::transistor_model_chan_length(const TechnologyDeviceId& device_id, float TechnologyLibrary::transistor_model_chan_length(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const { const e_tech_lib_transistor_type& transistor_type) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
return transistor_model_chan_lengths_[device_id][transistor_type]; return transistor_model_chan_lengths_[model_id][transistor_type];
} }
/* Access the minimum width of a transistor (either PMOS or NMOS) for a technology device /* Access the minimum width of a transistor (either PMOS or NMOS) for a technology model
* Note: This is ONLY applicable to transistor device * Note: This is ONLY applicable to transistor model
*/ */
float TechnologyLibrary::transistor_model_min_width(const TechnologyDeviceId& device_id, float TechnologyLibrary::transistor_model_min_width(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const { const e_tech_lib_transistor_type& transistor_type) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
return transistor_model_min_widths_[device_id][transistor_type]; return transistor_model_min_widths_[model_id][transistor_type];
} }
/* Access the minimum width of a transistor (either PMOS or NMOS) for a technology device /* Access the minimum width of a transistor (either PMOS or NMOS) for a technology model
* Note: This is ONLY applicable to transistor device * Note: This is ONLY applicable to transistor model
*/ */
TechnologyVariationId TechnologyLibrary::transistor_model_variation(const TechnologyDeviceId& device_id, TechnologyVariationId TechnologyLibrary::transistor_model_variation(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const { const e_tech_lib_transistor_type& transistor_type) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
return transistor_model_variation_ids_[device_id][transistor_type]; return transistor_model_variation_ids_[model_id][transistor_type];
} }
/************************************************************************ /************************************************************************
* Public Accessors : Basic data query on RRAM devices * Public Accessors : Basic data query on RRAM models
***********************************************************************/ ***********************************************************************/
/* Access the Low Resistence of a RRAM for a technology device /* Access the Low Resistence of a RRAM for a technology model
* Note: This is ONLY applicable to RRAM device * Note: This is ONLY applicable to RRAM model
*/ */
float TechnologyLibrary::rram_rlrs(const TechnologyDeviceId& device_id) const { float TechnologyLibrary::rram_rlrs(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model_id));
return rram_resistances_[device_id].x(); return rram_resistances_[model_id].x();
} }
/* Access the High Resistence of a RRAM for a technology device /* Access the High Resistence of a RRAM for a technology model
* Note: This is ONLY applicable to RRAM device * Note: This is ONLY applicable to RRAM model
*/ */
float TechnologyLibrary::rram_rhrs(const TechnologyDeviceId& device_id) const { float TechnologyLibrary::rram_rhrs(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to transistor device */ /* This is only applicable to transistor model */
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model_id));
return rram_resistances_[device_id].y(); return rram_resistances_[model_id].y();
} }
/* Access the Variation id of a RRAM for a technology device /* Access the Variation id of a RRAM for a technology model
* Note: This is ONLY applicable to RRAM device * Note: This is ONLY applicable to RRAM model
*/ */
TechnologyVariationId TechnologyLibrary::rram_variation(const TechnologyDeviceId& device_id) const { TechnologyVariationId TechnologyLibrary::rram_variation(const TechnologyModelId& model_id) const {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
/* This is only applicable to RRAM device */ /* This is only applicable to RRAM model */
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model_id));
return rram_variation_ids_[device_id]; return rram_variation_ids_[model_id];
} }
/************************************************************************ /************************************************************************
@ -243,29 +243,29 @@ size_t TechnologyLibrary::variation_num_sigma(const TechnologyVariationId& varia
} }
/************************************************************************ /************************************************************************
* Public Mutators: device-related * Public Mutators: model-related
***********************************************************************/ ***********************************************************************/
/* Add a new device to the library, return an id /* Add a new model to the library, return an id
* This function will check if the name has already been used inside the data structure. * This function will check if the name has already been used inside the data structure.
* If used, it will return an invalid id * If used, it will return an invalid id
*/ */
TechnologyDeviceId TechnologyLibrary::add_device(const std::string& name) { TechnologyModelId TechnologyLibrary::add_model(const std::string& name) {
std::map<std::string, TechnologyDeviceId>::iterator it = device_name2ids_.find(name); std::map<std::string, TechnologyModelId>::iterator it = model_name2ids_.find(name);
if (it != device_name2ids_.end()) { if (it != model_name2ids_.end()) {
return TechnologyDeviceId::INVALID(); return TechnologyModelId::INVALID();
} }
/* This is a legal name. we can create a new id */ /* This is a legal name. we can create a new id */
TechnologyDeviceId device = TechnologyDeviceId(device_ids_.size()); TechnologyModelId model = TechnologyModelId(model_ids_.size());
device_ids_.push_back(device); model_ids_.push_back(model);
device_names_.push_back(name); model_names_.push_back(name);
device_types_.emplace_back(NUM_TECH_LIB_DEVICE_TYPES); model_types_.emplace_back(NUM_TECH_LIB_MODEL_TYPES);
device_model_types_.emplace_back(NUM_TECH_LIB_MODEL_TYPES); model_lib_types_.emplace_back(NUM_TECH_LIB_TYPES);
device_corners_.emplace_back(); model_corners_.emplace_back();
device_model_refs_.emplace_back(); model_refs_.emplace_back();
device_lib_paths_.emplace_back(); model_lib_paths_.emplace_back();
device_vdds_.push_back(-1); model_vdds_.push_back(-1);
device_pn_ratios_.push_back(-1); model_pn_ratios_.push_back(-1);
transistor_model_names_.emplace_back(); transistor_model_names_.emplace_back();
transistor_model_chan_lengths_.emplace_back(); transistor_model_chan_lengths_.emplace_back();
@ -278,171 +278,171 @@ TechnologyDeviceId TechnologyLibrary::add_device(const std::string& name) {
rram_variation_ids_.emplace_back(); rram_variation_ids_.emplace_back();
/* Register in the name-to-id map */ /* Register in the name-to-id map */
device_name2ids_[name] = device; model_name2ids_[name] = model;
return device; return model;
} }
/* Set the device type of a device in the library */ /* Set the model type of a model in the library */
void TechnologyLibrary::set_device_type(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_type(const TechnologyModelId& model_id,
const e_tech_lib_device_type& type) { const e_tech_lib_model_type& type) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
device_types_[device_id] = type; model_types_[model_id] = type;
return; return;
} }
/* Set the model type of a device in the library */ /* Set the model type of a device model in the library */
void TechnologyLibrary::set_device_model_type(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_lib_type(const TechnologyModelId& model_id,
const e_tech_lib_model_type& model_type) { const e_tech_lib_type& model_lib_type) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
device_model_types_[device_id] = model_type; model_lib_types_[model_id] = model_lib_type;
return; return;
} }
/* Set the process corner of a device in the library */ /* Set the process corner of a model in the library */
void TechnologyLibrary::set_device_corner(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_corner(const TechnologyModelId& model_id,
const std::string& corner) { const std::string& corner) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
device_corners_[device_id] = corner; model_corners_[model_id] = corner;
return; return;
} }
/* Set the string used to model reference of a device in the library */ /* Set the string used to model reference of a model in the library */
void TechnologyLibrary::set_device_model_ref(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_ref(const TechnologyModelId& model_id,
const std::string& model_ref) { const std::string& model_ref) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
device_model_refs_[device_id] = model_ref; model_refs_[model_id] = model_ref;
return; return;
} }
/* Set the library file path of a device in the library */ /* Set the library file path of a model in the library */
void TechnologyLibrary::set_device_lib_path(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_lib_path(const TechnologyModelId& model_id,
const std::string& lib_path) { const std::string& lib_path) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
device_lib_paths_[device_id] = lib_path; model_lib_paths_[model_id] = lib_path;
return; return;
} }
/* Set the operating voltage of a device in the library /* Set the operating voltage of a model in the library
* This is ONLY applicable to transistors * This is ONLY applicable to transistors
*/ */
void TechnologyLibrary::set_device_vdd(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_vdd(const TechnologyModelId& model_id,
const float& vdd) { const float& vdd) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
device_vdds_[device_id] = vdd; model_vdds_[model_id] = vdd;
return; return;
} }
/* Set the width ratio between PMOS and NMOS of a device in the library /* Set the width ratio between PMOS and NMOS of a model in the library
* This is ONLY applicable to transistors * This is ONLY applicable to transistors
*/ */
void TechnologyLibrary::set_device_pn_ratio(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_model_pn_ratio(const TechnologyModelId& model_id,
const float& pn_ratio) { const float& pn_ratio) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
device_pn_ratios_[device_id] = pn_ratio; model_pn_ratios_[model_id] = pn_ratio;
return; return;
} }
/************************************************************************ /************************************************************************
* Public Mutators: transistor-related * Public Mutators: transistor-related
***********************************************************************/ ***********************************************************************/
/* Set the model name for either PMOS or NMOS of a device in the library /* Set the model name for either PMOS or NMOS of a model in the library
* This is ONLY applicable to transistors * This is ONLY applicable to transistors
*/ */
void TechnologyLibrary::set_transistor_model_name(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_transistor_model_name(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const std::string& model_name) { const std::string& model_name) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
transistor_model_names_[device_id][transistor_type] = model_name; transistor_model_names_[model_id][transistor_type] = model_name;
return; return;
} }
/* Set the channel length for either PMOS or NMOS of a device in the library /* Set the channel length for either PMOS or NMOS of a model in the library
* This is ONLY applicable to transistors * This is ONLY applicable to transistors
*/ */
void TechnologyLibrary::set_transistor_model_chan_length(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_transistor_model_chan_length(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const float& chan_length) { const float& chan_length) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
transistor_model_chan_lengths_[device_id][transistor_type] = chan_length; transistor_model_chan_lengths_[model_id][transistor_type] = chan_length;
return; return;
} }
/* Set the minimum width for either PMOS or NMOS of a device in the library /* Set the minimum width for either PMOS or NMOS of a model in the library
* This is ONLY applicable to transistors * This is ONLY applicable to transistors
*/ */
void TechnologyLibrary::set_transistor_model_min_width(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_transistor_model_min_width(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const float& min_width) { const float& min_width) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
transistor_model_min_widths_[device_id][transistor_type] = min_width; transistor_model_min_widths_[model_id][transistor_type] = min_width;
return; return;
} }
/* Set the variation name for either PMOS or NMOS of a device in the library /* Set the variation name for either PMOS or NMOS of a model in the library
* This is ONLY applicable to transistors * This is ONLY applicable to transistors
*/ */
void TechnologyLibrary::set_transistor_model_variation_name(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_transistor_model_variation_name(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const std::string& variation_name) { const std::string& variation_name) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_TRANSISTOR == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_TRANSISTOR == model_type(model_id));
transistor_model_variation_names_[device_id][transistor_type] = variation_name; transistor_model_variation_names_[model_id][transistor_type] = variation_name;
return; return;
} }
/************************************************************************ /************************************************************************
* Public Mutators: RRAM-related * Public Mutators: RRAM-related
***********************************************************************/ ***********************************************************************/
/* Set the Low Resistance State (LRS) resistance for a RRAM device in the library /* Set the Low Resistance State (LRS) resistance for a RRAM model in the library
* This is ONLY applicable to RRAM devices * This is ONLY applicable to RRAM models
*/ */
void TechnologyLibrary::set_rram_rlrs(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_rram_rlrs(const TechnologyModelId& model_id,
const float& rlrs) { const float& rlrs) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model_id));
rram_resistances_[device_id].set_x(rlrs); rram_resistances_[model_id].set_x(rlrs);
return; return;
} }
/* Set the High Resistance State (HRS) resistance for a RRAM device in the library /* Set the High Resistance State (HRS) resistance for a RRAM model in the library
* This is ONLY applicable to RRAM devices * This is ONLY applicable to RRAM models
*/ */
void TechnologyLibrary::set_rram_rhrs(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_rram_rhrs(const TechnologyModelId& model_id,
const float& rhrs) { const float& rhrs) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model_id));
rram_resistances_[device_id].set_y(rhrs); rram_resistances_[model_id].set_y(rhrs);
return; return;
} }
/* Set the variation name for a RRAM device in the library /* Set the variation name for a RRAM model in the library
* This is ONLY applicable to RRAM devices * This is ONLY applicable to RRAM models
*/ */
void TechnologyLibrary::set_rram_variation_name(const TechnologyDeviceId& device_id, void TechnologyLibrary::set_rram_variation_name(const TechnologyModelId& model_id,
const std::string& variation_name) { const std::string& variation_name) {
/* validate the device_id */ /* validate the model_id */
VTR_ASSERT(valid_device_id(device_id)); VTR_ASSERT(valid_model_id(model_id));
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device_id)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model_id));
rram_variation_names_[device_id] = variation_name; rram_variation_names_[model_id] = variation_name;
return; return;
} }
@ -490,31 +490,31 @@ void TechnologyLibrary::set_variation_num_sigma(const TechnologyVariationId& var
/************************************************************************ /************************************************************************
* Public mutators: linkers * Public mutators: linkers
***********************************************************************/ ***********************************************************************/
/* This function builds the links between devices and variations, /* This function builds the links between models and variations,
* which have been defined in the technology library * which have been defined in the technology library
*/ */
void TechnologyLibrary::link_devices_to_variations() { void TechnologyLibrary::link_models_to_variations() {
for (const TechnologyDeviceId& device : devices()) { for (const TechnologyModelId& model : models()) {
/* For transistors, find the variation name for each model and build a link */ /* For transistors, find the variation name for each model and build a link */
if (TECH_LIB_DEVICE_TRANSISTOR == device_type(device)) { if (TECH_LIB_MODEL_TRANSISTOR == model_type(model)) {
/* PMOS transistor, if a variation name is specified, we try to build a link /* PMOS transistor, if a variation name is specified, we try to build a link
* Otherwise, we assign any invalid id */ * Otherwise, we assign any invalid id */
const std::string& pmos_var_name = transistor_model_variation_names_[device][TECH_LIB_TRANSISTOR_PMOS]; const std::string& pmos_var_name = transistor_model_variation_names_[model][TECH_LIB_TRANSISTOR_PMOS];
transistor_model_variation_ids_[device][TECH_LIB_TRANSISTOR_PMOS] = variation(pmos_var_name); transistor_model_variation_ids_[model][TECH_LIB_TRANSISTOR_PMOS] = variation(pmos_var_name);
/* NMOS transistor, if a variation name is specified, we try to build a link /* NMOS transistor, if a variation name is specified, we try to build a link
* Otherwise, we assign any invalid id * Otherwise, we assign any invalid id
*/ */
const std::string& nmos_var_name = transistor_model_variation_names_[device][TECH_LIB_TRANSISTOR_NMOS]; const std::string& nmos_var_name = transistor_model_variation_names_[model][TECH_LIB_TRANSISTOR_NMOS];
transistor_model_variation_ids_[device][TECH_LIB_TRANSISTOR_NMOS] = variation(nmos_var_name); transistor_model_variation_ids_[model][TECH_LIB_TRANSISTOR_NMOS] = variation(nmos_var_name);
/* Finish for transistors, go to the next */ /* Finish for transistors, go to the next */
continue; continue;
} }
/* Reach here it means an RRAM device, we find the variation name and try to build a link */ /* Reach here it means an RRAM model, we find the variation name and try to build a link */
VTR_ASSERT(TECH_LIB_DEVICE_RRAM == device_type(device)); VTR_ASSERT(TECH_LIB_MODEL_RRAM == model_type(model));
const std::string& rram_var_name = rram_variation_names_[device]; const std::string& rram_var_name = rram_variation_names_[model];
rram_variation_ids_[device] = variation(rram_var_name); rram_variation_ids_[model] = variation(rram_var_name);
/* Finish for RRAMs, go to the next */ /* Finish for RRAMs, go to the next */
} }
} }
@ -523,8 +523,8 @@ void TechnologyLibrary::link_devices_to_variations() {
* Internal invalidators/validators * Internal invalidators/validators
***********************************************************************/ ***********************************************************************/
/* Validators */ /* Validators */
bool TechnologyLibrary::valid_device_id(const TechnologyDeviceId& device_id) const { bool TechnologyLibrary::valid_model_id(const TechnologyModelId& model_id) const {
return ( size_t(device_id) < device_ids_.size() ) && ( device_id == device_ids_[device_id] ); return ( size_t(model_id) < model_ids_.size() ) && ( model_id == model_ids_[model_id] );
} }
bool TechnologyLibrary::valid_variation_id(const TechnologyVariationId& variation_id) const { bool TechnologyLibrary::valid_variation_id(const TechnologyVariationId& variation_id) const {

View File

@ -25,33 +25,33 @@
* PTM is the Predictive Technology Model provided by the Arizona * PTM is the Predictive Technology Model provided by the Arizona
* State University (ASU). Available at ptm.asu.edu * State University (ASU). Available at ptm.asu.edu
*******************************************************************/ *******************************************************************/
enum e_tech_lib_model_type { enum e_tech_lib_type {
TECH_LIB_MODEL_INDUSTRY, TECH_LIB_MODEL_INDUSTRY,
TECH_LIB_MODEL_ACADEMIA, TECH_LIB_MODEL_ACADEMIA,
NUM_TECH_LIB_MODEL_TYPES NUM_TECH_LIB_TYPES
}; };
/* Strings correspond to each technology library type */ /* Strings correspond to each technology library type */
constexpr std::array<const char*, NUM_TECH_LIB_MODEL_TYPES> TECH_LIB_MODEL_TYPE_STRING = {{"industry", "academia"}}; constexpr std::array<const char*, NUM_TECH_LIB_TYPES> TECH_LIB_TYPE_STRING = {{"industry", "academia"}};
/******************************************************************** /********************************************************************
* Types of device which may be defined in a technology library * Types of model which may be defined in a technology library
* 1. transistor * 1. transistor
* 2. RRAM * 2. RRAM
*******************************************************************/ *******************************************************************/
enum e_tech_lib_device_type { enum e_tech_lib_model_type {
TECH_LIB_DEVICE_TRANSISTOR, TECH_LIB_MODEL_TRANSISTOR,
TECH_LIB_DEVICE_RRAM, TECH_LIB_MODEL_RRAM,
NUM_TECH_LIB_DEVICE_TYPES NUM_TECH_LIB_MODEL_TYPES
}; };
/* Strings correspond to transistor type */ /* Strings correspond to transistor type */
constexpr std::array<const char*, NUM_TECH_LIB_DEVICE_TYPES> TECH_LIB_DEVICE_TYPE_STRING = {{"transistor", "rram"}}; constexpr std::array<const char*, NUM_TECH_LIB_MODEL_TYPES> TECH_LIB_MODEL_TYPE_STRING = {{"transistor", "rram"}};
/******************************************************************** /********************************************************************
* Types of transistors which may be defined in a technology library * Types of transistors which may be defined in a technology library
* 1. NMOS transistor * 1. NMOS transistor
* 2. PMOS transistor * 2. PMOS transistor
*******************************************************************/ *******************************************************************/
enum e_tech_lib_trans_type { enum e_tech_lib_transistor_type {
TECH_LIB_TRANSISTOR_PMOS, TECH_LIB_TRANSISTOR_PMOS,
TECH_LIB_TRANSISTOR_NMOS, TECH_LIB_TRANSISTOR_NMOS,
NUM_TECH_LIB_TRANSISTOR_TYPES NUM_TECH_LIB_TRANSISTOR_TYPES
@ -59,18 +59,6 @@ enum e_tech_lib_trans_type {
/* Strings correspond to transistor type */ /* Strings correspond to transistor type */
constexpr std::array<const char*, NUM_TECH_LIB_TRANSISTOR_TYPES> TECH_LIB_TRANSISTOR_TYPE_STRING = {{"pmos", "nmos"}}; constexpr std::array<const char*, NUM_TECH_LIB_TRANSISTOR_TYPES> TECH_LIB_TRANSISTOR_TYPE_STRING = {{"pmos", "nmos"}};
/********************************************************************
* Process corners supported
*******************************************************************/
enum e_process_corner {
TECH_LIB_CORNER_FF,
TECH_LIB_CORNER_TT,
TECH_LIB_CORNER_SS,
NUM_TECH_LIB_CORNER_TYPES
};
/* Strings correspond to process corner type */
constexpr std::array<const char*, NUM_TECH_LIB_CORNER_TYPES> TECH_LIB_CORNER_TYPE_STRING = {{"FF", "TT", "SS"}};
/******************************************************************** /********************************************************************
* A data structure to describe technology library * A data structure to describe technology library
* *
@ -80,146 +68,146 @@ constexpr std::array<const char*, NUM_TECH_LIB_CORNER_TYPES> TECH_LIB_CORNER_TYP
* TechnologyLibrary tech_lib; * TechnologyLibrary tech_lib;
* // call your builder for technology library * // call your builder for technology library
* // Build the internal links for the technology library * // Build the internal links for the technology library
* tech_lib.link_device_to_variation(); * tech_lib.link_model_to_variation();
* *
*******************************************************************/ *******************************************************************/
class TechnologyLibrary { class TechnologyLibrary {
public: /* Types */ public: /* Types */
typedef vtr::vector<TechnologyDeviceId, TechnologyDeviceId>::const_iterator technology_device_iterator; typedef vtr::vector<TechnologyModelId, TechnologyModelId>::const_iterator technology_model_iterator;
typedef vtr::vector<TechnologyVariationId, TechnologyVariationId>::const_iterator technology_variation_iterator; typedef vtr::vector<TechnologyVariationId, TechnologyVariationId>::const_iterator technology_variation_iterator;
/* Create range */ /* Create range */
typedef vtr::Range<technology_device_iterator> technology_device_range; typedef vtr::Range<technology_model_iterator> technology_model_range;
typedef vtr::Range<technology_variation_iterator> technology_variation_range; typedef vtr::Range<technology_variation_iterator> technology_variation_range;
public: /* Constructors */ public: /* Constructors */
TechnologyLibrary(); TechnologyLibrary();
public: /* Accessors: aggregates */ public: /* Accessors: aggregates */
technology_device_range devices() const; technology_model_range models() const;
technology_variation_range variations() const; technology_variation_range variations() const;
std::vector<TechnologyDeviceId> devices_by_type(const enum e_tech_lib_device_type& type) const; std::vector<TechnologyModelId> models_by_type(const enum e_tech_lib_model_type& type) const;
public: /* Public Accessors: Basic data query on devices */ public: /* Public Accessors: Basic data query on models */
std::string device_name(const TechnologyDeviceId& device_id) const; std::string model_name(const TechnologyModelId& model_id) const;
TechnologyDeviceId device(const std::string& name) const; TechnologyModelId model(const std::string& name) const;
enum e_tech_lib_device_type device_type(const TechnologyDeviceId& device_id) const; enum e_tech_lib_model_type model_type(const TechnologyModelId& model_id) const;
enum e_tech_lib_model_type device_model_type(const TechnologyDeviceId& device_id) const; enum e_tech_lib_type model_lib_type(const TechnologyModelId& model_id) const;
std::string device_corner(const TechnologyDeviceId& device_id) const; std::string model_corner(const TechnologyModelId& model_id) const;
std::string device_model_ref(const TechnologyDeviceId& device_id) const; std::string model_ref(const TechnologyModelId& model_id) const;
std::string device_lib_path(const TechnologyDeviceId& device_id) const; std::string model_lib_path(const TechnologyModelId& model_id) const;
float device_vdd(const TechnologyDeviceId& device_id) const; float model_vdd(const TechnologyModelId& model_id) const;
float device_pn_ratio(const TechnologyDeviceId& device_id) const; float model_pn_ratio(const TechnologyModelId& model_id) const;
public: /* Public Accessors: Basic data query on transistors */ public: /* Public Accessors: Basic data query on transistors */
std::string transistor_model_name(const TechnologyDeviceId& device_id, std::string transistor_model_name(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const; const e_tech_lib_transistor_type& transistor_type) const;
float transistor_model_chan_length(const TechnologyDeviceId& device_id, float transistor_model_chan_length(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const; const e_tech_lib_transistor_type& transistor_type) const;
float transistor_model_min_width(const TechnologyDeviceId& device_id, float transistor_model_min_width(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const; const e_tech_lib_transistor_type& transistor_type) const;
TechnologyVariationId transistor_model_variation(const TechnologyDeviceId& device_id, TechnologyVariationId transistor_model_variation(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type) const; const e_tech_lib_transistor_type& transistor_type) const;
public: /* Public Accessors: Basic data query on RRAM devices */ public: /* Public Accessors: Basic data query on RRAM models */
float rram_rlrs(const TechnologyDeviceId& device_id) const; float rram_rlrs(const TechnologyModelId& model_id) const;
float rram_rhrs(const TechnologyDeviceId& device_id) const; float rram_rhrs(const TechnologyModelId& model_id) const;
TechnologyVariationId rram_variation(const TechnologyDeviceId& device_id) const; TechnologyVariationId rram_variation(const TechnologyModelId& model_id) const;
public: /* Public Accessors: Basic data query on variations */ public: /* Public Accessors: Basic data query on variations */
std::string variation_name(const TechnologyVariationId& variation_id) const; std::string variation_name(const TechnologyVariationId& variation_id) const;
TechnologyVariationId variation(const std::string& name) const; TechnologyVariationId variation(const std::string& name) const;
float variation_abs_value(const TechnologyVariationId& variation_id) const; float variation_abs_value(const TechnologyVariationId& variation_id) const;
size_t variation_num_sigma(const TechnologyVariationId& variation_id) const; size_t variation_num_sigma(const TechnologyVariationId& variation_id) const;
public: /* Public Mutators: device-related */ public: /* Public Mutators: model-related */
TechnologyDeviceId add_device(const std::string& name); TechnologyModelId add_model(const std::string& name);
void set_device_type(const TechnologyDeviceId& device_id, void set_model_type(const TechnologyModelId& model_id,
const e_tech_lib_device_type& type); const e_tech_lib_model_type& type);
void set_device_model_type(const TechnologyDeviceId& device_id, void set_model_lib_type(const TechnologyModelId& model_id,
const e_tech_lib_model_type& model_type); const e_tech_lib_type& lib_type);
void set_device_corner(const TechnologyDeviceId& device_id, void set_model_corner(const TechnologyModelId& model_id,
const std::string& corner); const std::string& corner);
void set_device_model_ref(const TechnologyDeviceId& device_id, void set_model_ref(const TechnologyModelId& model_id,
const std::string& model_ref); const std::string& model_ref);
void set_device_lib_path(const TechnologyDeviceId& device_id, void set_model_lib_path(const TechnologyModelId& model_id,
const std::string& lib_path); const std::string& lib_path);
void set_device_vdd(const TechnologyDeviceId& device_id, void set_model_vdd(const TechnologyModelId& model_id,
const float& vdd); const float& vdd);
void set_device_pn_ratio(const TechnologyDeviceId& device_id, void set_model_pn_ratio(const TechnologyModelId& model_id,
const float& pn_ratio); const float& pn_ratio);
public: /* Public Mutators: transistor-related */ public: /* Public Mutators: transistor-related */
void set_transistor_model_name(const TechnologyDeviceId& device_id, void set_transistor_model_name(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const std::string& model_name); const std::string& model_name);
void set_transistor_model_chan_length(const TechnologyDeviceId& device_id, void set_transistor_model_chan_length(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const float& chan_length); const float& chan_length);
void set_transistor_model_min_width(const TechnologyDeviceId& device_id, void set_transistor_model_min_width(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const float& min_width); const float& min_width);
void set_transistor_model_variation_name(const TechnologyDeviceId& device_id, void set_transistor_model_variation_name(const TechnologyModelId& model_id,
const e_tech_lib_trans_type& transistor_type, const e_tech_lib_transistor_type& transistor_type,
const std::string& variation_name); const std::string& variation_name);
public: /* Public Mutators: RRAM-related */ public: /* Public Mutators: RRAM-related */
void set_rram_rlrs(const TechnologyDeviceId& device_id, void set_rram_rlrs(const TechnologyModelId& model_id,
const float& rlrs); const float& rlrs);
void set_rram_rhrs(const TechnologyDeviceId& device_id, void set_rram_rhrs(const TechnologyModelId& model_id,
const float& rhrs); const float& rhrs);
void set_rram_variation_name(const TechnologyDeviceId& device_id, void set_rram_variation_name(const TechnologyModelId& model_id,
const std::string& variation_name); const std::string& variation_name);
public: /* Public Mutators: variation-related */ public: /* Public Mutators: variation-related */
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 */ public: /* Public Mutators: linkers */
void link_devices_to_variations(); void link_models_to_variations();
public: /* Public invalidators/validators */ public: /* Public invalidators/validators */
bool valid_device_id(const TechnologyDeviceId& device_id) const; bool valid_model_id(const TechnologyModelId& model_id) const;
bool valid_variation_id(const TechnologyVariationId& variation_id) const; bool valid_variation_id(const TechnologyVariationId& variation_id) const;
private: /* Internal data */ private: /* Internal data */
/* Transistor-related fundamental information */ /* Transistor-related fundamental information */
/* Unique identifier for each device /* Unique identifier for each model
* A device could be either transistors (1 pair of PMOS and NMOS) or RRAMs * A model could be either transistors (1 pair of PMOS and NMOS) or RRAMs
*/ */
vtr::vector<TechnologyDeviceId, TechnologyDeviceId> device_ids_; vtr::vector<TechnologyModelId, TechnologyModelId> model_ids_;
/* Unique name for each device. This is defined by XML file */ /* Unique name for each model. This is defined by XML file */
vtr::vector<TechnologyDeviceId, std::string> device_names_; vtr::vector<TechnologyModelId, std::string> model_names_;
/* Type of each device, either transistors or RRAMs */ /* Type of each model, either transistors or RRAMs */
vtr::vector<TechnologyDeviceId, e_tech_lib_device_type> device_types_; vtr::vector<TechnologyModelId, e_tech_lib_model_type> model_types_;
/* Type of models of each device, either industry or academia /* Type of models of each model, either industry or academia
* This will lead to different ways when include these models * This will lead to different ways when include these models
* For industry models, we use .lib to include library * For industry models, we use .lib to include library
* For academia models, we use .include to include library * For academia models, we use .include to include library
*/ */
vtr::vector<TechnologyDeviceId, e_tech_lib_model_type> device_model_types_; vtr::vector<TechnologyModelId, e_tech_lib_type> model_lib_types_;
/* Name of process corner to be used for each device /* Name of process corner to be used for each model
* Users can define any string for the process corner they are going to use * Users can define any string for the process corner they are going to use
* But the corner name should be consistent with their library files * But the corner name should be consistent with their library files
* When this is enabled, the corner name will be added when * When this is enabled, the corner name will be added when
* include the models * include the models
* For example, for a industry model, .lib <lib_path> <corner_name> * For example, for a industry model, .lib <lib_path> <corner_name>
*/ */
vtr::vector<TechnologyDeviceId, std::string> device_corners_; vtr::vector<TechnologyModelId, std::string> model_corners_;
/* The string used to instanciate the device models /* The string used to instanciate the model models
* This will really depend on the type of models * This will really depend on the type of models
* For most industry models, we can use 'M' to instanciate a transisitor * For most industry models, we can use 'M' to instanciate a transisitor
* For some academia models, we have to use 'X' to do so * For some academia models, we have to use 'X' to do so
*/ */
vtr::vector<TechnologyDeviceId, std::string> device_model_refs_; vtr::vector<TechnologyModelId, std::string> model_refs_;
/* The path to the transistor models /* The path to the transistor models
* This is going to be the <lib_path> when include the library files * This is going to be the <lib_path> when include the library files
* See the example in the comments about process corner * See the example in the comments about process corner
*/ */
vtr::vector<TechnologyDeviceId, std::string> device_lib_paths_; vtr::vector<TechnologyModelId, std::string> model_lib_paths_;
/* Operating voltage for the devices. Unit: [V] */ /* Operating voltage for the models. Unit: [V] */
vtr::vector<TechnologyDeviceId, float> device_vdds_; vtr::vector<TechnologyModelId, float> model_vdds_;
/* The width ratio between PMOS and NMOS for a device group /* The width ratio between PMOS and NMOS for a model group
* This really depend the transistor technology * This really depend the transistor technology
* We recommend users to characterize driving strengths of * We recommend users to characterize driving strengths of
* PMOS and NMOS using SPICE simulators * PMOS and NMOS using SPICE simulators
*/ */
vtr::vector<TechnologyDeviceId, float> device_pn_ratios_; vtr::vector<TechnologyModelId, float> model_pn_ratios_;
/* The model name is the name that is defined in your library file. /* The model name is the name that is defined in your library file.
* For example, your NMOS transistor may be defined as * For example, your NMOS transistor may be defined as
@ -230,38 +218,39 @@ class TechnologyLibrary {
* PMOS data will be stored in the first element of the array * PMOS data will be stored in the first element of the array
* NMOS data will be stored in the second element of the array * NMOS data will be stored in the second element of the array
*/ */
vtr::vector<TechnologyDeviceId, std::array<std::string, 2>> transistor_model_names_; vtr::vector<TechnologyModelId, std::array<std::string, 2>> transistor_model_names_;
/* The channel length of a transistor. /* The channel length of a transistor.
* This should be defined by your technology vendor * This should be defined by your technology vendor
* For example, a 22nm technology, the channel length is around 22nm * For example, a 22nm technology, the channel length is around 22nm
*/ */
vtr::vector<TechnologyDeviceId, std::array<float, 2>> transistor_model_chan_lengths_; vtr::vector<TechnologyModelId, std::array<float, 2>> transistor_model_chan_lengths_;
/* The minimum width of a transistor. /* The minimum width of a transistor.
* This should be defined by your technology vendor * This should be defined by your technology vendor
*/ */
vtr::vector<TechnologyDeviceId, std::array<float, 2>> transistor_model_min_widths_; vtr::vector<TechnologyModelId, std::array<float, 2>> transistor_model_min_widths_;
/* The variation name and id binded to PMOS and NMOS transistor /* The variation name and id binded to PMOS and NMOS transistor
* We expect users to provide the exact name of variation defined in this technology library * We expect users to provide the exact name of variation defined in this technology library
* the name and id will be automatically matched by using function link_device_to_variation() * the name and id will be automatically matched by using function link_model_to_variation()
*/ */
vtr::vector<TechnologyDeviceId, std::array<std::string, 2>> transistor_model_variation_names_; vtr::vector<TechnologyModelId, std::array<std::string, 2>> transistor_model_variation_names_;
vtr::vector<TechnologyDeviceId, std::array<TechnologyVariationId, 2>> transistor_model_variation_ids_; vtr::vector<TechnologyModelId, std::array<TechnologyVariationId, 2>> transistor_model_variation_ids_;
/* ReRAM-related fundamental information: /* ReRAM-related fundamental information:
* Low Resistance State (LRS) resistance will be stored in the x() part of vtr::Point * Low Resistance State (LRS) resistance will be stored in the x() part of vtr::Point
* High Resistance State (HRS) resistance will be stored in the y() part of vtr::Point * High Resistance State (HRS) resistance will be stored in the y() part of vtr::Point
* Unit: [Ohm]
*/ */
vtr::vector<TechnologyDeviceId, vtr::Point<float>> rram_resistances_; vtr::vector<TechnologyModelId, vtr::Point<float>> rram_resistances_;
/* The variation name and id binded to this RRAM /* The variation name and id binded to this RRAM
* We expect users to provide the exact name of variation defined in this technology library * We expect users to provide the exact name of variation defined in this technology library
* the name and id will be automatically matched by using function link_device_to_variation() * the name and id will be automatically matched by using function link_model_to_variation()
*/ */
vtr::vector<TechnologyDeviceId, std::string> rram_variation_names_; vtr::vector<TechnologyModelId, std::string> rram_variation_names_;
vtr::vector<TechnologyDeviceId, TechnologyVariationId> rram_variation_ids_; vtr::vector<TechnologyModelId, TechnologyVariationId> rram_variation_ids_;
/* Unique identifier for each process variation */ /* Unique identifier for each process variation */
vtr::vector<TechnologyVariationId, TechnologyVariationId> variation_ids_; vtr::vector<TechnologyVariationId, TechnologyVariationId> variation_ids_;
@ -275,7 +264,7 @@ class TechnologyLibrary {
vtr::vector<TechnologyVariationId, size_t> variation_num_sigmas_; vtr::vector<TechnologyVariationId, size_t> variation_num_sigmas_;
/* Fast name-to-id lookup */ /* Fast name-to-id lookup */
std::map<std::string, TechnologyDeviceId> device_name2ids_; std::map<std::string, TechnologyModelId> model_name2ids_;
std::map<std::string, TechnologyVariationId> variation_name2ids_; std::map<std::string, TechnologyVariationId> variation_name2ids_;
}; };

View File

@ -12,10 +12,10 @@
#include "vtr_strong_id.h" #include "vtr_strong_id.h"
struct technology_device_id_tag; struct technology_model_id_tag;
struct technology_variation_id_tag; struct technology_variation_id_tag;
typedef vtr::StrongId<technology_device_id_tag> TechnologyDeviceId; typedef vtr::StrongId<technology_model_id_tag> TechnologyModelId;
typedef vtr::StrongId<technology_variation_id_tag> TechnologyVariationId; typedef vtr::StrongId<technology_variation_id_tag> TechnologyVariationId;
/* Short declaration of class */ /* Short declaration of class */