# uvm_visitor #(NODE)

The uvm_visitor class provides an abstract base class for a visitor. The visitor visits instances of type NODE. For general information regarding the visitor pattern see http://en.wikipedia.org/wiki/Visitor_pattern

Contents

uvm_visitor #(NODE) | The uvm_visitor class provides an abstract base class for a visitor.
uvm_structure_proxy #(STRUCTURE) | The uvm_structure_proxy is a wrapper and provides a set of elements of the STRUCTURE to the caller on demand.
uvm_visitor_adapter #(STRUCTURE,uvm_visitor#(STRUCTURE)) | The visitor adaptor traverses all nodes of the STRUCTURE and will invoke visitor.visit() on every node.
uvm_top_down_visitor_adapter | This uvm_top_down_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.
uvm_bottom_up_visitor_adapter | This uvm_bottom_up_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.
uvm_by_level_visitor_adapter | This uvm_by_level_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.
uvm_component_proxy | The class is providing the proxy to extract the direct subcomponents of s
uvm_component_name_check_visitor | This specialized visitor analyze the naming of the current component.

### Methods

### begin_v

> virtual function void begin_v()

This method will be invoked by the visitor before the first NODE is visited

### end_v

> virtual function void end_v()

This method will be invoked by the visitor after the last NODE is visited

### visit

> pure virtual function void visit(
> | NODE | node
> )

This method will be invoked by the visitor for every visited node of the provided structure. The user is expected to provide the own functionality in this function.

>     class count_nodes_visitor#(type T=uvm_component) extends uvm_visitor#(T);
>         function new (string name = "");
>            super.new(name);
>         endfunction
>         local int cnt;
>         virtual function void begin_v(); cnt = 0; endfunction
>         virtual function void end_v(); `uvm_info("TEXT",$sformatf("%d elements",cnt),UVM_NONE) endfunction
>         virtual function void visit(T node); cnt++; endfunction
>     endclass

## uvm_structure_proxy #(STRUCTURE)

The uvm_structure_proxy is a wrapper and provides a set of elements of the STRUCTURE to the caller on demand. This is to decouple the retrieval of the STRUCTUREs subelements from the actual function being invoked on STRUCTURE

Summary

uvm_structure_proxy #(STRUCTURE)
The uvm_structure_proxy is a wrapper and provides a set of elements of the STRUCTURE to the caller on demand.
Methods |
get_immediate_children | This method will be return in children a set of the direct subelements of s

### Methods

### get_immediate_children

> pure virtual function void get_immediate_children(
> |  | STRUCTURE | s,
> | ref | STRUCTURE | children[$]
> )

This method will be return in children a set of the direct subelements of s

## uvm_visitor_adapter #(STRUCTURE,uvm_visitor#(STRUCTURE))

The visitor adaptor traverses all nodes of the STRUCTURE and will invoke visitor.visit() on every node.

Summary

uvm_visitor_adapter #(STRUCTURE,uvm_visitor#(STRUCTURE))
The visitor adaptor traverses all nodes of the STRUCTURE and will invoke visitor.visit() on every node.
Methods |
accept() | Calling this function will traverse through s (and every subnode of s).

### Methods

### accept()

> pure virtual function void accept(
> | STRUCTURE | s, |  |
> | VISITOR | v, |  |
> | uvm_structure_proxy#(STRUCTURE) | p, |  |
> | bit | invoke_begin_end | = | 1
> )

Calling this function will traverse through s (and every subnode of s). For each node found v.visit(node) will be invoked. The children of s are recursively determined by invoking p.get_immediate_children().~invoke_begin_end~ determines whether the visitors begin/end functions should be invoked prior to traversal.

## uvm_top_down_visitor_adapter

This uvm_top_down_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion. During traversal s will be visited before all subnodes of s will be visited.

Summary

uvm_top_down_visitor_adapter
This uvm_top_down_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.
Class Hierarchy
uvm_visitor_adapter#(STRUCTURE,VISITOR)
uvm_top_down_visitor_adapter
Class Declaration
> class uvm_top_down_visitor_adapter#(
> | type | STRUCTURE | = | uvm_component,
> |  | VISITOR | = | uvm_visitor#(STRUCTURE)
> ) extends uvm_visitor_adapter#(STRUCTURE,VISITOR)

## uvm_bottom_up_visitor_adapter

This uvm_bottom_up_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion. During traversal all children of node s will be visited s will be visited.

Summary

uvm_bottom_up_visitor_adapter
This uvm_bottom_up_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.
Class Hierarchy
uvm_visitor_adapter#(STRUCTURE,VISITOR)
uvm_bottom_up_visitor_adapter
Class Declaration
> class uvm_bottom_up_visitor_adapter#(
> | type | STRUCTURE | = | uvm_component,
> |  | VISITOR | = | uvm_visitor#(STRUCTURE)
> ) extends uvm_visitor_adapter#(STRUCTURE,VISITOR)

## uvm_by_level_visitor_adapter

This uvm_by_level_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion. During traversal will visit all direct children of s before all grand-children are visited.

Summary

uvm_by_level_visitor_adapter
This uvm_by_level_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.
Class Hierarchy
uvm_visitor_adapter#(STRUCTURE,VISITOR)
uvm_by_level_visitor_adapter
Class Declaration
> class uvm_by_level_visitor_adapter#(
> | type | STRUCTURE | = | uvm_component,
> |  | VISITOR | = | uvm_visitor#(STRUCTURE)
> ) extends uvm_visitor_adapter#(STRUCTURE,VISITOR)

## uvm_component_proxy

The class is providing the proxy to extract the direct subcomponents of s

Summary

uvm_component_proxy
The class is providing the proxy to extract the direct subcomponents of s
Class Hierarchy
uvm_structure_proxy#(uvm_component)
uvm_component_proxy
Class Declaration
> class uvm_component_proxy extends uvm_structure_proxy#(
> | uvm_component
> )

## uvm_component_name_check_visitor

This specialized visitor analyze the naming of the current component. The established rule set ensures that a component.get_full_name() is parsable, unique, printable to order to avoid any ambiguities when messages are being emitted.

ruleset a legal name is composed of

- allowed charset “A-z:_0-9[](){}-: “
- whitespace-as-is, no-balancing delimiter semantic, no escape sequences
- path delimiter not allowed anywhere in the name

the check is coded here as a function to complete it in a single function call otherwise save/restore issues with the used dpi could occur

Summary

uvm_component_name_check_visitor
This specialized visitor analyze the naming of the current component.
Class Hierarchy
uvm_visitor#(uvm_component)
uvm_component_name_check_visitor
Class Declaration
> class uvm_component_name_check_visitor extends uvm_visitor#(
> | uvm_component
> )
Methods |
get_name_constraint | This method should return a regex for what is being considered a valid/good component name.

### Methods

### get_name_constraint

> virtual function string get_name_constraint()

This method should return a regex for what is being considered a valid/good component name. The visitor will check all component names using this regex and report failing names

> class uvm_top_down_visitor_adapter#(
> | type | STRUCTURE | = | uvm_component,
> |  | VISITOR | = | uvm_visitor#(STRUCTURE)
> ) extends uvm_visitor_adapter#(STRUCTURE,VISITOR)

This uvm_top_down_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.

> class uvm_bottom_up_visitor_adapter#(
> | type | STRUCTURE | = | uvm_component,
> |  | VISITOR | = | uvm_visitor#(STRUCTURE)
> ) extends uvm_visitor_adapter#(STRUCTURE,VISITOR)

This uvm_bottom_up_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.

> class uvm_by_level_visitor_adapter#(
> | type | STRUCTURE | = | uvm_component,
> |  | VISITOR | = | uvm_visitor#(STRUCTURE)
> ) extends uvm_visitor_adapter#(STRUCTURE,VISITOR)

This uvm_by_level_visitor_adapter traverses the STRUCTURE s (and will invoke the visitor) in a hierarchical fashion.

> class uvm_component_proxy extends uvm_structure_proxy#(
> | uvm_component
> )

The class is providing the proxy to extract the direct subcomponents of s

> class uvm_component_name_check_visitor extends uvm_visitor#(
> | uvm_component
> )

This specialized visitor analyze the naming of the current component.

> pure virtual function void get_immediate_children(
> |  | STRUCTURE | s,
> | ref | STRUCTURE | children[$]
> )

This method will be return in children a set of the direct subelements of s

> pure virtual function void accept(
> | STRUCTURE | s, |  |
> | VISITOR | v, |  |
> | uvm_structure_proxy#(STRUCTURE) | p, |  |
> | bit | invoke_begin_end | = | 1
> )

Calling this function will traverse through s (and every subnode of s).

> virtual function string get_name_constraint()

This method should return a regex for what is being considered a valid/good component name.