|
HAL
v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
Functions | |
| Result< BooleanFunction > | get_subgraph_function (const Net *net, const std::vector< const Gate * > &subgraph_gates, std::map< std::pair< u32, const GatePin * >, BooleanFunction > &cache) |
| Result< BooleanFunction > | get_subgraph_function (const Net *net, const std::vector< const Gate * > &subgraph_gates) |
| std::unique_ptr< Netlist > | copy_netlist (const Netlist *nl) |
| std::pair< std::map< u32, Gate * >, std::vector< std::vector< int > > > | get_ff_dependency_matrix (const Netlist *nl) |
| std::unique_ptr< Netlist > | get_partial_netlist (const Netlist *nl, const std::vector< const Gate * > &subgraph_gates) |
| std::vector< Gate * > | get_next_gates (const Gate *gate, bool get_successors, int depth=0, const std::function< bool(const Gate *)> &filter=nullptr) |
| std::vector< Gate * > | get_next_gates (const Net *net, bool get_successors, int depth=0, const std::function< bool(const Gate *)> &filter=nullptr) |
| std::vector< Gate * > | get_next_sequential_gates (const Gate *gate, bool get_successors, std::unordered_map< u32, std::vector< Gate * >> &cache) |
| std::vector< Gate * > | get_next_sequential_gates (const Gate *gate, bool get_successors) |
| std::vector< Gate * > | get_next_sequential_gates (const Net *net, bool get_successors, std::unordered_map< u32, std::vector< Gate * >> &cache) |
| std::vector< Gate * > | get_next_sequential_gates (const Net *net, bool get_successors) |
| std::vector< Gate * > | get_path (const Gate *gate, bool get_successors, std::set< GateTypeProperty > stop_properties, std::unordered_map< u32, std::vector< Gate * >> &cache) |
| std::vector< Gate * > | get_path (const Gate *gate, bool get_successors, std::set< GateTypeProperty > stop_properties) |
| std::vector< Gate * > | get_path (const Net *net, bool get_successors, std::set< GateTypeProperty > stop_properties, std::unordered_map< u32, std::vector< Gate * >> &cache) |
| std::vector< Gate * > | get_path (const Net *net, bool get_successors, std::set< GateTypeProperty > stop_properties) |
| std::vector< Net * > | get_nets_at_pins (Gate *gate, std::vector< GatePin * > pins) |
| Result< u32 > | remove_buffers (Netlist *netlist, bool analyze_inputs=false) |
| Result< u32 > | remove_unused_lut_endpoints (Netlist *netlist) |
| std::vector< Net * > | get_common_inputs (const std::vector< Gate * > &gates, u32 threshold=0) |
| Result< std::monostate > | replace_gate (Gate *gate, GateType *target_type, std::map< GatePin *, GatePin * > pin_map) |
| Result< std::vector< Gate * > > | get_gate_chain (Gate *start_gate, const std::vector< const GatePin * > &input_pins={}, const std::vector< const GatePin * > &output_pins={}, const std::function< bool(const Gate *)> &filter=nullptr) |
| Result< std::vector< Gate * > > | get_complex_gate_chain (Gate *start_gate, const std::vector< GateType * > &chain_types, const std::map< GateType *, std::vector< const GatePin * >> &input_pins, const std::map< GateType *, std::vector< const GatePin * >> &output_pins, const std::function< bool(const Gate *)> &filter=nullptr) |
| std::vector< Gate * > | get_shortest_path (Gate *start_gate, Gate *end_gate, bool search_both_directions=false) |
| std::vector< Gate * > | get_shortest_path (Gate *start_gate, Module *end_module, bool forward_direction) |
| std::vector< std::vector< Gate * > > | get_shortest_path (Module *start_module, Module *end_module) |
Contains various utility functions that operate on a netlist without modifying it, e.g., traversal and analysis helpers.
| [in] | nl | - The netlist to copy. |
Definition at line 174 of file netlist_utils.cpp.
References hal::Netlist::copy(), and log_error.
Referenced by hal::netlist_utils_init().
| std::vector< Net * > hal::netlist_utils::get_common_inputs | ( | const std::vector< Gate * > & | gates, |
| u32 | threshold = 0 |
||
| ) |
Returns all nets that are considered to be common inputs to the provided gates. A threshold value can be provided to specify the number of gates a net must be connected to in order to be classified as a common input. If the theshold value is set to 0, a net must be input to all gates to be considered a common input.
| [in] | gates | - The gates. |
| [in] | threshold | - The threshold value, defaults to 0. |
Definition at line 853 of file netlist_utils.cpp.
Referenced by hal::netlist_utils_init().
| Result< std::vector< Gate * > > hal::netlist_utils::get_complex_gate_chain | ( | Gate * | start_gate, |
| const std::vector< GateType * > & | chain_types, | ||
| const std::map< GateType *, std::vector< const GatePin * >> & | input_pins, | ||
| const std::map< GateType *, std::vector< const GatePin * >> & | output_pins, | ||
| const std::function< bool(const Gate *)> & | filter = nullptr |
||
| ) |
Find a sequence of gates (of the specified sequence of gate types) that are connected via the specified input and output pins. The start gate may be any gate within a such a sequence, it is not required to be the first or the last gate. However, the start gate must be of the first gate type within the repeating sequence. If input and/or output pins are specified for a gate type, the gates must be connected through one of the input pins and/or one of the output pins. The optional filter is evaluated on every gate such that the result only contains gates matching the specified condition.
| [in] | start_gate | - The gate at which to start the chain detection. |
| [in] | chain_types | - The sequence of gate types that is expected to make up the gate chain. |
| [in] | input_pins | - The input pins (of every gate type of the sequence) through which the gates must be connected. |
| [in] | output_pins | - The output pins (of every gate type of the sequence) through which the gates must be connected. |
| [in] | filter | - An optional filter function to be evaluated on each gate. |
Definition at line 1033 of file netlist_utils.cpp.
References ERR, hal::Endpoint::get_gate(), hal::Gate::get_id(), hal::Netlist::get_id(), hal::Gate::get_name(), hal::Gate::get_netlist(), hal::Endpoint::get_pin(), hal::Gate::get_predecessors(), hal::Gate::get_successors(), hal::Gate::get_type(), log_debug, and OK.
Referenced by hal::netlist_utils_init().
| std::pair< std::map< u32, Gate * >, std::vector< std::vector< int > > > hal::netlist_utils::get_ff_dependency_matrix | ( | const Netlist * | nl | ) |
Get the FF dependency matrix of a netlist.
| [in] | nl | - The netlist to extract the dependency matrix from. |
Definition at line 187 of file netlist_utils.cpp.
References hal::ff, hal::Netlist::get_gates(), and get_next_sequential_gates().
Referenced by hal::netlist_utils_init().
| Result< std::vector< Gate * > > hal::netlist_utils::get_gate_chain | ( | Gate * | start_gate, |
| const std::vector< const GatePin * > & | input_pins = {}, |
||
| const std::vector< const GatePin * > & | output_pins = {}, |
||
| const std::function< bool(const Gate *)> & | filter = nullptr |
||
| ) |
Find a sequence of identical gates that are connected via the specified input and output pins. The start gate may be any gate within a such a sequence, it is not required to be the first or the last gate. If input and/or output pins are specified, the gates must be connected through one of the input pins and/or one of the output pins. The optional filter is evaluated on every gate such that the result only contains gates matching the specified condition.
| [in] | start_gate | - The gate at which to start the chain detection. |
| [in] | input_pins | - The input pins through which the gates must be connected. Defaults to an empty vector. |
| [in] | output_pins | - The output pins through which the gates must be connected. Defaults to an empty vector. |
| [in] | filter | - An optional filter function to be evaluated on each gate. |
Definition at line 910 of file netlist_utils.cpp.
References ERR, hal::Endpoint::get_gate(), hal::Gate::get_id(), hal::Netlist::get_id(), hal::Gate::get_name(), hal::Gate::get_netlist(), hal::Gate::get_successors(), hal::Gate::get_type(), and log_debug.
Referenced by hal::netlist_utils_init().
| std::vector< Net * > hal::netlist_utils::get_nets_at_pins | ( | Gate * | gate, |
| std::vector< GatePin * > | pins | ||
| ) |
Get the nets that are connected to a subset of pins of the specified gate.
| [in] | gate | - The gate. |
| [in] | pins | - The targeted pins. |
Definition at line 571 of file netlist_utils.cpp.
References direction, hal::Gate::get_fan_in_net(), hal::Gate::get_fan_out_net(), hal::Gate::get_id(), hal::Gate::get_name(), hal::inout, hal::input, log_warning, net, hal::output, and pins.
Referenced by hal::netlist_utils_init().
| std::vector< Gate * > hal::netlist_utils::get_next_gates | ( | const Gate * | gate, |
| bool | get_successors, | ||
| int | depth = 0, |
||
| const std::function< bool(const Gate *)> & | filter = nullptr |
||
| ) |
| [in] | gate | - The initial gate. |
| [in] | get_successors | - true to return successors, false for Predecessors. |
| [in] | depth | - Depth of recursion. |
| [in] | filter | - User-defined filter function. |
Definition at line 245 of file netlist_utils.cpp.
Referenced by hal::CommonSuccessorPredecessorGateQueue::getNext(), and hal::netlist_utils_init().
| std::vector< Gate * > hal::netlist_utils::get_next_gates | ( | const Net * | net, |
| bool | get_successors, | ||
| int | depth = 0, |
||
| const std::function< bool(const Gate *)> & | filter = nullptr |
||
| ) |
false. Only gates matching the filter will be added to the result vector.| [in] | net | - The initial net. |
| [in] | get_successors | - true to return successors, false for Predecessors. |
| [in] | depth | - Depth of recursion. |
| [in] | filter | - User-defined filter function. |
Definition at line 293 of file netlist_utils.cpp.
References net.
| std::vector< Gate * > hal::netlist_utils::get_next_sequential_gates | ( | const Gate * | gate, |
| bool | get_successors | ||
| ) |
| [in] | gate | - The initial gate. |
| [in] | get_successors | - If true, sequential successors are returned, otherwise sequential predecessors are returned. |
Definition at line 474 of file netlist_utils.cpp.
References get_next_sequential_gates().
| std::vector< Gate * > hal::netlist_utils::get_next_sequential_gates | ( | const Gate * | gate, |
| bool | get_successors, | ||
| std::unordered_map< u32, std::vector< Gate * >> & | cache | ||
| ) |
| [in] | gate | - The initial gate. |
| [in] | get_successors | - If true, sequential successors are returned, otherwise sequential predecessors are returned. |
| [in,out] | cache | - The cache. |
Definition at line 453 of file netlist_utils.cpp.
References hal::Gate::get_fan_in_nets(), and hal::Gate::get_fan_out_nets().
Referenced by get_ff_dependency_matrix(), get_next_sequential_gates(), and hal::netlist_utils_init().
| std::vector< Gate * > hal::netlist_utils::get_next_sequential_gates | ( | const Net * | net, |
| bool | get_successors | ||
| ) |
| [in] | net | - The initial net. |
| [in] | get_successors | - If true, sequential successors are returned, otherwise sequential predecessors are returned. |
Definition at line 480 of file netlist_utils.cpp.
References get_next_sequential_gates(), and net.
| std::vector< Gate * > hal::netlist_utils::get_next_sequential_gates | ( | const Net * | net, |
| bool | get_successors, | ||
| std::unordered_map< u32, std::vector< Gate * >> & | cache | ||
| ) |
| [in] | net | - The initial net. |
| [in] | get_successors | - If true, sequential successors are returned, otherwise sequential predecessors are returned. |
| [in,out] | cache | - The cache. |
Definition at line 468 of file netlist_utils.cpp.
References net.
| std::unique_ptr< Netlist > hal::netlist_utils::get_partial_netlist | ( | const Netlist * | nl, |
| const std::vector< const Gate * > & | subgraph_gates | ||
| ) |
| [in] | nl | - The netlist consisting of the subgraph. |
| [in] | subgraph_gates | - The gates the subgraph is supposed to consist of. |
Definition at line 232 of file netlist_utils.cpp.
References hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), and log_error.
Referenced by hal::verilator::VerilatorEngine::setSimulationInput().
| std::vector< Gate * > hal::netlist_utils::get_path | ( | const Gate * | gate, |
| bool | get_successors, | ||
| std::set< GateTypeProperty > | stop_properties | ||
| ) |
Find all gates on the predeccessor or successor path of a gate. Traverses all input or output nets until gates of the specified base types are found. The result may include the provided gate itself.
| [in] | gate | - The initial gate. |
| [in] | get_successors | - If true, the successor path is returned, otherwise the predecessor path is returned. |
| [in] | stop_properties | - Stop recursion when reaching a gate of a type with one of the specified properties. |
Definition at line 559 of file netlist_utils.cpp.
References get_path().
| std::vector< Gate * > hal::netlist_utils::get_path | ( | const Gate * | gate, |
| bool | get_successors, | ||
| std::set< GateTypeProperty > | stop_properties, | ||
| std::unordered_map< u32, std::vector< Gate * >> & | cache | ||
| ) |
Find all gates on the predecessor or successor path of a gate. Traverses all input or output nets until gates of the specified base types are found. The result may include the provided gate itself. The use of the this cached version is recommended in case of extensive usage to improve performance. The cache will be filled by this function and should initially be provided empty. Different caches for different values of get_successors shall be used.
| [in] | gate | - The initial gate. |
| [in] | get_successors | - If true, the successor path is returned, otherwise the predecessor path is returned. |
| [in] | stop_properties | - Stop recursion when reaching a gate of a type with one of the specified properties. |
| [in,out] | cache | - The cache. |
Definition at line 538 of file netlist_utils.cpp.
References hal::Gate::get_fan_in_nets(), and hal::Gate::get_fan_out_nets().
Referenced by get_path(), and hal::netlist_utils_init().
| std::vector< Gate * > hal::netlist_utils::get_path | ( | const Net * | net, |
| bool | get_successors, | ||
| std::set< GateTypeProperty > | stop_properties | ||
| ) |
Find all gates on the predecessor or successor path of a net. Traverses all input or output nets until gates of the specified base types are found.
| [in] | net | - The initial net. |
| [in] | get_successors | - If true, the successor path is returned, otherwise the predecessor path is returned. |
| [in] | stop_properties | - Stop recursion when reaching a gate of a type with one of the specified properties. |
Definition at line 565 of file netlist_utils.cpp.
References get_path(), and net.
| std::vector< Gate * > hal::netlist_utils::get_path | ( | const Net * | net, |
| bool | get_successors, | ||
| std::set< GateTypeProperty > | stop_properties, | ||
| std::unordered_map< u32, std::vector< Gate * >> & | cache | ||
| ) |
Find all gates on the predecessor or successor path of a net. Traverses all input or output nets until gates of the specified base types are found. The use of the this cached version is recommended in case of extensive usage to improve performance. The cache will be filled by this function and should initially be provided empty. Different caches for different values of get_successors shall be used.
| [in] | net | - The initial net. |
| [in] | get_successors | - If true, the successor path is returned, otherwise the predecessor path is returned. |
| [in] | stop_properties | - Stop recursion when reaching a gate of a type with one of the specified properties. |
| [in,out] | cache | - The cache. |
Definition at line 553 of file netlist_utils.cpp.
References net.
| std::vector< Gate * > hal::netlist_utils::get_shortest_path | ( | Gate * | start_gate, |
| Gate * | end_gate, | ||
| bool | search_both_directions = false |
||
| ) |
Find the shortest path (i.e., the result set with the lowest number of gates) that connects the start gate with the end gate. The gate where the search started from will be the first in the result vector, the end gate will be the last. If there is no such path an empty vector is returned. If there is more than one path with the same length only the first one is returned.
| [in] | start_gate | - The gate to start from. |
| [in] | end_gate | - The gate to connect to. |
| [in] | search_both_directions | - true to additionally check whether a shorter path from end to start exists, false otherwise. |
Definition at line 394 of file netlist_utils.cpp.
Referenced by hal::GraphGraphicsView::handleShortestPathToGrouping(), hal::GuiApiClasses::View::isolateModuleToModulePathInNewView(), and hal::netlist_utils_init().
| std::vector< Gate * > hal::netlist_utils::get_shortest_path | ( | Gate * | start_gate, |
| Module * | end_module, | ||
| bool | forward_direction | ||
| ) |
Find the shortest path (i.e., the result set with the lowest number of gates) that connects the start gate with any gate from the given module. The gate where the search started from will be the first in the result vector, the end gate will be the last. If there is no such path an empty vector is returned. If there is more than one path with the same length only the first one is returned.
| [in] | start_gate | - The gate to start from. |
| [in] | end_module | - The module to connect to. |
| [in] | forward_direction | - true to search along the fan-out nets of the start gate, false to search along its fan-in nets. |
Definition at line 350 of file netlist_utils.cpp.
References hal::Module::get_gates().
| std::vector< std::vector< Gate * > > hal::netlist_utils::get_shortest_path | ( | Module * | start_module, |
| Module * | end_module | ||
| ) |
Find the shortest path (i.e., the result set with the lowest number of gates) that connects the start module with the target module. There might be more than one connection thus a vector of connecting gate vectors is returned. In each connecting gate vector gate where the search started from will be the first, the end gate will be the last. If there is no such path an empty vector is returned. If there is more than one path with the same length only the first one is returned.
| [in] | start_module | - The module to start from. |
| [in] | end_module | - The module to connect to. |
Definition at line 361 of file netlist_utils.cpp.
References hal::Module::get_gates().
| Result< BooleanFunction > hal::netlist_utils::get_subgraph_function | ( | const Net * | net, |
| const std::vector< const Gate * > & | subgraph_gates | ||
| ) |
| [in] | net | - The net for which to generate the Boolean function. |
| [in] | subgraph_gates | - The gates making up the subgraph to consider. |
Definition at line 161 of file netlist_utils.cpp.
References ERR, get_subgraph_function(), and net.
| Result< BooleanFunction > hal::netlist_utils::get_subgraph_function | ( | const Net * | net, |
| const std::vector< const Gate * > & | subgraph_gates, | ||
| std::map< std::pair< u32, const GatePin * >, BooleanFunction > & | cache | ||
| ) |
| [in] | net | - The net for which to generate the Boolean function. |
| [in] | subgraph_gates | - The gates making up the subgraph to consider. |
| [in,out] | cache | - Cache to speed up computations. The cache is filled by this function. |
Definition at line 144 of file netlist_utils.cpp.
References ERR, hal::SubgraphNetlistDecorator::get_subgraph_function(), and net.
Referenced by get_subgraph_function(), and hal::netlist_utils_init().
| [in] | netlist | - The target netlist. |
| [in] | analyze_inputs | - Set true to dynamically analyze the inputs, false otherwise. |
Definition at line 611 of file netlist_utils.cpp.
References hal::Net::add_destination(), hal::combinational, hal::BooleanFunction::Const(), hal::Netlist::delete_gate(), hal::Netlist::delete_net(), ERR, hal::Gate::get_boolean_functions(), hal::Net::get_destinations(), hal::Gate::get_fan_in_endpoints(), hal::Gate::get_fan_out_endpoints(), hal::Netlist::get_gates(), hal::Netlist::get_gnd_gates(), hal::Gate::get_id(), hal::Net::get_id(), hal::Netlist::get_id(), hal::GateType::get_input_pin_names(), hal::Gate::get_name(), hal::Net::get_name(), hal::BasePin< T >::get_name(), hal::Endpoint::get_net(), hal::Endpoint::get_pin(), hal::Gate::get_type(), hal::Netlist::get_vcc_gates(), hal::ground, hal::GateType::has_property(), OK, hal::power, hal::Net::remove_destination(), hal::BooleanFunction::simplify(), hal::BooleanFunction::substitute(), and hal::BooleanFunction::to_string().
Referenced by hal::netlist_utils_init().
| [in] | netlist | - The target netlist. |
Definition at line 800 of file netlist_utils.cpp.
References hal::Net::add_destination(), ERR, hal::Gate::get_boolean_functions(), hal::Gate::get_fan_in_endpoints(), hal::Netlist::get_gates(), hal::Netlist::get_gnd_gates(), hal::Gate::get_id(), hal::Netlist::get_id(), hal::Gate::get_name(), and OK.
Referenced by hal::netlist_utils_init().
| Result< std::monostate > hal::netlist_utils::replace_gate | ( | Gate * | gate, |
| GateType * | target_type, | ||
| std::map< GatePin *, GatePin * > | pin_map | ||
| ) |
| [in] | gate | - The gate to be replaced. |
| [in] | target_type | - The gate type of the replacement gate. |
| [in] | pin_map | - A map from old to new pins. |
Definition at line 897 of file netlist_utils.cpp.
References ERR, hal::Gate::get_netlist(), OK, and hal::NetlistModificationDecorator::replace_gate().
Referenced by hal::netlist_utils_init().