|
HAL
v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
Classes | |
| class | RecursiveDirectoryRange |
| class | DirectoryRange |
| struct | Color |
Functions | |
| template<typename T > | |
| bool | unordered_vector_erase (std::vector< T > &vec, T element) |
| template<typename T > | |
| bool | vectors_have_same_content (std::vector< T > vec_1, std::vector< T > vec_2) |
| u64 | get_bit (const u64 value, const u64 index) |
| u64 | set_bit (const u64 value, const u64 index) |
| u64 | clear_bit (const u64 value, const u64 index) |
| u64 | toggle_bit (const u64 value, const u64 index) |
| template<typename T > | |
| bool | ends_with (const T &s, const T &end) |
| template<typename T > | |
| bool | starts_with (const T &s, const T &start) |
| template<typename T > | |
| bool | is_digits (const T &s) |
| template<typename T > | |
| bool | is_integer (const T &s) |
| template<typename T > | |
| bool | is_floating_point (const T &s) |
| template<typename T > | |
| std::vector< T > | split (const T &s, const char delim, bool obey_brackets=false) |
| template<typename T > | |
| T | ltrim (const T &s, const char *to_remove=" \t\r\n") |
| template<typename T > | |
| T | rtrim (const T &s, const char *to_remove=" \t\r\n") |
| template<typename T > | |
| T | trim (const T &s, const char *to_remove=" \t\r\n") |
| template<typename T > | |
| T | replace (const T &str, const T &search, const T &replace) |
| template<typename Iterator , class Transform > | |
| std::string | join (const std::string &joiner, const Iterator &begin, const Iterator &end, const Transform &transform) |
| template<typename T , class Transform > | |
| std::string | join (const std::string &joiner, const T &items, const Transform &transform) |
| template<typename T > | |
| std::string | join (const std::string &joiner, const T &items) |
| template<typename T > | |
| T | to_upper (const T &s) |
| template<typename T > | |
| T | to_lower (const T &s) |
| template<typename T > | |
| u32 | num_of_occurrences (const T &s, const T &substr) |
| template<typename T , template< typename, typename... > class Container, typename... Args> | |
| std::vector< T > | to_vector (const Container< T, Args... > &container) |
| template<typename T , template< typename, typename... > class Container, typename... Args> | |
| std::set< T > | to_set (const Container< T, Args... > &container) |
| template<typename T1 , typename T2 > | |
| bool | is_subset (const T1 &subset, const T2 &superset) |
| bool | file_exists (const std::string &filename) |
| bool | folder_exists_and_is_accessible (const std::filesystem::path &path) |
| std::filesystem::path | which (const std::string &name, const std::string &path="") |
| std::filesystem::path | get_binary_directory () |
| std::filesystem::path | get_base_directory () |
| std::filesystem::path | get_library_directory () |
| std::filesystem::path | get_share_directory () |
| std::filesystem::path | get_user_share_directory () |
| std::filesystem::path | get_config_directory () |
| std::filesystem::path | get_user_config_directory () |
| std::filesystem::path | get_default_log_directory (std::filesystem::path source_file="") |
| std::vector< std::filesystem::path > | get_gate_library_directories () |
| std::vector< std::filesystem::path > | get_plugin_directories () |
| std::filesystem::path | get_first_directory_exists (std::vector< std::filesystem::path > path_hints) |
| std::filesystem::path | get_file (std::string file_name, std::vector< std::filesystem::path > path_hints) |
| Result< std::filesystem::path > | get_unique_temp_directory (const std::string &prefix="", const u32 max_attempts=5) |
| std::string | get_open_source_licenses () |
| Result< u64 > | wrapped_stoull (const std::string &s, const u32 base=10) |
| Result< u32 > | wrapped_stoul (const std::string &s, const u32 base=10) |
Contains general-purpose utility functions for strings, containers, bit manipulation, and file system paths.
| bool hal::utils::ends_with | ( | const T & | s, |
| const T & | end | ||
| ) |
Checks whether a string ends with another string.
| [in] | s | - The string to analyze. |
| [in] | end | - The ending to check for. |
true if s ends with end, false otherwise. Definition at line 149 of file utils.h.
Referenced by hal::PluginPythonShell::exec(), and hal::plugin_manager::has_valid_file_extension().
| bool hal::utils::file_exists | ( | const std::string & | filename | ) |
Check whether a file exists.
| [in] | filename | - The file to check. |
true if file exists, false otherwise. Definition at line 31 of file utils.cpp.
Referenced by hal::CliExtensionsPerfTest::handle_cli_call().
| bool hal::utils::folder_exists_and_is_accessible | ( | const std::filesystem::path & | path | ) |
| std::filesystem::path hal::utils::get_base_directory | ( | ) |
Get the base path to the HAL installation.
Definition at line 100 of file utils.cpp.
References die, get_binary_directory(), and which().
Referenced by hal::core_utils_init(), get_config_directory(), get_library_directory(), and get_share_directory().
| std::filesystem::path hal::utils::get_binary_directory | ( | ) |
Get the path to the executable of HAL.
Definition at line 70 of file utils.cpp.
References size.
Referenced by hal::core_utils_init(), and get_base_directory().
| std::filesystem::path hal::utils::get_config_directory | ( | ) |
Get the path to the read-only global configuration directory of HAL.
The resulting path is relative to the binary directory.
Definition at line 164 of file utils.cpp.
References get_base_directory(), and get_first_directory_exists().
| std::filesystem::path hal::utils::get_default_log_directory | ( | std::filesystem::path | source_file = "" | ) |
Get the path to the default directory for log files.
If a netlist source file is provided, the function returns the parent directory, otherwise get_user_share_directory() / "log".
| [in] | source_file | - The netlist source file. |
Definition at line 179 of file utils.cpp.
References get_user_share_directory().
Referenced by hal::core_utils_init().
| std::filesystem::path hal::utils::get_file | ( | std::string | file_name, |
| std::vector< std::filesystem::path > | path_hints | ||
| ) |
Search for the given filename in all paths provided by the path hints (searched in order).
| [in] | file_name | - The filename to search for. |
| [in] | path_hints | - A vector of hints. |
Definition at line 220 of file utils.cpp.
Referenced by hal::gate_library_manager::get_gate_library(), and hal::plugin_manager::get_plugin_path().
| std::filesystem::path hal::utils::get_first_directory_exists | ( | std::vector< std::filesystem::path > | path_hints | ) |
Get the first directory out of all the path hints that exists (searched in order).
| [in] | path_hints | - A vector of hints. |
Definition at line 207 of file utils.cpp.
Referenced by get_config_directory(), and get_share_directory().
| std::vector< std::filesystem::path > hal::utils::get_gate_library_directories | ( | ) |
Get the paths to the locations where gate libraries are searched.
Contains the share and user share directories.
Definition at line 186 of file utils.cpp.
References get_share_directory(), and get_user_share_directory().
Referenced by hal::core_utils_init(), hal::gate_library_manager::get_all_path(), hal::gate_library_manager::get_gate_library(), and hal::gate_library_manager::load_all().
| std::filesystem::path hal::utils::get_library_directory | ( | ) |
Get the path to the shared and static libraries of HAL.
The resulting path is relative to the binary directory.
Definition at line 129 of file utils.cpp.
References get_base_directory().
Referenced by hal::core_utils_init(), hal::PluginPythonShell::exec(), get_plugin_directories(), and hal::PythonContext::initializeContext().
| std::string hal::utils::get_open_source_licenses | ( | ) |
Get the licenses of all embedded OpenSource Projects.
Definition at line 299 of file utils.cpp.
Referenced by hal::AboutDialog::AboutDialog().
| std::vector< std::filesystem::path > hal::utils::get_plugin_directories | ( | ) |
Get the paths to the locations where plugins are searched.
Contains the library and user share directories.
Definition at line 195 of file utils.cpp.
References get_library_directory(), and get_user_share_directory().
Referenced by hal::core_utils_init(), and hal::PythonContext::initializeContext().
| std::filesystem::path hal::utils::get_share_directory | ( | ) |
Get the path to the shared objects of HAL.
The resulting path is relative to the binary directory.
Definition at line 149 of file utils.cpp.
References get_base_directory(), and get_first_directory_exists().
Referenced by hal::core_utils_init(), and get_gate_library_directories().
| Result< std::filesystem::path > hal::utils::get_unique_temp_directory | ( | const std::string & | prefix = "", |
| const u32 | max_attempts = 5 |
||
| ) |
Try to generate a unique temporary directory.
| [in] | prefix | - A prefix that is added in front of the unique identifier. Defaults to an empty string. |
| [in] | max_attempts | - The maximum amount of attempts before the function fails. Defaults to 5. |
Definition at line 276 of file utils.cpp.
Referenced by hal::resynthesis::generate_resynth_netlist_for_boolean_functions(), hal::resynthesis::resynthesize_gate(), hal::resynthesis::resynthesize_gates(), and hal::resynthesis::resynthesize_subgraph().
| std::filesystem::path hal::utils::get_user_config_directory | ( | ) |
Get the path to the configuration directory of the user.
This is ~/.config/hal on Unix.
Definition at line 172 of file utils.cpp.
Referenced by hal::core_utils_init(), hal::PluginGui::exec(), and hal::NetlistSimulatorControllerPlugin::on_load().
| std::filesystem::path hal::utils::get_user_share_directory | ( | ) |
Get the path to shared objects and files provided by the user.
This is ~/.local/share/hal on Unix.
Definition at line 157 of file utils.cpp.
Referenced by hal::core_utils_init(), get_default_log_directory(), get_gate_library_directories(), and get_plugin_directories().
| bool hal::utils::is_digits | ( | const T & | s | ) |
| bool hal::utils::is_floating_point | ( | const T & | s | ) |
| bool hal::utils::is_integer | ( | const T & | s | ) |
| bool hal::utils::is_subset | ( | const T1 & | subset, |
| const T2 & | superset | ||
| ) |
Check whether one container is a subset of another container. The function checks whether all elements of the subset container are contained in the superset container.
| [in] | subset | - The container containing the possible subset. |
| [in] | superset | - The container containing the possible superset. |
true if the subset container actually is a subset of the superset, false otherwise. Definition at line 541 of file utils.h.
Referenced by hal::module_identification::Result::create_modules_in_netlist().
| std::string hal::utils::join | ( | const std::string & | joiner, |
| const Iterator & | begin, | ||
| const Iterator & | end, | ||
| const Transform & | transform | ||
| ) |
Join all elements of a iterator range with a joiner-string. A transformation is applied to all elements of the collections before joining.
| [in] | joiner | - The string joining the elements. |
| [in] | begin | - The start iterator. |
| [in] | end | - The end iterator. |
| [in] | transform | - The transformation function. |
Definition at line 414 of file utils.h.
Referenced by hal::module_identification::FunctionalCandidate::add_all_shifted_operand(), hal::module_identification::FunctionalCandidate::add_selected_shifted_operand(), hal::dataflow::analyze(), hal::module_identification::Result::create_modules_in_netlist(), hal::module_identification::FunctionalCandidate::get_candidate_info(), hal::module_identification::VerifiedCandidate::get_candidate_info(), hal::module_identification::VerifiedCandidate::get_name(), join(), hal::ProgramOptions::parse(), hal::ProgramArguments::set_option(), and hal::dataflow::Result::write_txt().
| std::string hal::utils::join | ( | const std::string & | joiner, |
| const T & | items | ||
| ) |
| std::string hal::utils::join | ( | const std::string & | joiner, |
| const T & | items, | ||
| const Transform & | transform | ||
| ) |
Join all elements of a collection with a joiner-string. A transformation is applied to all elements of the collections before joining.
| [in] | joiner | - The string joining the elements. |
| [in] | items | - The collection of elements to join. |
| [in] | transform | - The transformation function. |
Definition at line 440 of file utils.h.
References join().
| T hal::utils::ltrim | ( | const T & | s, |
| const char * | to_remove = " \t\r\n" |
||
| ) |
| u32 hal::utils::num_of_occurrences | ( | const T & | s, |
| const T & | substr | ||
| ) |
| T hal::utils::replace | ( | const T & | str, |
| const T & | search, | ||
| const T & | replace | ||
| ) |
Replace all occurences of a substring within a string with another string.
| [in] | str | - The initial string. |
| [in] | search | - The targetted substring. |
| [in] | replace | - The replacement string. |
Definition at line 384 of file utils.h.
References hal::T.
Referenced by hal::LogicEvaluatorDialog::compile(), hal::verilator::escape_net_name(), hal::verilator::converter::get_provided_models(), and hal::GenlibWriter::write().
| T hal::utils::rtrim | ( | const T & | s, |
| const char * | to_remove = " \t\r\n" |
||
| ) |
Remove any trailing whitespace characters from the end of a string.
| [in] | s | - The string to trim. |
| [in] | to_remove | - The characters to remove. |
Definition at line 338 of file utils.h.
References hal::T.
Referenced by hal::PythonContext::forwardStdout().
| std::vector<T> hal::utils::split | ( | const T & | s, |
| const char | delim, | ||
| bool | obey_brackets = false |
||
| ) |
Split a string into a vector of strings. The split delimiter can be specified by the user.
The delimiters are removed in the splitting process.
To avoid splitting within brackets, set obey_brackets to .true
| [in] | s | - The string to split. |
| [in] | delim | - The delimiter, indicating where to split. |
| [in] | obey_brackets | - Flag to indicate whether brackets are obeyed. |
Definition at line 239 of file utils.h.
References hal::T.
Referenced by hal::PluginPythonShell::exec(), hal::module_identification::FunctionalCandidate::identify_control_signals(), and which().
| bool hal::utils::starts_with | ( | const T & | s, |
| const T & | start | ||
| ) |
Checks whether a string begins with another string.
| [in] | s | - The string to analyze. |
| [in] | start | - The beginning to check for. |
true if s begins with start, false otherwise. Definition at line 169 of file utils.h.
Referenced by hal::dataflow::Result::create_modules().
| T hal::utils::to_lower | ( | const T & | s | ) |
Convert a string to lower case.
| [in] | s | - The string to convert. |
Definition at line 479 of file utils.h.
References hal::T.
Referenced by hal::netlist_parser_manager::can_parse(), hal::gate_library_parser_manager::register_parser(), hal::netlist_parser_manager::register_parser(), hal::gate_library_writer_manager::register_writer(), and hal::netlist_writer_manager::register_writer().
|
inline |
| T hal::utils::to_upper | ( | const T & | s | ) |
|
inline |
Turn a given iterable collection into a vector.
| [in] | container | - The input collection. |
Definition at line 515 of file utils.h.
Referenced by hal::z3_utils::compare_netlists(), hal::z3_utils::Converter::convert_z3_expr_to_func(), hal::Gate::get_resolved_boolean_function(), hal::LUTTableModel::setBooleanFunction(), and hal::solve_fsm::solve_fsm_brute_force().
| T hal::utils::trim | ( | const T & | s, |
| const char * | to_remove = " \t\r\n" |
||
| ) |
Remove any leading and trailing whitespace characters from the beginning and the end of a string.
| [in] | s | - The string to trim. |
| [in] | to_remove | - The characters to remove. |
Definition at line 360 of file utils.h.
References hal::T.
Referenced by hal::ProgramOptions::add_flags(), hal::gate_library_parser_manager::register_parser(), hal::netlist_parser_manager::register_parser(), hal::gate_library_writer_manager::register_writer(), hal::netlist_writer_manager::register_writer(), hal::Gate::set_name(), hal::Module::set_name(), hal::Net::set_name(), and hal::Grouping::set_name().
|
inline |
| bool hal::utils::vectors_have_same_content | ( | std::vector< T > | vec_1, |
| std::vector< T > | vec_2 | ||
| ) |
| std::filesystem::path hal::utils::which | ( | const std::string & | name, |
| const std::string & | path = "" |
||
| ) |
Locate an executable in the given path environment.
| [in] | name | - The name of the executable. |
| [in] | path | - The search path (defaults to PATH environment variable). |
Definition at line 243 of file utils.cpp.
References name, split(), and UNUSED.
Referenced by get_base_directory().
A safe wrapper around the std::stoul function that provides a Result<> for error handling instead of exceptions.
| [in] | s | - The string represntation of the number. |
| [in] | base | - The base of the integer, defaults to 10. |
A safe wrapper around the std::stoull function that provides a Result<> for error handling instead of exceptions.
| [in] | s | - The string represntation of the number. |
| [in] | base | - The base of the integer, defaults to 10. |