HAL  v4.5.0-258-gf372a0264
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::SubgraphNetlistDecorator Class Reference

#include <hal_core/netlist/decorators/subgraph_netlist_decorator.h>

Collaboration diagram for hal::SubgraphNetlistDecorator:
Collaboration graph

Public Member Functions

 SubgraphNetlistDecorator (const Netlist &netlist)
 
Result< std::unique_ptr< Netlist > > copy_subgraph_netlist (const std::vector< const Gate * > &subgraph_gates, const bool all_global_io=false) const
 
Result< std::unique_ptr< Netlist > > copy_subgraph_netlist (const std::vector< Gate * > &subgraph_gates, const bool all_global_io=false) const
 
Result< std::unique_ptr< Netlist > > copy_subgraph_netlist (const Module *subgraph_module, const bool all_global_io=false) const
 
Result< BooleanFunction > get_subgraph_function (const std::vector< const Gate * > &subgraph_gates, const Net *subgraph_output) const
 
Result< BooleanFunction > get_subgraph_function (const std::vector< Gate * > &subgraph_gates, const Net *subgraph_output) const
 
Result< BooleanFunction > get_subgraph_function (const Module *subgraph_module, const Net *subgraph_output) const
 
Result< SubgraphFunctionCache > make_subgraph_function_cache (const std::vector< const Gate * > &subgraph_gates) const
 
Result< SubgraphFunctionCache > make_subgraph_function_cache (const std::vector< Gate * > &subgraph_gates) const
 
Result< SubgraphFunctionCache > make_subgraph_function_cache (const Module *subgraph_module) const
 
Result< BooleanFunction > get_subgraph_function (const Net *subgraph_output, SubgraphFunctionCache &cache) const
 
Result< std::set< const Net * > > get_subgraph_function_inputs (const std::vector< const Gate * > &subgraph_gates, const Net *subgraph_output) const
 
Result< std::set< const Net * > > get_subgraph_function_inputs (const std::vector< Gate * > &subgraph_gates, const Net *subgraph_output) const
 
Result< std::set< const Net * > > get_subgraph_function_inputs (const Module *subgraph_module, const Net *subgraph_output) const
 
Result< std::set< const Net * > > get_subgraph_function_inputs (const Net *subgraph_output, SubgraphFunctionCache &cache) const
 

Detailed Description

A netlist decorator that operates on an existing subgraph of the associated netlist to, e.g., copy the subgraph as a new netlist object or compute a Boolean function describing the subgraph.

Definition at line 41 of file subgraph_netlist_decorator.h.

Constructor & Destructor Documentation

◆ SubgraphNetlistDecorator()

hal::SubgraphNetlistDecorator::SubgraphNetlistDecorator ( const Netlist &  netlist)

Construct new SubgraphNetlistDecorator object.

Parameters
[in]netlist- The netlist to operate on.

Definition at line 14 of file subgraph_netlist_decorator.cpp.

Member Function Documentation

◆ copy_subgraph_netlist() [1/3]

Result< std::unique_ptr< Netlist > > hal::SubgraphNetlistDecorator::copy_subgraph_netlist ( const Module *  subgraph_module,
const bool  all_global_io = false 
) const

Get a deep copy of a netlist subgraph including all of its gates and nets, but excluding modules and groupings.

Parameters
[in]subgraph_module- The module making up the subgraph that shall be copied from the netlist, including the gates of all of its submodules.
[in]all_global_io- Set true to mark all nets as global input or output that lost at least one source or destination in the copied netlist, false to only mark them if all sources or destinations were removed. Global inputs and outputs of the parent netlist will always also be annotated as global inputs or outputs. Defaults to false.
Returns
The copied subgraph netlist on success, an error otherwise.

Definition at line 185 of file subgraph_netlist_decorator.cpp.

References copy_subgraph_netlist(), ERR, and hal::Module::get_gates().

◆ copy_subgraph_netlist() [2/3]

Result< std::unique_ptr< Netlist > > hal::SubgraphNetlistDecorator::copy_subgraph_netlist ( const std::vector< const Gate * > &  subgraph_gates,
const bool  all_global_io = false 
) const

Get a deep copy of a netlist subgraph including all of its gates and nets, but excluding modules and groupings.

Parameters
[in]subgraph_gates- The gates making up the subgraph that shall be copied from the netlist.
[in]all_global_io- Set true to mark all nets as global input or output that lost at least one source or destination in the copied netlist, false to only mark them if all sources or destinations were removed. Global inputs and outputs of the parent netlist will always also be annotated as global inputs or outputs. Defaults to false.
Returns
The copied subgraph netlist on success, an error otherwise.

Definition at line 18 of file subgraph_netlist_decorator.cpp.

References hal::Gate::add_boolean_function(), hal::netlist_factory::create_netlist(), hal::Module::create_pin(), ERR_APPEND, hal::Netlist::get_design_name(), hal::Netlist::get_device_name(), hal::Netlist::get_free_gate_ids(), hal::Netlist::get_free_grouping_ids(), hal::Netlist::get_free_module_ids(), hal::Netlist::get_free_net_ids(), hal::Netlist::get_gate_library(), hal::Netlist::get_gates(), hal::Netlist::get_input_filename(), hal::Module::get_input_nets(), hal::Netlist::get_net_by_id(), hal::Netlist::get_next_gate_id(), hal::Netlist::get_next_grouping_id(), hal::Netlist::get_next_module_id(), hal::Netlist::get_next_net_id(), hal::Module::get_output_nets(), hal::Netlist::get_used_gate_ids(), hal::Netlist::get_used_grouping_ids(), hal::Netlist::get_used_module_ids(), hal::Netlist::get_used_net_ids(), hal::Net::mark_global_input_net(), name, net, OK, hal::DataContainer::set_data_map(), hal::DataContainer::set_parameter(), and hal::Module::update_nets().

Referenced by copy_subgraph_netlist(), and hal::netlist_utils::get_partial_netlist().

◆ copy_subgraph_netlist() [3/3]

Result< std::unique_ptr< Netlist > > hal::SubgraphNetlistDecorator::copy_subgraph_netlist ( const std::vector< Gate * > &  subgraph_gates,
const bool  all_global_io = false 
) const

Get a deep copy of a netlist subgraph including all of its gates and nets, but excluding modules and groupings.

Parameters
[in]subgraph_gates- The gates making up the subgraph that shall be copied from the netlist.
[in]all_global_io- Set true to mark all nets as global input or output that lost at least one source or destination in the copied netlist, false to only mark them if all sources or destinations were removed. Global inputs and outputs of the parent netlist will always also be annotated as global inputs or outputs. Defaults to false.
Returns
The copied subgraph netlist on success, an error otherwise.

Definition at line 172 of file subgraph_netlist_decorator.cpp.

References copy_subgraph_netlist(), and ERR.

◆ get_subgraph_function() [1/4]

Result< BooleanFunction > hal::SubgraphNetlistDecorator::get_subgraph_function ( const Module *  subgraph_module,
const Net *  subgraph_output 
) const

Get the combined Boolean function of a subgraph starting at the source of the provided subgraph output net. The function is composed backwards through the gates of the subgraph. A gate is composed into it only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes a variable of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph_module. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. The variables of the resulting Boolean function are created from the subgraph input nets using BooleanFunctionNetDecorator::get_boolean_variable. For repeated calls on the same subgraph, create a cache with make_subgraph_function_cache and pass it to get_subgraph_function instead.

Parameters
[in]subgraph_module- The module making up the subgraph to consider, including the gates of all of its submodules.
[in]subgraph_output- The subgraph output net for which to generate the Boolean function.
Returns
The combined Boolean function of the subgraph on success, an error otherwise.

Definition at line 572 of file subgraph_netlist_decorator.cpp.

References ERR, hal::Module::get_gates(), and get_subgraph_function().

◆ get_subgraph_function() [2/4]

Result< BooleanFunction > hal::SubgraphNetlistDecorator::get_subgraph_function ( const Net *  subgraph_output,
SubgraphFunctionCache &  cache 
) const

Get the combined Boolean function of the subgraph of the cache starting at the source of the provided subgraph output net. The function is composed backwards through the gates of the subgraph. A gate is composed into it only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes a variable of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph of the cache. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. The variables of the resulting Boolean function are created from the subgraph input nets using BooleanFunctionNetDecorator::get_boolean_variable. The Boolean functions computed for the gate outputs of the subgraph are stored in the cache, and those stored by earlier calls are reused instead of being computed again. The cache must have been created for the netlist of this decorator.

Parameters
[in]subgraph_output- The subgraph output net for which to generate the Boolean function.
[in,out]cache- The cache holding the subgraph and the Boolean functions computed for it.
Returns
The combined Boolean function of the subgraph on success, an error otherwise.

Definition at line 610 of file subgraph_netlist_decorator.cpp.

References ERR, hal::Net::get_id(), and hal::Net::get_name().

◆ get_subgraph_function() [3/4]

Result< BooleanFunction > hal::SubgraphNetlistDecorator::get_subgraph_function ( const std::vector< const Gate * > &  subgraph_gates,
const Net *  subgraph_output 
) const

Get the combined Boolean function of a subgraph starting at the source of the provided subgraph output net. The function is composed backwards through the gates of the subgraph. A gate is composed into it only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes a variable of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph_gates. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. The variables of the resulting Boolean function are created from the subgraph input nets using BooleanFunctionNetDecorator::get_boolean_variable. For repeated calls on the same subgraph, create a cache with make_subgraph_function_cache and pass it to get_subgraph_function instead.

Parameters
[in]subgraph_gates- The gates making up the subgraph to consider.
[in]subgraph_output- The subgraph output net for which to generate the Boolean function.
Returns
The combined Boolean function of the subgraph on success, an error otherwise.

Definition at line 549 of file subgraph_netlist_decorator.cpp.

References ERR, ERR_APPEND, hal::Net::get_id(), hal::Net::get_name(), and make_subgraph_function_cache().

Referenced by hal::netlist_utils::get_subgraph_function(), and get_subgraph_function().

◆ get_subgraph_function() [4/4]

Result< BooleanFunction > hal::SubgraphNetlistDecorator::get_subgraph_function ( const std::vector< Gate * > &  subgraph_gates,
const Net *  subgraph_output 
) const

Get the combined Boolean function of a subgraph starting at the source of the provided subgraph output net. The function is composed backwards through the gates of the subgraph. A gate is composed into it only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes a variable of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph_gates. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. The variables of the resulting Boolean function are created from the subgraph input nets using BooleanFunctionNetDecorator::get_boolean_variable. For repeated calls on the same subgraph, create a cache with make_subgraph_function_cache and pass it to get_subgraph_function instead.

Parameters
[in]subgraph_gates- The gates making up the subgraph to consider.
[in]subgraph_output- The subgraph output net for which to generate the Boolean function.
Returns
The combined Boolean function of the subgraph on success, an error otherwise.

Definition at line 566 of file subgraph_netlist_decorator.cpp.

References get_subgraph_function().

◆ get_subgraph_function_inputs() [1/4]

Result< std::set< const Net * > > hal::SubgraphNetlistDecorator::get_subgraph_function_inputs ( const Module *  subgraph_module,
const Net *  subgraph_output 
) const

Get the inputs of the combined Boolean function of a subgraph starting at the source of the provided subgraph output net. This does not actually build the Boolean function but only determines the inputs the subgraph function would have, which is a lot faster. The subgraph is traversed backwards through its gates. A gate is traversed only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes an input of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph_module. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. For repeated calls on the same subgraph, create a cache with make_subgraph_function_cache and pass it to get_subgraph_function_inputs instead.

Parameters
[in]subgraph_module- The module making up the subgraph to consider, including the gates of all of its submodules.
[in]subgraph_output- The subgraph output net from which to start the back propagation.
Returns
The input nets that would be the input for the subgraph function on success, an error otherwise.

Definition at line 649 of file subgraph_netlist_decorator.cpp.

References ERR, hal::Module::get_gates(), and get_subgraph_function_inputs().

◆ get_subgraph_function_inputs() [2/4]

Result< std::set< const Net * > > hal::SubgraphNetlistDecorator::get_subgraph_function_inputs ( const Net *  subgraph_output,
SubgraphFunctionCache &  cache 
) const

Get the inputs of the combined Boolean function of the subgraph of the cache starting at the source of the provided subgraph output net. This does not actually build the Boolean function but only determines the inputs the subgraph function would have, which is a lot faster. The subgraph is traversed backwards through its gates. A gate is traversed only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes an input of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph of the cache. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. The inputs determined for the gate outputs of the subgraph are stored in the cache, and those stored by earlier calls are reused instead of being determined again. The cache must have been created for the netlist of this decorator.

Parameters
[in]subgraph_output- The subgraph output net from which to start the back propagation.
[in,out]cache- The cache holding the subgraph and the inputs determined for it.
Returns
The input nets that would be the input for the subgraph function on success, an error otherwise.

Definition at line 659 of file subgraph_netlist_decorator.cpp.

References ERR, hal::Net::get_id(), and hal::Net::get_name().

◆ get_subgraph_function_inputs() [3/4]

Result< std::set< const Net * > > hal::SubgraphNetlistDecorator::get_subgraph_function_inputs ( const std::vector< const Gate * > &  subgraph_gates,
const Net *  subgraph_output 
) const

Get the inputs of the combined Boolean function of a subgraph starting at the source of the provided subgraph output net. This does not actually build the Boolean function but only determines the inputs the subgraph function would have, which is a lot faster. The subgraph is traversed backwards through its gates. A gate is traversed only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes an input of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph_gates. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. For repeated calls on the same subgraph, create a cache with make_subgraph_function_cache and pass it to get_subgraph_function_inputs instead.

Parameters
[in]subgraph_gates- The gates making up the subgraph to consider.
[in]subgraph_output- The subgraph output net from which to start the back propagation.
Returns
The input nets that would be the input for the subgraph function on success, an error otherwise.

Definition at line 626 of file subgraph_netlist_decorator.cpp.

References ERR, ERR_APPEND, hal::Net::get_id(), hal::Net::get_name(), and make_subgraph_function_cache().

Referenced by get_subgraph_function_inputs().

◆ get_subgraph_function_inputs() [4/4]

Result< std::set< const Net * > > hal::SubgraphNetlistDecorator::get_subgraph_function_inputs ( const std::vector< Gate * > &  subgraph_gates,
const Net *  subgraph_output 
) const

Get the inputs of the combined Boolean function of a subgraph starting at the source of the provided subgraph output net. This does not actually build the Boolean function but only determines the inputs the subgraph function would have, which is a lot faster. The subgraph is traversed backwards through its gates. A gate is traversed only if its gate type is combinational and it has a Boolean function for the output pin that the walk reaches it through. At any other gate, at a gate outside of the subgraph, at a net without a source, and at a global input net, the walk stops and the net becomes an input of the function. Hence, flip-flops, memories, and gates without a Boolean function bound the subgraph function even if they are part of the subgraph_gates. If the Boolean function of a gate cannot be built in terms of nets, e.g., because one of its input pins has no net or a gate parameter it depends on has no value, a warning is logged and the walk stops at that gate as well. For repeated calls on the same subgraph, create a cache with make_subgraph_function_cache and pass it to get_subgraph_function_inputs instead.

Parameters
[in]subgraph_gates- The gates making up the subgraph to consider.
[in]subgraph_output- The subgraph output net from which to start the back propagation.
Returns
The input nets that would be the input for the subgraph function on success, an error otherwise.

Definition at line 643 of file subgraph_netlist_decorator.cpp.

References get_subgraph_function_inputs().

◆ make_subgraph_function_cache() [1/3]

Result< SubgraphFunctionCache > hal::SubgraphNetlistDecorator::make_subgraph_function_cache ( const Module *  subgraph_module) const

Create a cache for one specific subgraph, to be passed to get_subgraph_function or get_subgraph_function_inputs in place of the subgraph. The cache shares the Boolean functions and inputs computed for the gate outputs of the subgraph across calls, so that logic which several subgraph output nets have in common is traversed only once. The cache belongs to the netlist of this decorator and must be dropped when the netlist is modified.

Parameters
[in]subgraph_module- The module making up the subgraph to consider, including the gates of all of its submodules.
Returns
The cache on success, an error otherwise.

Definition at line 600 of file subgraph_netlist_decorator.cpp.

References ERR, hal::Module::get_gates(), and make_subgraph_function_cache().

◆ make_subgraph_function_cache() [2/3]

Result< SubgraphFunctionCache > hal::SubgraphNetlistDecorator::make_subgraph_function_cache ( const std::vector< const Gate * > &  subgraph_gates) const

Create a cache for one specific subgraph, to be passed to get_subgraph_function or get_subgraph_function_inputs in place of the subgraph. The cache shares the Boolean functions and inputs computed for the gate outputs of the subgraph across calls, so that logic which several subgraph output nets have in common is traversed only once. The cache belongs to the netlist of this decorator and must be dropped when the netlist is modified.

Parameters
[in]subgraph_gates- The gates making up the subgraph to consider.
Returns
The cache on success, an error otherwise.

Definition at line 582 of file subgraph_netlist_decorator.cpp.

References ERR_APPEND, hal::Netlist::get_global_input_nets(), and OK.

Referenced by get_subgraph_function(), get_subgraph_function_inputs(), and make_subgraph_function_cache().

◆ make_subgraph_function_cache() [3/3]

Result< SubgraphFunctionCache > hal::SubgraphNetlistDecorator::make_subgraph_function_cache ( const std::vector< Gate * > &  subgraph_gates) const

Create a cache for one specific subgraph, to be passed to get_subgraph_function or get_subgraph_function_inputs in place of the subgraph. The cache shares the Boolean functions and inputs computed for the gate outputs of the subgraph across calls, so that logic which several subgraph output nets have in common is traversed only once. The cache belongs to the netlist of this decorator and must be dropped when the netlist is modified.

Parameters
[in]subgraph_gates- The gates making up the subgraph to consider.
Returns
The cache on success, an error otherwise.

Definition at line 594 of file subgraph_netlist_decorator.cpp.

References make_subgraph_function_cache().


The documentation for this class was generated from the following files: