HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
result.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 
31 #pragma once
32 
33 #include "hal_core/netlist/gate.h"
35 #include "hal_core/netlist/net.h"
37 #include "hal_core/utilities/log.h"
40 
41 #include <set>
42 
43 namespace hal
44 {
48  namespace module_identification
49  {
54  struct Result
55  {
63  Result(Netlist* nl, const std::vector<std::pair<BaseCandidate, VerifiedCandidate>>& result, const std::string& timing_stats_json = "");
64 
70  Netlist* get_netlist() const;
71 
80  std::map<u32, std::vector<Gate*>> get_verified_candidate_gates() const;
81 
90  std::map<u32, VerifiedCandidate> get_verified_candidates() const;
91 
100  std::map<u32, std::vector<Gate*>> get_candidate_gates() const;
101 
110  std::map<u32, VerifiedCandidate> get_candidates() const;
111 
119 
127 
133  std::set<Gate*> get_all_gates() const;
134 
140  std::set<Gate*> get_all_verified_gates() const;
141 
148 
154  std::string get_timing_stats() const;
155 
166  hal::Result<Result> merge(const Result& other, const std::vector<std::vector<Gate*>>& registers) const;
167 
177  static std::vector<std::vector<std::set<Gate*>>> assign_base_candidates_to_iterations(const std::vector<Result>& iteration_results, const bool create_block_lists = false);
178 
179  private:
183  Netlist* m_netlist;
184 
188  std::vector<std::pair<BaseCandidate, VerifiedCandidate>> m_candidates;
189 
193  std::string m_timing_stats_json = "";
194  };
195 
196  } // namespace module_identification
197 } // namespace hal
This file contains the definition of the BaseCandidate class, which represents a base candidate in th...
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
The result of a module identification run containing the candidates.
Definition: result.h:55
std::map< u32, std::vector< Gate * > > get_candidate_gates() const
Get a map of the candidate IDs to the gates contained inside the candidate.
Definition: result.cpp:57
std::map< u32, VerifiedCandidate > get_candidates() const
Get a map of the candidate IDs to the candidates.
Definition: result.cpp:68
hal::Result< Result > merge(const Result &other, const std::vector< std::vector< Gate * >> &registers) const
Merges two results by combining the found verified candidates.
Definition: result.cpp:685
std::set< Gate * > get_all_gates() const
Get all gates contained in any of the candidates.
Definition: result.cpp:107
std::map< u32, std::vector< Gate * > > get_verified_candidate_gates() const
Get a map of the candidate IDs to the gates contained inside the verified candidates.
Definition: result.cpp:28
std::set< Gate * > get_all_verified_gates() const
Get all gates contained in any of the verified candidates.
Definition: result.cpp:124
static std::vector< std::vector< std::set< Gate * > > > assign_base_candidates_to_iterations(const std::vector< Result > &iteration_results, const bool create_block_lists=false)
For different runs of the plugin figure out in which iteration the plugin found the highest quality r...
Definition: result.cpp:872
Netlist * get_netlist() const
Get the netlist on which module identification has been performed.
Definition: result.cpp:23
hal::Result< std::monostate > create_modules_in_netlist()
Creates a HAL module for each candidate of the result.
Definition: result.cpp:426
Result(Netlist *nl, const std::vector< std::pair< BaseCandidate, VerifiedCandidate >> &result, const std::string &timing_stats_json="")
Constructor for Result.
Definition: result.cpp:18
hal::Result< std::vector< Gate * > > get_candidate_gates_by_id(const u32 id) const
Get the gates of the candidate with the corresponding ID.
Definition: result.cpp:79
std::string get_timing_stats() const
Get the collected timing information formatted as a JSON string.
Definition: result.cpp:680
hal::Result< VerifiedCandidate > get_candidate_by_id(const u32 id) const
Returns the candidate with the corresponding ID.
Definition: result.cpp:97
std::map< u32, VerifiedCandidate > get_verified_candidates() const
Get a map of the candidate IDs to the verified candidates.
Definition: result.cpp:43