HAL  v4.5.0-130-g83e8bfb3f
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
state_transition_graph.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/defines.h"
36 
37 #include <filesystem>
38 #include <map>
39 #include <string>
40 #include <utility>
41 #include <vector>
42 
43 namespace hal
44 {
45  class Gate;
46  class Net;
47  class Netlist;
48 
49  namespace solve_fsm
50  {
59  {
63  Netlist* netlist = nullptr;
64 
70  std::vector<Gate*> state_register;
71 
77  std::vector<std::pair<std::string, std::vector<Net*>>> output_nets;
78 
82  std::map<u64, std::map<u64, BooleanFunction>> transitions;
83 
93  std::map<u64, std::vector<std::pair<std::string, BooleanFunction>>> outputs;
94 
100  u32 get_state_size() const;
101 
114  Result<std::string> generate_dot_graph(const std::filesystem::path& graph_path = "", const u32 max_condition_length = 128, const u32 base = 10) const;
115 
127  Result<std::string> to_string(const u32 base = 10) const;
128 
136  Result<std::monostate> write_txt(const std::filesystem::path& file_path, const u32 base = 10) const;
137  };
138  } // namespace solve_fsm
139 } // namespace hal
uint32_t u32
Definition: defines.h:41
Result< StateTransitionGraph > solve_fsm(const Configuration &config)
Recover the state transition graph of an FSM from the netlist that implements it.
Definition: solve_fsm.cpp:622
Definition: defines.h:45
The state transition graph of an FSM, i.e., the behavior that its netlist implements.
std::vector< std::pair< std::string, std::vector< Net * > > > output_nets
The outputs of the FSM, each given as a name and the nets that make up that output.
Result< std::string > generate_dot_graph(const std::filesystem::path &graph_path="", const u32 max_condition_length=128, const u32 base=10) const
Render the state transition graph in the DOT format.
std::map< u64, std::map< u64, BooleanFunction > > transitions
A map from each state to its successor states, together with the condition under which the respective...
u32 get_state_size() const
Get the number of flip-flops that make up the state register, i.e., the bit-size of a state.
std::vector< Gate * > state_register
The flip-flops that make up the state register, in the order that determines the encoding of a state.
Netlist * netlist
The netlist that implements the FSM.
Result< std::string > to_string(const u32 base=10) const
Render the state transition graph as human-readable text, without truncating anything.
std::map< u64, std::vector< std::pair< std::string, BooleanFunction > > > outputs
A map from each state to the value of every output of the FSM in that state.
Result< std::monostate > write_txt(const std::filesystem::path &file_path, const u32 base=10) const
Write the state transition graph to a text file, without truncating anything.