Welcome To UVM World

Sunday, 1 January 2017

Inside UVM factory Part -1

Hi all. Today we will understand one of the most important feature of UVM which is "uvm factory".
uvm factory is used to create components and objects in uvm environment. User has to call factory create method and not explicit new method to create the class objects. Factory take care of object overriding so that when user creates a new object it will create overridden object instead of actual object. This is the powerful feature of UVM Factory.
In order to use factory all the class types in the UVM environment has to be registered with factory. Below shown macro will do that. Example is considered for uvm component and same applies for uvm object as well.

            


This macro internally call other macro "component registry internal" which will declare the handle of uvm object/ component registry parameterized with our class handle and extra two functions to get the wrapper object and wrapper name of our class as shown below.

        
       
The uvm_component registry handle name is "type_id" which we commonly use to call factory create method. Even though handle name is common for all the classes the parameterization makes it different.Now the point is how just a handle declaration registers class type for the factory. We will see that now...

         
Inside uvm_component_registry base class as shown above, there is declaration of local static handle of that particular object wrapper (this_type me). It is initialized with returned value from "get()" method. So get will be called for each unique handle declaration in our user defined classes.

get() method as shown will call factory's register method to register the particular wrapper class to the factory. We got the answer!!. Just a macro call does the factory registration.!!

It is as simple as it is. In this post we understood how just a handle declaration of object/component wrapper parameterized with user specific class name makes factory registration to happen. In the next post we will see different factory methods and understand how it works internally. See you all soon!!
  

2 comments:

  1. Hi Raghu,
    Nice explanation,thank you. Eagerly waiting for next post.....

    ReplyDelete
  2. Hi Pavan, Thank you for your support..

    ReplyDelete