# Policy Classes

Policy classes are used to implement polymorphic operations that differ between built-in types and class-based types. Generic components can then be built that work with either classes or built-in types, depending on what policy class is used.

Contents

Policy Classes | Policy classes are used to implement polymorphic operations that differ between built-in types and class-based types.
uvm_built_in_comp #(T) | This policy class is used to compare built-in types.
uvm_built_in_converter #(T) | This policy class is used to convert built-in types to strings.
uvm_built_in_clone #(T) | This policy class is used to clone built-in types via the = operator.
uvm_class_comp #(T) | This policy class is used to compare two objects of the same type.
uvm_class_converter #(T) | This policy class is used to convert a class object to a string.
uvm_class_clone #(T) | This policy class is used to clone class objects.

## uvm_built_in_comp #(T)

This policy class is used to compare built-in types.

Provides a comp method that compares the built-in type, T, for which the == operator is defined.

Summary

uvm_built_in_comp #(T)
This policy class is used to compare built-in types.
Class Declaration
> class uvm_built_in_comp #(
> | type | T | = | int
> )

## uvm_built_in_converter #(T)

This policy class is used to convert built-in types to strings.

Provides a convert2string method that converts the built-in type, T, to a string using the %p format specifier.

Summary

uvm_built_in_converter #(T)
This policy class is used to convert built-in types to strings.
Class Declaration
> class uvm_built_in_converter #(
> | type | T | = | int
> )

## uvm_built_in_clone #(T)

This policy class is used to clone built-in types via the = operator.

Provides a clone method that returns a copy of the built-in type, T.

Summary

uvm_built_in_clone #(T)
This policy class is used to clone built-in types via the = operator.
Class Declaration
> class uvm_built_in_clone #(
> | type | T | = | int
> )

## uvm_class_comp #(T)

This policy class is used to compare two objects of the same type.

Provides a comp method that compares two objects of type T. The class T must provide the method “function bit compare(T rhs)”, similar to the uvm_object::compare method.

Summary

uvm_class_comp #(T)
This policy class is used to compare two objects of the same type.
Class Declaration
> class uvm_class_comp #(
> | type | T | = | int
> )

## uvm_class_converter #(T)

This policy class is used to convert a class object to a string.

Provides a convert2string method that converts an instance of type T to a string. The class T must provide the method “function string convert2string()”, similar to the uvm_object::convert2string method.

Summary

uvm_class_converter #(T)
This policy class is used to convert a class object to a string.
Class Declaration
> class uvm_class_converter #(
> | type | T | = | int
> )

## uvm_class_clone #(T)

This policy class is used to clone class objects.

Provides a clone method that returns a copy of the built-in type, T. The class T must implement the clone method, to which this class delegates the operation. If T is derived from uvm_object, then T must instead implement uvm_object::do_copy, either directly or indirectly through use of the `uvm_field macros.

Summary

uvm_class_clone #(T)
This policy class is used to clone class objects.
Class Declaration
> class uvm_class_clone #(
> | type | T | = | int
> )

> class uvm_built_in_comp #(
> | type | T | = | int
> )

This policy class is used to compare built-in types.

> class uvm_built_in_converter #(
> | type | T | = | int
> )

This policy class is used to convert built-in types to strings.

> class uvm_built_in_clone #(
> | type | T | = | int
> )

This policy class is used to clone built-in types via the = operator.

> class uvm_class_comp #(
> | type | T | = | int
> )

This policy class is used to compare two objects of the same type.

> class uvm_class_converter #(
> | type | T | = | int
> )

This policy class is used to convert a class object to a string.

> class uvm_class_clone #(
> | type | T | = | int
> )

This policy class is used to clone class objects.

> function bit compare (
> | uvm_object | rhs, |  |
> | uvm_comparer | comparer | = | null
> )

Deep compares members of this data object with those of the object provided in the rhs (right-hand side) argument, returning 1 on a match, 0 otherwise.

> virtual function string convert2string()

This virtual function is a user-definable hook, called directly by the user, that allows users to provide object information in the form of a string.

> virtual class uvm_object extends uvm_void

The uvm_object class is the base class for all UVM data and hierarchical classes.

> virtual function void do_copy (
> | uvm_object | rhs
> )

The do_copy method is the user-definable hook called by the copy method.