HAL
gate_library.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include "hal_core/defines.h"
30 
31 #include <map>
32 #include <set>
33 #include <string>
34 #include <vector>
35 
36 namespace hal
37 {
44  {
45  public:
52  GateLibrary(const std::filesystem::path& path, const std::string& name);
53  ~GateLibrary() = default;
54 
60  std::string get_name() const;
61 
67  std::filesystem::path get_path() const;
68 
75  void set_path(const std::filesystem::path& modified_path);
76 
83  void set_name(const std::string& modified_name);
84 
90  void set_gate_location_data_category(const std::string& category);
91 
97  const std::string& get_gate_location_data_category() const;
104  void set_gate_location_data_identifiers(const std::string& x_coordinate, const std::string& y_coordinate);
105 
111  const std::pair<std::string, std::string>& get_gate_location_data_identifiers() const;
112 
122  GateType* create_gate_type(const std::string& name, std::set<GateTypeProperty> properties = {GateTypeProperty::combinational}, std::unique_ptr<GateTypeComponent> component = nullptr);
123 
134  GateType* replace_gate_type(u32 id, const std::string& name, std::set<GateTypeProperty> properties = {GateTypeProperty::combinational}, std::unique_ptr<GateTypeComponent> component = nullptr);
135 
142  bool contains_gate_type(GateType* gate_type) const;
143 
150  bool contains_gate_type_by_name(const std::string& name) const;
151 
158  GateType* get_gate_type_by_name(const std::string& name) const;
159 
167  std::unordered_map<std::string, GateType*> get_gate_types(const std::function<bool(const GateType*)>& filter = nullptr) const;
168 
175  bool mark_vcc_gate_type(GateType* gate_type);
176 
182  std::unordered_map<std::string, GateType*> get_vcc_gate_types() const;
183 
190  bool mark_gnd_gate_type(GateType* gate_type);
191 
197  std::unordered_map<std::string, GateType*> get_gnd_gate_types() const;
198 
204  void add_include(const std::string& inc);
205 
211  std::vector<std::string> get_includes() const;
212 
213  void remove_gate_type(const std::string& name);
214 
215  private:
216  std::string m_name;
217  std::filesystem::path m_path;
218 
219  std::string m_gate_location_data_category = "generic";
220  std::pair<std::string, std::string> m_gate_location_data_identifiers = {"X_COORDINATE", "Y_COORDINATE"};
221 
222  u32 m_next_gate_type_id;
223 
224  std::vector<std::unique_ptr<GateType>> m_gate_types;
225  std::unordered_map<std::string, GateType*> m_gate_type_map;
226  std::unordered_map<std::string, GateType*> m_vcc_gate_types;
227  std::unordered_map<std::string, GateType*> m_gnd_gate_types;
228 
229  std::vector<std::string> m_includes;
230 
231  GateLibrary(const GateLibrary&) = delete;
232  GateLibrary& operator=(const GateLibrary&) = delete;
233 
234  u32 get_unique_gate_type_id();
235  };
236 } // namespace hal
#define NETLIST_API
Definition: arch_linux.h:30
~GateLibrary()=default
std::vector< Gate * > get_path(const Gate *gate, bool get_successors, std::set< GateTypeProperty > stop_properties, std::unordered_map< u32, std::vector< Gate * >> &cache)
quint32 u32
std::string name