HAL
netlist_traversal_decorator.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 <optional>
33 
34 namespace hal
35 {
42  {
43  public:
50 
66  bool successors,
67  const std::function<bool(const Gate*)>& target_gate_filter,
68  bool continue_on_match = false,
69  const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
70  const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
71 
87  bool successors,
88  const std::function<bool(const Gate*)>& target_gate_filter,
89  bool continue_on_match = false,
90  const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
91  const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
92 
108  bool successors,
109  const std::function<bool(const Gate*)>& target_gate_filter,
110  bool continue_on_mismatch = false,
111  const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
112  const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
113 
129  bool successors,
130  const std::function<bool(const Gate*)>& target_gate_filter,
131  bool continue_on_mismatch = false,
132  const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
133  const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
134 
149  Result<std::set<Gate*>> get_next_matching_gates_until_depth(const Net* net, bool successors, u32 max_depth, const std::function<bool(const Gate*)>& target_gate_filter = nullptr) const;
150 
165  Result<std::set<Gate*>> get_next_matching_gates_until_depth(const Gate* gate, bool successors, u32 max_depth, const std::function<bool(const Gate*)>& target_gate_filter = nullptr) const;
166 
180  get_next_sequential_gates(const Net* net, bool successors, const std::set<PinType>& forbidden_pins = {}, std::unordered_map<const Net*, std::set<Gate*>>* cache = nullptr) const;
181 
195  get_next_sequential_gates(const Gate* gate, bool successors, const std::set<PinType>& forbidden_pins = {}, std::unordered_map<const Net*, std::set<Gate*>>* cache = nullptr) const;
196 
206  Result<std::map<Gate*, std::set<Gate*>>> get_next_sequential_gates_map(bool successors, const std::set<PinType>& forbidden_pins) const;
207 
219  Result<std::set<Gate*>>
220  get_next_combinational_gates(const Net* net, bool successors, const std::set<PinType>& forbidden_pins = {}, std::unordered_map<const Net*, std::set<Gate*>>* cache = nullptr) const;
221 
233  Result<std::set<Gate*>>
234  get_next_combinational_gates(const Gate* gate, bool successors, const std::set<PinType>& forbidden_pins = {}, std::unordered_map<const Net*, std::set<Gate*>>* cache = nullptr) const;
235 
248  Result<std::optional<u32>> get_shortest_path_distance(const Gate* start_gate,
249  const Gate* end_gate,
250  const PinDirection& direction,
251  const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
252  const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
253 
266  Result<std::optional<std::vector<Gate*>>> get_shortest_path(const Gate* start_gate,
267  const Gate* end_gate,
268  const PinDirection& direction,
269  const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
270  const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
271 
272  // TODO move get_gate_chain and get_complex_gate_chain here
273 
274  private:
275  const Netlist& m_netlist;
276  };
277 } // namespace hal
#define NETLIST_API
Definition: arch_linux.h:30
Definition: gate.h:58
Definition: net.h:58
Result< std::set< Gate * > > get_next_matching_gates_until(const Net *net, bool successors, const std::function< bool(const Gate *)> &target_gate_filter, bool continue_on_mismatch=false, const std::function< bool(const Endpoint *, const u32 current_depth)> &exit_endpoint_filter=nullptr, const std::function< bool(const Endpoint *, const u32 current_depth)> &entry_endpoint_filter=nullptr) const
Result< std::set< Gate * > > get_next_matching_gates(const Gate *gate, bool successors, const std::function< bool(const Gate *)> &target_gate_filter, bool continue_on_match=false, const std::function< bool(const Endpoint *, const u32 current_depth)> &exit_endpoint_filter=nullptr, const std::function< bool(const Endpoint *, const u32 current_depth)> &entry_endpoint_filter=nullptr) const
Result< std::set< Gate * > > get_next_matching_gates_until(const Gate *gate, bool successors, const std::function< bool(const Gate *)> &target_gate_filter, bool continue_on_mismatch=false, const std::function< bool(const Endpoint *, const u32 current_depth)> &exit_endpoint_filter=nullptr, const std::function< bool(const Endpoint *, const u32 current_depth)> &entry_endpoint_filter=nullptr) const
Result< std::set< Gate * > > get_next_matching_gates(const Net *net, bool successors, const std::function< bool(const Gate *)> &target_gate_filter, bool continue_on_match=false, const std::function< bool(const Endpoint *, const u32 current_depth)> &exit_endpoint_filter=nullptr, const std::function< bool(const Endpoint *, const u32 current_depth)> &entry_endpoint_filter=nullptr) const
std::vector< Gate * > get_next_sequential_gates(const Gate *gate, bool get_successors, std::unordered_map< u32, std::vector< Gate * >> &cache)
std::vector< Gate * > get_shortest_path(Gate *start_gate, Gate *end_gate, bool search_both_directions)
PinDirection
Definition: pin_direction.h:36
quint32 u32
Net * net
PinDirection direction