Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/unify_modul…
Browse files Browse the repository at this point in the history
…e_context_menu
  • Loading branch information
Skaleee committed Sep 20, 2024
2 parents a413694 + 09a2ef0 commit 9ae8c8d
Show file tree
Hide file tree
Showing 20 changed files with 491 additions and 135 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file.
## [4.4.1](v4.4.1) - 2024-07-29 14:21:42+02:00 (urgency: medium)
* fixed `hal_py.GateLibrary.gate_types` pybind
* fixed `hal_py.NetlistFactory.load_netlist` pybind
* plugins
* updated `bitorder_propagation_plugin`
* added functionality to export collected bitorder information as a `.json` file to use external tools for propgating and solving conflicts, like SMT solvers

## [4.4.0](v4.4.0) - 2024-07-19 15:55:24+02:00 (urgency: medium)
* **WARNING:** this release breaks the API of the `boolean_influence` and `bitorder_propagation` plugin
Expand Down
43 changes: 21 additions & 22 deletions cmake/detect_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ if(RapidJSON_FOUND AND NOT TARGET RapidJSON::RapidJSON)
endif()


# ###############################
# #### Python support
# ###############################

# set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.8)
find_package(Python3 COMPONENTS Interpreter Development)

if(Python3_Interpreter_FOUND)
message(STATUS "Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3_LIBRARIES: ${Python3_LIBRARIES}")
message(STATUS "PYTHON_MODULE_PREFIX: ${PYTHON_MODULE_PREFIX}")
message(STATUS "PYTHON_MODULE_EXTENSION: ${PYTHON_MODULE_EXTENSION}")
elseif(NOT Python3_Interpreter_FOUND)
set(Missing_package "TRUE")

if(APPLE AND CMAKE_HOST_APPLE)
message(STATUS "To install python3 on MacOS using homebrew run following command:")
message(STATUS " brew install python3")
endif(APPLE AND CMAKE_HOST_APPLE)
endif(Python3_Interpreter_FOUND)


# ###############################
# #### pybind11
Expand Down Expand Up @@ -199,28 +220,6 @@ set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/deps/nlohmann_json"
)


# ###############################
# #### Python support
# ###############################

# set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.8)
find_package(Python3 COMPONENTS Interpreter Development)

if(Python3_Interpreter_FOUND)
message(STATUS "Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3_LIBRARIES: ${Python3_LIBRARIES}")
message(STATUS "PYTHON_MODULE_PREFIX: ${PYTHON_MODULE_PREFIX}")
message(STATUS "PYTHON_MODULE_EXTENSION: ${PYTHON_MODULE_EXTENSION}")
elseif(NOT Python3_Interpreter_FOUND)
set(Missing_package "TRUE")

if(APPLE AND CMAKE_HOST_APPLE)
message(STATUS "To install python3 on MacOS using homebrew run following command:")
message(STATUS " brew install python3")
endif(APPLE AND CMAKE_HOST_APPLE)
endif(Python3_Interpreter_FOUND)

# ###############################
# #### Graphviz
# ###############################
Expand Down
1 change: 1 addition & 0 deletions plugins/bitorder_propagation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ if(PL_BITORDER_PROPAGATION OR BUILD_ALL_PLUGINS)
HEADER ${BITORDER_PROPAGATION_INC}
SOURCES ${BITORDER_PROPAGATION_SRC} ${BITORDER_PROPAGATION_PYTHON_SRC}
PYDOC SPHINX_DOC_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/documentation/bitorder_propagation.rst
LINK_LIBRARIES nlohmann_json::nlohmann_json
)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,29 @@ namespace hal
*/
Result<std::map<std::pair<Module*, PinGroup<ModulePin>*>, std::map<Net*, u32>>> propagate_bitorder(const std::vector<std::pair<Module*, PinGroup<ModulePin>*>>& src,
const std::vector<std::pair<Module*, PinGroup<ModulePin>*>>& dst);

/**
* @brief Export word composition, known bitorder and connectivity in .json format to solve with external tools.
*
* @param[in] src - The pairs of module and pin group with known bit order.
* @param[in] dst - The pairs of module and pin group with unknown bit order.
* @param[in] export_filepath - The filepath where the .json file should be written to.
* @returns OK and a map containing all known bit orders (including new and already known ones) on success, an error otherwise.
*/
Result<std::map<std::pair<Module*, PinGroup<ModulePin>*>, u32>> export_bitorder_propagation_information(const std::vector<std::pair<Module*, PinGroup<ModulePin>*>>& src,
const std::vector<std::pair<Module*, PinGroup<ModulePin>*>>& dst,
const std::string& export_filepath);
/**
* @brief Export word composition, known bitorder and connectivity in .json format to solve with external tools.
*
* @param[in] src - The known indices for the nets belonging to the given module pin groups.
* @param[in] dst - The pairs of module ID and pin group name with unknown bit order.
* @param[in] export_filepath - The filepath where the .json file should be written to.
* @returns OK and the mapping from each mdoule/pingroup pair to its index on success, an error otherwise.
*/
Result<std::map<std::pair<Module*, PinGroup<ModulePin>*>, u32>> export_bitorder_propagation_information(const std::map<std::pair<Module*, PinGroup<ModulePin>*>, std::map<Net*, u32>>& src,
const std::set<std::pair<Module*, PinGroup<ModulePin>*>>& dst,
const std::string& export_filepath);

} // namespace bitorder_propagation
} // namespace hal
58 changes: 58 additions & 0 deletions plugins/bitorder_propagation/python/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,64 @@ namespace hal
:rtype: dict[tuple(hal_py.Module,hal_py.ModulePinGroup),dict[hal_py.Net,int]] or None
)");

m.def(
"export_bitorder_propagation_information",
[](const std::map<std::pair<Module*, PinGroup<ModulePin>*>, std::map<Net*, u32>>& src,
const std::set<std::pair<Module*, PinGroup<ModulePin>*>>& dst,
const std::string& export_filepath) -> std::optional<std::map<std::pair<Module*, PinGroup<ModulePin>*>, u32>> {
const auto res = bitorder_propagation::export_bitorder_propagation_information(src, dst, export_filepath);
if (res.is_ok())
{
return res.get();
}
else
{
log_error("python_context", "{}", res.get_error().get());
return std::nullopt;
}
},
py::arg("src"),
py::arg("dst"),
py::arg("export_filepath"),
R"(
Export collected bitorder information like word composition, known bitorder and connectivity in .json format to solve with external tools.
:param dict[tuple(hal_py.Module,hal_py.ModulePinGroup),dict[hal_py.Net,int]] src: The known indices for the nets belonging to the given module pin groups.
:param set[tuple(hal_py.Module,hal_py.ModulePinGroup)] dst: The pairs of module ID and pin group name with unknown bit order.
:param str export_filepath: The filepath where the .json file should be written to.
:returns: The mapping from each mdoule/pingroup pair to its index on success, ``None`` otherwise.
:rtype: dict[tuple(hal_py.Module, hal_py.ModulePinGroup), int] or None
)");

m.def(
"export_bitorder_propagation_information",
[](const std::vector<std::pair<Module*, PinGroup<ModulePin>*>>& src,
const std::vector<std::pair<Module*, PinGroup<ModulePin>*>>& dst,
const std::string& export_filepath) -> std::optional<std::map<std::pair<Module*, PinGroup<ModulePin>*>, u32>> {
const auto res = bitorder_propagation::export_bitorder_propagation_information(src, dst, export_filepath);
if (res.is_ok())
{
return res.get();
}
else
{
log_error("python_context", "{}", res.get_error().get());
return std::nullopt;
}
},
py::arg("src"),
py::arg("dst"),
py::arg("export_filepath"),
R"(
Export collected bitorder information like word composition, known bitorder and connectivity in .json format to solve with external tools.
:param tuple(hal_py.Module,hal_py.ModulePinGroup) src: The pair of module and pin group with known bit order.
:param tuple(hal_py.Module,hal_py.ModulePinGroup) dst: The pair of module and pin group with unknown bit order.
:param str export_filepath: The filepath where the .json file should be written to.
:returns: The mapping from each mdoule/pingroup pair to its index on success, ``None`` otherwise.
:rtype: dict[tuple(hal_py.Module, hal_py.ModulePinGroup), int] or None
)");

#ifndef PYBIND11_MODULE
return m.ptr();
#endif // PYBIND11_MODULE
Expand Down
Loading

0 comments on commit 9ae8c8d

Please sign in to comment.