10 m_next_gate_type_id = 1;
25 m_path = modified_path;
30 m_name = modified_name;
35 m_gate_location_data_category = category;
40 return m_gate_location_data_category;
45 m_gate_location_data_identifiers = std::make_pair(x_coordinate, y_coordinate);
50 return m_gate_location_data_identifiers;
55 if (m_gate_type_map.find(
name) != m_gate_type_map.end())
57 log_error(
"gate_library",
"could not create gate type with name '{}' as a gate type with the same name already exists within gate library '{}'.",
name, m_name);
61 std::unique_ptr<GateType> gt = std::unique_ptr<GateType>(
new GateType(
this, get_unique_gate_type_id(),
name, properties, std::move(component)));
64 m_gate_type_map.emplace(
name, res);
65 m_gate_types.push_back(std::move(gt));
72 auto it = m_gate_type_map.find(
name);
73 if (it != m_gate_type_map.end() && it->second->get_id() !=
id)
75 log_error(
"gate_library",
"could not replace gate type ID={} since new name '{}' exists already within gate library '{}'.",
id,
name, m_name);
79 auto jt = m_gate_types.begin();
80 while (jt != m_gate_types.end())
82 if (jt->get()->get_id() ==
id)
break;
85 if (jt == m_gate_types.end())
87 log_error(
"gate_library",
"could not replace gate type ID={}, no gate with this ID found within gate library",
id, m_name);
90 auto nt = m_gate_type_map.find(jt->get()->get_name());
91 if (nt != m_gate_type_map.end())
92 m_gate_type_map.erase(nt);
93 m_gate_types.erase(jt);
95 std::unique_ptr<GateType> gt = std::unique_ptr<GateType>(
new GateType(
this,
id,
name, properties, std::move(component)));
98 m_gate_type_map.emplace(
name, res);
99 m_gate_types.push_back(std::move(gt));
105 if (gate_type ==
nullptr)
110 auto it = m_gate_type_map.find(gate_type->
get_name());
111 if (it == m_gate_type_map.end())
115 return *(it->second) == *gate_type;
120 if (
auto it = m_gate_type_map.find(
name); it != m_gate_type_map.end())
130 if (
auto it = m_gate_type_map.find(
name); it != m_gate_type_map.end())
135 log_error(
"gate_library",
"could not find the specified gate type, as there exists no gate type called '{}' within gate library '{}'.",
name, m_name);
143 std::unordered_map<std::string, GateType*> res;
144 for (
const auto&
type : m_gate_types)
146 if (filter(
type.get()))
154 return m_gate_type_map;
161 if (gate_type->
get_input_pins().empty() && (out_pins.size() == 1))
164 if (!bf.is_empty() && bf.has_constant_value(1))
166 m_vcc_gate_types.emplace(gate_type->
get_name(), gate_type);
176 return m_vcc_gate_types;
183 if (gate_type->
get_input_pins().empty() && (out_pins.size() == 1))
186 if (!bf.is_empty() && bf.has_constant_value(0))
188 m_gnd_gate_types.emplace(gate_type->
get_name(), gate_type);
198 return m_gnd_gate_types;
208 m_includes.push_back(inc);
211 u32 GateLibrary::get_unique_gate_type_id()
213 return m_next_gate_type_id++;
218 if (m_gate_type_map.find(
name) == m_gate_type_map.end())
220 log_error(
"gate_library",
"could not remove gate type with name '{}' as a gate type with this name does not exist within gate library '{}'.",
name, m_name);
224 auto it = m_gate_type_map.find(
name);
225 m_gate_type_map.erase(it);
bool contains_gate_type_by_name(const std::string &name) const
GateType * replace_gate_type(u32 id, const std::string &name, std::set< GateTypeProperty > properties={GateTypeProperty::combinational}, std::unique_ptr< GateTypeComponent > component=nullptr)
std::filesystem::path get_path() const
const std::pair< std::string, std::string > & get_gate_location_data_identifiers() const
bool mark_vcc_gate_type(GateType *gate_type)
void remove_gate_type(const std::string &name)
std::unordered_map< std::string, GateType * > get_gate_types(const std::function< bool(const GateType *)> &filter=nullptr) const
std::unordered_map< std::string, GateType * > get_vcc_gate_types() const
GateType * get_gate_type_by_name(const std::string &name) const
void set_path(const std::filesystem::path &modified_path)
GateLibrary(const std::filesystem::path &path, const std::string &name)
void set_name(const std::string &modified_name)
void set_gate_location_data_category(const std::string &category)
bool mark_gnd_gate_type(GateType *gate_type)
bool contains_gate_type(GateType *gate_type) const
void add_include(const std::string &inc)
std::vector< std::string > get_includes() const
void set_gate_location_data_identifiers(const std::string &x_coordinate, const std::string &y_coordinate)
GateType * create_gate_type(const std::string &name, std::set< GateTypeProperty > properties={GateTypeProperty::combinational}, std::unique_ptr< GateTypeComponent > component=nullptr)
std::unordered_map< std::string, GateType * > get_gnd_gate_types() const
std::string get_name() const
const std::string & get_gate_location_data_category() const
std::vector< GatePin * > get_output_pins() const
const std::string & get_name() const
std::vector< GatePin * > get_input_pins() const
BooleanFunction get_boolean_function(const std::string &name) const
#define log_error(channel,...)