Walker/Listener#

Walkers#

class systemrdl.walker.RDLSimpleWalker(unroll: bool = False, skip_not_present: bool = True)#

Implements a walker instance that traverses the elaborated RDL instance tree Each node is visited exactly once.

Each node is visited as follows:

  1. Run enter_Component() callback

  2. Run enter_AddressableComponent() or enter_VectorComponent() callback

  3. Run type-specific enter_*() callback, such as enter_Reg()

  4. Traverse any children

  5. Run type-specific exit_*() callback, such as exit_Reg()

  6. Run exit_AddressableComponent() or exit_VectorComponent() callback

  7. Run exit_Component() callback

Parameters:
  • unroll (bool) – If True, any nodes that are arrays are unrolled. When the walker arrives at an array node, it will be visited multiple times according to the array dimensions.

  • skip_not_present (bool) – If True, walker skips nodes whose ‘ispresent’ property is set to False

walk(node: Node, *listeners: RDLListener, skip_top: bool = False) None#

Initiates the walker to traverse the current node and its children. Calls the corresponding callback for each of the listeners provided in the order that they are listed.

Parameters:
  • node (Node) – Node to start traversing. Listener traversal includes this node.

  • listeners (RDLListener) – One or more RDLListener that are invoked during node traversal. Listener callbacks are executed in the same order as provided.

  • skip_top (bool) – Skip callbacks for the top node specified by node

class systemrdl.walker.RDLSteerableWalker(unroll: bool = False, skip_not_present: bool = True)#

Identical to RDLSimpleWalker, except that this walker allows listeners to steer the traversal of the design using “Walker Actions”

From each callback, the listener may optionally return a WalkerAction to control how the walker should continue model traversal. Returning None is equivalent to WalkerAction.Continue.

If this feature is not necessary, it is recommended to use RDLSimpleWalker as it has less traversal overhead.

systemrdl.walker.RDLWalker#

Alias to RDLSteerableWalker for backwards compatibility

Listener#

class systemrdl.walker.RDLListener#

Base class for user-defined RDL traversal listeners.

enter_AddressableComponent(node: AddressableNode) WalkerAction | None#
enter_Addrmap(node: AddrmapNode) WalkerAction | None#
enter_Component(node: Node) WalkerAction | None#
enter_Field(node: FieldNode) WalkerAction | None#
enter_Mem(node: MemNode) WalkerAction | None#
enter_Reg(node: RegNode) WalkerAction | None#
enter_Regfile(node: RegfileNode) WalkerAction | None#
enter_Signal(node: SignalNode) WalkerAction | None#
enter_VectorComponent(node: VectorNode) WalkerAction | None#
exit_AddressableComponent(node: AddressableNode) WalkerAction | None#
exit_Addrmap(node: AddrmapNode) WalkerAction | None#
exit_Component(node: Node) WalkerAction | None#
exit_Field(node: FieldNode) WalkerAction | None#
exit_Mem(node: MemNode) WalkerAction | None#
exit_Reg(node: RegNode) WalkerAction | None#
exit_Regfile(node: RegfileNode) WalkerAction | None#
exit_Signal(node: SignalNode) WalkerAction | None#
exit_VectorComponent(node: VectorNode) WalkerAction | None#
class systemrdl.walker.WalkerAction(value)#
Continue = 0#

Continue walking the register model

SkipDescendants = 1#

Walker will continue calling listener methods for this component, but will not recurse into this node’s children.

StopNow = 2#

Stop the walker immediately. No more listener methods will be called.