Netlist Traversal Decorator
- class hal_py.NetlistTraversalDecorator
A netlist decorator that provides functionality to traverse the associated netlist without making any modifications.
- __init__(self: hal_py.NetlistTraversalDecorator, netlist: hal_py.Netlist) None
Construct new NetlistTraversalDecorator object.
- Parameters
netlist (hal_py.Netlist) – The netlist to operate on.
- get_next_combinational_gates(*args, **kwargs)
Overloaded function.
get_next_combinational_gates(self: hal_py.NetlistTraversalDecorator, net: hal_py.Net, successors: bool, forbidden_pins: Set[hal_py.PinType]) -> Optional[Set[hal_py.Gate]]
Starting from the given net, traverse the netlist and return all combinational successor/predecessor gates. Continue traversal as long as further combinational gates are found and stop at gates that are not combinational. All combinational gates found during traversal are added to the result. Forbidden pins can be provided to, e.g., avoid the inclusion of logic in front of flip-flop control inputs.
- param hal_py.Net net
Start net.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param set[hal_py.PinType] forbidden_pins
Netlist traversal stops at these pins.
- returns
The next combinational gates on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
get_next_combinational_gates(self: hal_py.NetlistTraversalDecorator, gate: hal_py.Gate, successors: bool, forbidden_pins: Set[hal_py.PinType]) -> Optional[Set[hal_py.Gate]]
Starting from the given gate, traverse the netlist and return all combinational successor/predecessor gates. Continue traversal as long as further combinational gates are found and stop at gates that are not combinational. All combinational gates found during traversal are added to the result. Forbidden pins can be provided to, e.g., avoid the inclusion of logic in front of flip-flop control inputs.
- param hal_py.Gate gate
Start gate.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param set[hal_py.PinType] forbidden_pins
Netlist traversal stops at these pins.
- returns
The next combinational gates on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
- get_next_matching_gates(*args, **kwargs)
Overloaded function.
get_next_matching_gates(self: hal_py.NetlistTraversalDecorator, net: hal_py.Net, successors: bool, target_gate_filter: Callable[[hal_py.Gate], bool], continue_on_match: bool = False, exit_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None, entry_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None) -> Optional[Set[hal_py.Gate]]
Starting from the given net, traverse the netlist and return only the successor/predecessor gates for which the
target_gate_filter
evaluates toTrue
. Traverse over gates that do not meet thetarget_gate_filter
condition. Stop traversal if (1)continue_on_match
isFalse
thetarget_gate_filter
evaluates toTrue
, (2) theexit_endpoint_filter
evaluates toFalse
on a fan-in/out endpoint (i.e., when exiting the current gate during traversal), or (3) theentry_endpoint_filter
evaluates toFalse
on a successor/predecessor endpoint (i.e., when entering the next gate during traversal). Both theentry_endpoint_filter
and theexit_endpoint_filter
may be omitted.- param hal_py.Net net
Start net.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param lambda target_gate_filter
Filter condition that must be met for the target gates.
- param bool continue_on_match
Set
True
to continue even iftarget_gate_filter
evaluated toTrue
,False
otherwise. Defaults toFalse
.- param lambda exit_endpoint_filter
Filter condition that determines whether to stop traversal on a fan-in/out endpoint.
- param lambda entry_endpoint_filter
Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
- returns
The next gates fulfilling the target gate filter condition on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
get_next_matching_gates(self: hal_py.NetlistTraversalDecorator, gate: hal_py.Gate, successors: bool, target_gate_filter: Callable[[hal_py.Gate], bool], continue_on_match: bool = False, exit_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None, entry_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None) -> Optional[Set[hal_py.Gate]]
Starting from the given gate, traverse the netlist and return only the successor/predecessor gates for which the
target_gate_filter
evaluates toTrue
. Traverse over gates that do not meet thetarget_gate_filter
condition. Stop traversal if (1)continue_on_match
isFalse
thetarget_gate_filter
evaluates toTrue
, (2) theexit_endpoint_filter
evaluates toFalse
on a fan-in/out endpoint (i.e., when exiting the current gate during traversal), or (3) theentry_endpoint_filter
evaluates toFalse
on a successor/predecessor endpoint (i.e., when entering the next gate during traversal). Both theentry_endpoint_filter
and theexit_endpoint_filter
may be omitted.- param hal_py.Gate gate
Start gate.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param lambda target_gate_filter
Filter condition that must be met for the target gates.
- param bool continue_on_match
Set
True
to continue even iftarget_gate_filter
evaluated toTrue
,False
otherwise. Defaults toFalse
.- param lambda exit_endpoint_filter
Filter condition that determines whether to stop traversal on a fan-in/out endpoint.
- param lambda entry_endpoint_filter
Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
- returns
The next gates fulfilling the target gate filter condition on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
- get_next_matching_gates_until(*args, **kwargs)
Overloaded function.
get_next_matching_gates_until(self: hal_py.NetlistTraversalDecorator, net: hal_py.Net, successors: bool, target_gate_filter: Callable[[hal_py.Gate], bool], continue_on_mismatch: bool = False, exit_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None, entry_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None) -> Optional[Set[hal_py.Gate]]
Starting from the given net, traverse the netlist and return only the successor/predecessor gates for which the
target_gate_filter
evaluates toTrue
. Continue traversal independent of whatevertarget_gate_filter
evaluates to. Stop traversal if (1)continue_on_mismatch
isFalse
thetarget_gate_filter
evaluates toFalse
, (2) theexit_endpoint_filter
evaluates toFalse
on a fan-in/out endpoint (i.e., when exiting the current gate during traversal), or (3) theentry_endpoint_filter
evaluates toFalse
on a successor/predecessor endpoint (i.e., when entering the next gate during traversal). Bothentry_endpoint_filter
and theexit_endpoint_filter
may be omitted.- param hal_py.Net net
Start net.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param lambda target_gate_filter
Filter condition that must be met for the target gates.
- param bool continue_on_mismatch
Set
True
to continue even iftarget_gate_filter
evaluated toFalse
,False
otherwise. Defaults toFalse
.- param lambda exit_endpoint_filter
Filter condition that determines whether to stop traversal on a fan-in/out endpoint.
- param lambda entry_endpoint_filter
Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
- returns
The next gates fulfilling the target gate filter condition on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
get_next_matching_gates_until(self: hal_py.NetlistTraversalDecorator, gate: hal_py.Gate, successors: bool, target_gate_filter: Callable[[hal_py.Gate], bool], continue_on_mismatch: bool = False, exit_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None, entry_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None) -> Optional[Set[hal_py.Gate]]
Starting from the given gate, traverse the netlist and return only the successor/predecessor gates for which the
target_gate_filter
evaluates toTrue
. Continue traversal independent of whatevertarget_gate_filter
evaluates to. Stop traversal if (1)continue_on_mismatch
isFalse
thetarget_gate_filter
evaluates toFalse
, (2) theexit_endpoint_filter
evaluates toFalse
on a fan-in/out endpoint (i.e., when exiting the current gate during traversal), or (3) theentry_endpoint_filter
evaluates toFalse
on a successor/predecessor endpoint (i.e., when entering the next gate during traversal). Bothentry_endpoint_filter
and theexit_endpoint_filter
may be omitted.- param hal_py.Gate gate
Start gate.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param lambda target_gate_filter
Filter condition that must be met for the target gates.
- param bool continue_on_mismatch
Set
True
to continue even iftarget_gate_filter
evaluated toFalse
,False
otherwise. Defaults toFalse
.- param lambda exit_endpoint_filter
Filter condition that determines whether to stop traversal on a fan-in/out endpoint.
- param lambda entry_endpoint_filter
Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
- returns
The next gates fulfilling the target gate filter condition on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
- get_next_matching_gates_until_depth(*args, **kwargs)
Overloaded function.
get_next_matching_gates_until_depth(self: hal_py.NetlistTraversalDecorator, net: hal_py.Net, successors: bool, max_depth: int, target_gate_filter: Callable[[hal_py.Gate], bool] = None) -> Optional[Set[hal_py.Gate]]
Starting from the given net, traverse the netlist and return only the successor/predecessor gates for which the
target_gate_filter
evaluates toTrue
. Continue traversal independent of whatevertarget_gate_filter
evaluates to. Stop traversal if the specified depth is reached. The current depth is counted starting at 1 for the destinations of the provided net. For amax_depth
of0
, all gates between the start net and the global netlist outputs will be traversed. The target_gate_filter may be omitted in which case all traversed gates will be returned.- param hal_py.Net net
Start net.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param int max_depth
The maximum depth for netlist traversal starting from the start net.
- param lambda target_gate_filter
Filter condition that must be met for the target gates.
- returns
The next gates fulfilling the target gate filter condition on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
get_next_matching_gates_until_depth(self: hal_py.NetlistTraversalDecorator, gate: hal_py.Gate, successors: bool, max_depth: int, target_gate_filter: Callable[[hal_py.Gate], bool] = None) -> Optional[Set[hal_py.Gate]]
Starting from the given gate, traverse the netlist and return only the successor/predecessor gates for which the
target_gate_filter
evaluates toTrue
. Continue traversal independent of whatevertarget_gate_filter
evaluates to. Stop traversal if the specified depth is reached. The current depth is counted starting at 1 for the direct successors/predecessors of the provided gate. For amax_depth
of0
, all gates between the start gate and the global netlist outputs will be traversed. The target_gate_filter may be omitted in which case all traversed gates will be returned.- param hal_py.Gate gate
Start gate.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param int max_depth
The maximum depth for netlist traversal starting from the start gate.
- param lambda target_gate_filter
Filter condition that must be met for the target gates.
- returns
The next gates fulfilling the target gate filter condition on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
- get_next_sequential_gates(*args, **kwargs)
Overloaded function.
get_next_sequential_gates(self: hal_py.NetlistTraversalDecorator, net: hal_py.Net, successors: bool, forbidden_pins: Set[hal_py.PinType]) -> Optional[Set[hal_py.Gate]]
Starting from the given net, traverse the netlist and return only the next layer of sequential successor/predecessor gates. Traverse over gates that are not sequential until a sequential gate is found. Stop traversal at all sequential gates, but only adds those to the result that have not been reached through a pin of one of the forbidden types.
- param hal_py.Net net
Start net.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param set[hal_py.PinType] forbidden_pins
Sequential gates reached through these pins will not be part of the result. Defaults to an empty set.
- returns
The next sequential gates on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
get_next_sequential_gates(self: hal_py.NetlistTraversalDecorator, gate: hal_py.Gate, successors: bool, forbidden_pins: Set[hal_py.PinType]) -> Optional[Set[hal_py.Gate]]
Starting from the given gate, traverse the netlist and return only the next layer of sequential successor/predecessor gates. Traverse over gates that are not sequential until a sequential gate is found. Stop traversal at all sequential gates, but only adds those to the result that have not been reached through a pin of one of the forbidden types.
- param hal_py.Gate gate
Start gate.
- param bool successors
Set
True
to get successors, setFalse
to get predecessors.- param set[hal_py.PinType] forbidden_pins
Sequential gates reached through these pins will not be part of the result.
- returns
The next sequential gates on success,
None
otherwise.- rtype
set[hal_py.Gate] or None
- get_next_sequential_gates_map(self: hal_py.NetlistTraversalDecorator, successors: bool, forbidden_pins: Set[hal_py.PinType]) Optional[Dict[hal_py.Gate, Set[hal_py.Gate]]]
Get the next sequential gates for all sequential gates in the netlist by traversing through remaining logic (e.g., combinational logic). Compute a dict from a sequential gate to all its successors. Stop traversal at all sequential gates, but only adds those to the result that have not been reached through a pin of one of the forbidden types.
- Parameters
successors (bool) – Set
True
to get successors, setFalse
to get predecessors.forbidden_pins (set[hal_py.PinType]) – Sequential gates reached through these pins will not be part of the result.
- Returns
A dict from each sequential gate to all its sequential successors on success,
None
otherwise.- Return type
dict[hal_py.Gate,set[hal_py.Gate]] or None
- get_shortest_path(self: hal_py.NetlistTraversalDecorator, start_gate: hal_py.Gate, end_gate: hal_py.Gate, direction: hal_py.PinDirection, exit_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None, entry_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None) Optional[List[hal_py.Gate]]
Find the shortest path (i.e., the smallest 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 list, the end gate will be the last. If there is no such path,
None
is returned. If there is more than one path with the same length, only the first one is returned.- Parameters
start_gate (hal_py.Gate) – The gate to start from.
end_gate (hal_py.Gate) – The gate to connect to.
direction (hal_py.PinDirection) – The direction to search in. Can be
hal_py.PinDirection.input
,hal_py.PinDirection.output
, orhal_py.PinDirection.inout
to search both directions and return the shorter one.exit_endpoint_filter (lambda) – Filter condition that determines whether to stop traversal on a fan-in/out endpoint.
entry_endpoint_filter (lambda) – Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
- Returns
A list of gates that connect the start with end gate on success,
None
otherwise.- Return type
list[hal_py.Gate] or None
- get_shortest_path_distance(self: hal_py.NetlistTraversalDecorator, start_gate: hal_py.Gate, end_gate: hal_py.Gate, direction: hal_py.PinDirection, exit_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None, entry_endpoint_filter: Callable[[hal_py.Endpoint, int], bool] = None) Optional[int]
Find the length of the shortest path (i.e., the smallest number of gates) that connects the start gate with the end gate. If there is no such path,
None
is returned. Computing only the shortest distance to a gate is faster than computing the shortest path, since it does not have to keep track of the path to reach each gate.- Parameters
start_gate (hal_py.Gate) – The gate to start from.
end_gate (hal_py.Gate) – The gate to connect to.
direction (hal_py.PinDirection) – The direction to search in. Can be
hal_py.PinDirection.input
,hal_py.PinDirection.output
, orhal_py.PinDirection.inout
to search both directions and return the shorter one.exit_endpoint_filter (lambda) – Filter condition that determines whether to stop traversal on a fan-in/out endpoint.
entry_endpoint_filter (lambda) – Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
- Returns
The shortest distance between the start and end gate on success,
None
otherwise.- Return type