|
HAL
v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
Simplifies a netlist before analysis, e.g., by removing unused gates and nets and by resolving redundant logic.
| Result< std::vector< Module * > > hal::netlist_preprocessing::create_multi_bit_gate_modules | ( | Netlist * | nl, |
| const std::map< std::string, std::map< std::string, std::vector< std::string >>> & | concatenated_pin_groups | ||
| ) |
Create modules from large gates like RAMs and DSPs with the option to concatenate multiple gate pin groups into larger consecutive pin groups.
| [in] | nl | - The netlist to operate on. |
| [in] | concatenated_pin_groups | - A map from gate type name to a map from the name of the resulting pin group to the names of the pin groups it is concatenated from. |
Definition at line 2393 of file netlist_preprocessing.cpp.
References hal::Netlist::create_module(), ERR, hal::Netlist::get_gate_library(), hal::GateLibrary::get_gate_type_by_name(), hal::Netlist::get_gates(), hal::GateLibrary::get_name(), hal::Module::get_type(), net, OK, and hal::output.
Referenced by hal::PYBIND11_PLUGIN().
| Result< std::vector< Net * > > hal::netlist_preprocessing::create_nets_at_unconnected_pins | ( | Netlist * | nl | ) |
Create a new net for every unconnected output pin of every gate of the netlist. The new nets are named HAL_UNCONNECTED_<net_id>.
| [in] | nl | - The netlist to operate on. |
Definition at line 2461 of file netlist_preprocessing.cpp.
References hal::Netlist::create_net(), hal::Netlist::get_gates(), OK, and hal::Net::set_name().
Referenced by hal::PYBIND11_PLUGIN().
| Result< u32 > hal::netlist_preprocessing::manual_mux_optimizations | ( | Netlist * | nl, |
| GateLibrary * | mux_inv_gl | ||
| ) |
Apply manually implemented optimizations to the netlist centered around muxes. Currently implemented optimizations include:
| [in] | nl | - The netlist to operate on. |
| [in] | mux_inv_gl | - A gate library only containing mux and inverter gates used for resynthesis. |
Definition at line 1599 of file netlist_preprocessing.cpp.
References ERR, ERR_APPEND, and OK.
Referenced by hal::PYBIND11_PLUGIN().
| Result< std::monostate > hal::netlist_preprocessing::parse_def_file | ( | Netlist * | nl, |
| const std::filesystem::path & | def_file | ||
| ) |
Parses a design exchange format file and extracts the coordinates of a placed design for each component/gate. The extracted coordinates get annotated to the gates.
| [in] | nl | - The netlist to operate on. |
| [in] | def_file | - Path to the def file. |
Definition at line 2330 of file netlist_preprocessing.cpp.
References hal::data, ERR, ERR_APPEND, hal::Netlist::get_gates(), log_info, and OK.
Referenced by hal::PYBIND11_PLUGIN().
Builds for all gate output nets the Boolean function and substitutes all variables connected to vcc/gnd nets with the respective boolean value. If the function simplifies to a boolean constant cut the connection to the nets destinations and directly connect it to vcc/gnd.
| [in] | nl | - The netlist to operate on. |
Definition at line 1637 of file netlist_preprocessing.cpp.
References hal::Net::add_destination(), hal::Netlist::delete_gate(), hal::Netlist::delete_net(), ERR, ERR_APPEND, hal::Netlist::get_gates(), hal::Netlist::get_gnd_gates(), hal::Netlist::get_vcc_gates(), log_debug, log_info, OK, and hal::BooleanFunctionDecorator::substitute_power_ground_nets().
Referenced by hal::PYBIND11_PLUGIN().
Tries to reconstruct a name and index for each flip flop that was part of a multi-bit wire in the verilog code. This is NOT a general netlist reverse engineering algorithm and ONLY works on synthesized netlists with names annotated by the synthesizer. This function mainly focuses netlists synthesized with yosys since yosys names the output wires of the flip flops but not the gate it self. We try to reconstruct name and index for each flip flop based on the name of its output nets.
The reconstructed indexed identifiers get annotated to the flip flop in the gate data container.
| [in] | nl | - The netlist to operate on. |
Definition at line 2108 of file netlist_preprocessing.cpp.
References hal::data, hal::ff, hal::Netlist::get_gates(), hal::neg_state, OK, and hal::state.
Referenced by hal::PYBIND11_PLUGIN().
Tries to reconstruct top module pin groups via indexed pin names. This should really be done by the verilog parser, but this is at the moment not the case.
| [in] | nl | - The netlist to operate on |
Definition at line 2146 of file netlist_preprocessing.cpp.
References hal::Module::create_pin_group(), ERR_APPEND, hal::Module::get_pins(), hal::Netlist::get_top_module(), index, OK, and pins.
Referenced by hal::PYBIND11_PLUGIN().
Removes buffer gates from the netlist and connect their fan-in to their fan-out nets. Considers all combinational gates and takes their inputs into account. For example, a 2-input AND gate with one input being connected to constant 1 will also be removed.
| [in] | nl | - The netlist to operate on. |
Definition at line 94 of file netlist_preprocessing.cpp.
References hal::combinational, hal::NetlistModificationDecorator::connect_nets(), hal::Netlist::delete_gate(), ERR_APPEND, hal::GateType::get_boolean_functions(), hal::Netlist::get_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::BooleanFunction::get_variable_name(), hal::ground, hal::GateType::has_property(), hal::BooleanFunction::is_variable(), log_debug, log_info, log_warning, OK, hal::power, hal::Net::remove_destination(), hal::BooleanFunction::simplify_local(), and hal::BooleanFunctionDecorator::substitute_power_ground_pins().
Referenced by hal::PYBIND11_PLUGIN().
Removes two consecutive inverters and reconnects the input of the first inverter to the output of the second one. If the first inverter has additional successors, only the second inverter is deleted.
| [in] | nl | - The netlist to operate on. |
Definition at line 1749 of file netlist_preprocessing.cpp.
References hal::c_inverter, hal::Netlist::delete_gate(), hal::Netlist::delete_net(), ERR, hal::Netlist::get_gates(), log_warning, and OK.
Referenced by hal::PYBIND11_PLUGIN().
| Result< u32 > hal::netlist_preprocessing::remove_redundant_gates | ( | Netlist * | nl, |
| const std::function< bool(const Gate *)> & | filter = nullptr |
||
| ) |
Removes redundant gates from the netlist, i.e., gates that are functionally equivalent and are connected to the same input nets.
| [in] | nl | - The netlist to operate on. |
| [in] | filter | - Optional filter to fine-tune which gates are being replaced. Default to a nullptr. |
Definition at line 379 of file netlist_preprocessing.cpp.
References hal::SMT::Bitwuzla, hal::SMT::Library, and type.
Referenced by hal::PYBIND11_PLUGIN().
Removes redundant logic trees made up of combinational gates. If two trees compute the exact same function even if implemented with different gates we will disconnect one of the trees and afterwards clean up all dangling gates and nets.
| [in] | nl | - The netlist to operate on. |
Definition at line 886 of file netlist_preprocessing.cpp.
Referenced by hal::PYBIND11_PLUGIN().
Removes redundant sequential feedback loops. Sometimes flip-flops and some of their combinational fan-in form a feedback loop where the flip-flop input depends on its own output. For optimization, some synthesizers create multiple equivalent instances of these feedback loops. To simplify structural analysis, this function removes the redundant flip-flop gate of the loop from the netlist. Other preprocessing functions can then take care of the remaining combination gates of the loop.
| [in] | nl | - The netlist to operate on. |
Definition at line 622 of file netlist_preprocessing.cpp.
Referenced by hal::PYBIND11_PLUGIN().
Removes gates for which all fan-out nets do not have a destination and are not global output nets.
| [in] | nl | - The netlist to operate on. |
Definition at line 1024 of file netlist_preprocessing.cpp.
References hal::Netlist::delete_gate(), hal::Netlist::get_gates(), hal::Netlist::get_id(), log_info, log_warning, and OK.
Referenced by hal::PYBIND11_PLUGIN(), and remove_unconnected_looped().
Calls remove_unconnected_gates / remove_unconnected_nets until there are no further changes.
| [in] | nl | - The netlist to operate on. |
Definition at line 1096 of file netlist_preprocessing.cpp.
References ERR_APPEND, OK, remove_unconnected_gates(), and remove_unconnected_nets().
Referenced by hal::PYBIND11_PLUGIN().
Removes nets who have neither a source, nor a destination.
| [in] | nl | - The netlist to operate on. |
Definition at line 1066 of file netlist_preprocessing.cpp.
References hal::Netlist::delete_net(), hal::Netlist::get_id(), hal::Netlist::get_nets(), log_info, log_warning, and OK.
Referenced by hal::PYBIND11_PLUGIN(), and remove_unconnected_looped().
Removes all LUT fan-in endpoints that do not correspond to a variable within the Boolean function that determines the output of a gate.
| [in] | nl | - The netlist to operate on. |
Definition at line 27 of file netlist_preprocessing.cpp.
References hal::Net::add_destination(), ERR, hal::Netlist::get_gates(), hal::Netlist::get_gnd_gates(), hal::Netlist::get_id(), log_info, log_warning, and OK.
Referenced by hal::PYBIND11_PLUGIN().
Replaces pins connected to GND/VCC with constants and simplifies the Boolean function of a LUT by recomputing the INIT string.
| [in] | nl | - The netlist to operate on. |
Definition at line 1864 of file netlist_preprocessing.cpp.
References hal::BooleanFunction::And(), ERR, ERR_APPEND, hal::Netlist::get_gates(), hal::Netlist::get_id(), log_info, OK, hal::BooleanFunctionDecorator::substitute_power_ground_pins(), and hal::BooleanFunction::Var().
Referenced by hal::PYBIND11_PLUGIN().
| Result< u32 > hal::netlist_preprocessing::unify_ff_outputs | ( | Netlist * | nl, |
| const std::vector< Gate * > & | ffs = {}, |
||
| GateType * | inverter_type = nullptr |
||
| ) |
Iterates all flip-flops of the netlist or specified by the user. If a flip-flop has a state and a neg_state output, a new inverter gate is created and connected to the state output net as an additional destination. Finally, the neg_state output net is disconnected from the neg_state pin and re-connected to the new inverter gate's output.
| [in] | nl | - The netlist to operate on. |
| [in] | ffs | - The flip-flops to operate on. Defaults to an empty vector, in which case all flip-flops of the netlist are considered. |
| [in] | inverter_type | - The inverter gate type to use. Defaults to a nullptr, in which case the first inverter type found in the gate library is used. |
neg_state outputs on success, an error otherwise. Definition at line 2483 of file netlist_preprocessing.cpp.
References hal::Net::add_source(), hal::c_inverter, hal::Netlist::create_gate(), hal::Netlist::create_net(), ERR, hal::ff, hal::GateType::get_gate_library(), hal::Netlist::get_gate_library(), hal::GateLibrary::get_gate_types(), hal::Netlist::get_gates(), hal::GateType::get_input_pins(), hal::GateLibrary::get_name(), hal::GateType::get_name(), hal::GateType::get_output_pins(), hal::GateType::has_property(), hal::neg_state, OK, and hal::state.
Referenced by hal::PYBIND11_PLUGIN().