HAL
netlist_internal_manager.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"
31 
32 #include <map>
33 #include <vector>
34 
35 namespace hal
36 {
37  // forward declaration
38  class Netlist;
39  class Gate;
40  class GateType;
41  class Net;
42  class Module;
43  class Endpoint;
44  class Grouping;
45  class BooleanFunction;
46 
51  {
52  friend class Netlist;
53  friend class Module;
54  friend class Net;
55  friend class Gate;
56  friend class Grouping;
57 
58  private:
59  Netlist* m_netlist;
60  EventHandler* m_event_handler;
61 
62  explicit NetlistInternalManager(Netlist* nl, EventHandler* eh);
63  ~NetlistInternalManager() = default;
64 
65  // netlist functions
67 
68  // gate functions
69  Gate* create_gate(u32 id, GateType* gt, const std::string& name, i32 x, i32 y);
70  bool delete_gate(Gate* gate);
71  bool is_gate_type_invalid(GateType* gt) const;
72 
73  // net functions
74  Net* create_net(u32 id, const std::string& name);
75  bool delete_net(Net* net);
76  Endpoint* net_add_source(Net* net, Gate* gate, GatePin* pin);
77  bool net_remove_source(Net* net, Endpoint* ep);
78  Endpoint* net_add_destination(Net* net, Gate* gate, GatePin* pin);
79  bool net_remove_destination(Net* net, Endpoint* ep);
80 
81  // module functions
82  Module* create_module(u32 id, Module* parent, const std::string& name);
83  bool delete_module(Module* module);
84  bool module_assign_gate(Module* m, Gate* g);
85  bool module_assign_gates(Module* module, const std::vector<Gate*>& gates);
86  bool module_check_net(Module* module, Net* net, bool recursive = false);
87 
88  // grouping functions
89  Grouping* create_grouping(u32 id, const std::string name);
90  bool delete_grouping(Grouping* grouping);
91  bool grouping_assign_gate(Grouping* grouping, Gate* gate, bool force = false);
92  bool grouping_remove_gate(Grouping* grouping, Gate* gate);
93  bool grouping_assign_net(Grouping* grouping, Net* net, bool force = false);
94  bool grouping_remove_net(Grouping* grouping, Net* net);
95  bool grouping_assign_module(Grouping* grouping, Module* module, bool force = false);
96  bool grouping_remove_module(Grouping* grouping, Module* module);
97 
98  // caches
99  void clear_caches();
100  mutable std::map<std::pair<std::vector<GatePin*>, u64>, BooleanFunction> m_lut_function_cache;
101  bool m_net_checks_enabled = true;
102  };
103 } // namespace hal
#define NETLIST_API
Definition: arch_linux.h:30
Definition: gate.h:58
Definition: net.h:58
uint64_t u64
Definition: defines.h:42
int32_t i32
Definition: defines.h:36
const Module * module(const Gate *g, const NodeBoxes &boxes)
std::unique_ptr< Netlist > copy_netlist(const Netlist *nl)
quint32 u32
Net * net
std::string name