3 #include "pybind11/operators.h"
4 #include "pybind11/pybind11.h"
5 #include "pybind11/stl.h"
6 #include "pybind11/stl_bind.h"
11 namespace py = pybind11;
19 #ifdef PYBIND11_MODULE
20 PYBIND11_MODULE(sequential_symbolic_execution, m)
22 m.doc() =
"hal SequentialSymbolicExecutionPlugin python bindings";
26 py::module m(
"sequential_symbolic_execution",
"hal SequentialSymbolicExecutionPlugin python bindings");
29 py::class_<SequentialSymbolicExecutionPlugin, RawPtrWrapper<SequentialSymbolicExecutionPlugin>,
BasePluginInterface> py_sequential_symbolic_execution_plugin(
30 m,
"SequentialSymbolicExecutionPlugin", R
"(This class provides an interface to integrate the HAWKEYE tool as a plugin within the HAL framework.)");
33 The name of the plugin.
39 Get the name of the plugin.
41 :returns: The name of the plugin.
46 The version of the plugin.
52 Get the version of the plugin.
54 :returns: The version of the plugin.
59 The description of the plugin.
65 Get the description of the plugin.
67 :returns: The description of the plugin.
72 A set of plugin names that this plugin depends on.
78 Get a set of plugin names that this plugin depends on.
80 :returns: A set of plugin names that this plugin depends on.
84 m.def("get_pg_word_values_at_z3",
86 const std::vector<u32>& time_indices,
87 const std::vector<bool>& subgraph_gates_byte_map,
88 const std::vector<std::map<u32, bool>>& known_inputs,
90 const bool substitute_endpoints) {
93 const auto word_values_res =
sse::get_word_values_at_z3(words, time_indices, subgraph_gates_byte_map, known_inputs, word_level_calculations, substitute_endpoints, ctx);
95 if (word_values_res.is_error())
97 log_error(
"sequential_symbolic_execution",
"{}", word_values_res.get_error().get());
101 const auto word_values = word_values_res.get();
103 for (
u32 idx = 0; idx < word_values.size(); idx++)
105 const auto& [mod, pg] = words.at(idx);
106 const auto& w = word_values.at(idx);
107 const auto t = time_indices.at(idx);
109 if (idx == 0 || t != time_indices.at(idx - 1))
111 std::cout <<
"T[" << t <<
"]" << std::endl;
115 std::cout <<
"\t" << mod->get_name() <<
" - " << pg->get_name() <<
": " << std::endl;
119 if (w_z3_simplified.is_error())
121 std::cout << w_z3_simplified.get_error().get() << std::endl;
125 if (w_bfz_simplified.is_error())
127 std::cout << w_bfz_simplified.get_error().get() << std::endl;
131 const std::string s = w_bfz_simplified.get().to_string();
132 std::cout <<
"\t\t" << s << std::endl;
139 #ifndef PYBIND11_MODULE
std::set< std::string > get_dependencies() const override
Get the plugin dependencies.
std::string get_name() const override
Get the name of the plugin.
std::string get_description() const override
Get a short description of the plugin.
std::string get_version() const override
Get the version of the plugin.
#define log_error(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)
Result< std::vector< z3::expr > > get_word_values_at_z3(const std::vector< std::vector< Net * >> &words, const std::vector< u32 > &time_indices, const std::vector< bool > &subgraph_gates_byte_map, const std::vector< std::map< u32, bool >> &known_inputs, const std::map< PinGroup< ModulePin > *, BooleanFunction > &word_level_calculations, const bool substitute_endpoints, z3::context &ctx)
Get the Z3 expressions representing the values of multiple nets as words at specific time indices.
Result< z3::expr > simplify_local(const z3::expr &e, std::unordered_map< u32, z3::expr > &cache, const bool check_correctness=false)
Applies hand-crafted simplification rules iteratively until no further simplifications can be made.
Result< BooleanFunction > to_bf(const z3::expr &e)
This file contains all functions related to the HAL plugin API.
This file contains the declarations for functions to perform sequential symbolic execution using z3.