• No results found

5. Base classes

8.2 Factory component and object wrappers

This subclause defines the proxy component and object classes used by the factory. To avoid the overhead of creating an instance of every component and object that are registered, the factory holds lightweight wrappers, or proxies. When a request for a new object is made, the factory calls upon the proxy to create the object it represents.

8.2.2 type_id

All classes derived from uvm_object (see 5.3) within the UVM package (see 1.3.5) shall have a proxy declared as type_id, unless explicitly stated otherwise.

This type_id declaration takes the form of

typedefproxy_typetype_id where proxy_type is one of the following:

a) uvm_component_registry #(TYPE, "TYPE") (see 8.2.3)—For non-abstract, non-parameterized derivatives of uvm_component (see 13.1).

b) uvm_abstract_component_registry #(TYPE, "TYPE") (see 8.2.5.1)—For abstract, non-parameterized derivatives of uvm_component (see 13.1).

c) uvm_component_registry #(TYPE) (see 8.2.3)—For non-abstract, parameterized derivatives of uvm_component (see 13.1).

d) uvm_abstract_component_registry #(TYPE) (see 8.2.5.1)—For abstract, parameterized derivatives of uvm_component (see 13.1).

e) uvm_object_registry #(TYPE, "TYPE") (see 8.2.4)—For non-abstract, non-parameterized derivatives of uvm_object (see 5.3) that do not derive from uvm_component (see 13.1).

f) uvm_abstract_object_registry #(TYPE, "TYPE") (see 8.2.5.2)—For abstract, non-parameterized derivatives of uvm_object (see 5.3) that do not derive from uvm_component (see 13.1).

g) uvm_object_registry #(TYPE) (see 8.2.4)—For non-abstract, parameterized derivatives of uvm_object (see 5.3) that do not derive from uvm_component (see 13.1).

h) uvm_abstract_object_registry #(TYPE) (see 8.2.5.2)—For abstract, parameterized derivatives of uvm_object (see 5.3) that do not derive from uvm_component (see 13.1).

8.2.3 uvm_component_registry #(T,Tname)

The uvm_component_registry serves as a lightweight proxy for a component of type T and type name

Tname, a string. The proxy enables efficient registration with the uvm_factory (see 8.3.1). Without it, registration would require an instance of the component itself.

8.2.3.1 Class declaration

class uvm_component_registry #( type T = uvm_component, string Tname = "<unknown>" ) extends uvm_object_wrapper

The default value of Tname shall be "<unknown>". 8.2.3.2 Methods

8.2.3.2.1 create_component

virtual function uvm_component create_component ( string name,

uvm_component parent )

Creates a component of type T using the provided name and parent. This is an override of the method in uvm_object_wrapper (see 8.3.2). It is called by the factory after determining the type of object to create and the user can then implement it.

NOTE—Users should not call this method directly, they should use create instead (see 8.2.3.2.4).

8.2.3.2.2 get_type_name

virtual function string get_type_name()

Returns the value given by the string parameter, Tname by default. 8.2.3.2.3 get

static function uvm_component_registry #(T,Tname) get()

Returns a singleton instance.

The singleton instance is registered for initialization via uvm_init (see F.3.1.3) during static initialization. If uvm_init has been called prior to this registration occurring, the instance’s initialize method (see 8.2.3.2.7) is called automatically during static initialization.

8.2.3.2.4 create

static function T create( string name,

uvm_component parent, string contxt = "" )

Returns an instance of the component type T, represented by this proxy, subject to any factory overrides based on the context provided by contxt if it is not an empty string ("") or otherwise provided by the

parent’s full name. The new instance uses the given leaf name and parent. 8.2.3.2.5 set_type_override

static function void set_type_override ( uvm_object_wrapper override_type, bit replace = 1

)

This is a pass-through; it configures the factory to create an object of the type represented by override_type

whenever a request is made to create an object of the type T, represented by this proxy, provided no instance override applies. The original type T shall be a super class of the override_type. replace is a pass-through to the set_type_override_by_type (see 8.3.1.4.2). The default value of replace shall be 1.

8.2.3.2.6 set_inst_override

static function void set_inst_override( uvm_object_wrapper override_type, string inst_path,

uvm_component parent = null )

Configures the factory to create a component of the type represented by override_type whenever a request is made to create an object of the type T, represented by this proxy, with matching instance paths. The original type T shall be a super class of the override_type.

If parent is not specified, inst_path is interpreted as an absolute instance path, which enables instance overrides to be specified outside the component classes. If parent is specified, inst_path is interpreted as being relative to the parent’s hierarchical instance path, i.e., {parent.get_full_name(),

"

.

"

, inst_path} is the instance path that is registered with the override. inst_path may contain wildcards for matching against multiple contexts.

8.2.3.2.7 initialize

virtual function void initialize()

Registers this proxy object with the current factory (see F.4.1.4.2) via uvm_factory::register (see 8.3.1.3). 8.2.4 uvm_object_registry #(T,Tname)

The uvm_object_registry serves as a lightweight proxy for an uvm_object (see 5.3) of type T and type name Tname, a string. The proxy enables efficient registration with the uvm_factory (see 8.3.1). Without it, registration would require an instance of the object itself.

8.2.4.1 Class declaration

class uvm_object_registry #( type T = uvm_object, string Tname = "<unknown>" ) extends uvm_object_wrapper

The default value of Tname shall be "<unknown>". 8.2.4.2 Methods

8.2.4.2.1 create_object

virtual function uvm_object create_object ( string name = ""

)

Creates a component of type T and returns it as a handle to uvm_object (see 5.3). This is called by the factory after determining the type of object to create and the user can then implement it.

NOTE—Users should not call this method directly, they should use create instead (see 8.2.4.2.4).

8.2.4.2.2 get_type_name

virtual function string get_type_name()

Returns the value given by the string parameter Tname by default. This method overrides the method in uvm_object_wrapper (see 8.3.2).

8.2.4.2.3 get

static function uvm_object_registry #(T,Tname) get()

Returns a singleton instance.

The singleton instance is registered for initialization via uvm_init (see F.3.1.3) during static initialization. If uvm_init has been called prior to this registration occurring, the instance’s initialize method (see 8.2.3.2.7) is called automatically during static initialization.

8.2.4.2.4 create

static function T create( string name = "",

uvm_component parent = null, string contxt = ""

)

Returns an instance of the object type T, represented by this proxy, subject to any factory overrides based on the context provided by the parent’s full name. The contxt argument, if supplied, supersedes the parent’s context. The new instance uses the given leaf name and parent.

8.2.4.2.5 set_type_override

static function void set_type_override ( uvm_object_wrapper override_type, bit replace = 1

)

Configures the factory to create an object of the type represented by override_type whenever a request is made to create an object of the type represented by this proxy, provided no instance override applies. The original type T is typically a super class of the override_type. The default value of replace shall be 1.

8.2.4.2.6 set_inst_override

static function void set_inst_override( uvm_object_wrapper override_type, string inst_path,

uvm_component parent = null )

Configures the factory to create an object of the type represented by override_type whenever a request is made to create an object of the type represented by this proxy, with matching instance paths. The original type T is typically a super class of the override_type.

If parent is not specified, inst_path is interpreted as an absolute instance path, which enables instance overrides to be specified outside the component classes. If parent is specified, inst_path is interpreted as being relative to the parent’s hierarchical instance path, i.e., {parent.get_full_name(),”.”, inst_path} is the instance path that is registered with the override. inst_path may contain wildcards for matching against multiple contexts.

8.2.4.2.7 initialize

virtual function void initialize()

Registers this proxy object with the current factory (see F.4.1.4.2) via uvm_factory::register (see 8.3.1.3).

8.2.5 Abstract registries

UVM additionally supports registration of abstract objects and components with the factory. Since registered classes are abstract, they can not be constructed directly via a call to new. As such, the user needs to provide a factory override for any abstract classes that are registered with the factory. It shall be an error to attempt to construct an abstract class for which no overrides have been declared.

The abstract registries should only be used with objects and components that have been declared as virtual types, e.g.,

virtual my_component_base extends uvm_component

For standard components and objects (i.e., those not declared using the keyword virtual), the standard registries should be used (see 8.2.3 and 8.2.4).

8.2.5.1 uvm_abstract_component_registry

This serves as a lightweight proxy for an abstract component of type T and type name Tname, a string. The proxy enables efficient registration with uvm_factory (see 8.3.1). Without it, registration would require an instance of the component itself.

8.2.5.1.1 Class declaration

class uvm_abstract_component_registry #(type T=uvm_component, string Tname="<unknown>")

extends uvm_object_wrapper

The default value of the parameter Tname shall be "<unknown>". This class has the following Methods.

8.2.5.1.2 create_component

virtual function uvm_component create_component( string name,

uvm_component parent )

As abstract classes cannot be constructed, this method shall generate an error and return null. 8.2.5.1.3 get_type_name

This is the same as uvm_component_registry::get_type_name (see 8.2.3.2.2). 8.2.5.1.4 get

This is the same as uvm_component_registry::get (see 8.2.3.2.3). 8.2.5.1.5 create

This is the same as uvm_component_registry::create (see 8.2.3.2.4). 8.2.5.1.6 set_type_override

This is the same as uvm_component_registry::set_type_override (see 8.2.3.2.5). 8.2.5.1.7 set_inst_override

This is the same as uvm_component_registry::set_inst_override (see 8.2.3.2.6). 8.2.5.1.8 initialize

This is the same as uvm_component_registry::initialize (see 8.2.3.2.7). 8.2.5.2 uvm_abstract_object_registry

This serves as a lightweight proxy for an abstract object of type T and type name Tname, a string. The proxy enables efficient registration with uvm_factory (see 8.3.1). Without it, registration would require an instance of the object itself.

8.2.5.2.1 Class declaration

class uvm_abstract_object_registry #(type T=uvm_object, string Tname="<unknown>")

extends uvm_object_wrapper

The default value of the parameter Tname shall be "<unknown>". This class has the following Methods.

8.2.5.2.2 create_object

virtual function uvm_object create_object( string name,

uvm_object parent )

As abstract classes cannot be constructed, this method shall generate an error and return null. 8.2.5.2.3 get_type_name

This is the same as uvm_object_registry::get_type_name (see 8.2.4.2.2).

8.2.5.2.4 get

This is the same as uvm_object_registry::get (see 8.2.4.2.3).

8.2.5.2.5 create

This is the same as uvm_object_registry::create (see 8.2.4.2.4).

8.2.5.2.6 set_type_override

This is the same as uvm_object_registry::set_type_override (see 8.2.4.2.5).

8.2.5.2.7 set_inst_override

This is the same as uvm_object_registry::set_inst_override (see 8.2.4.2.2).

8.2.5.2.8 initialize

This is the same as uvm_object_registry::initialize (see 8.2.4.2.7).

Related documents