From the name above, we can see that uvm_factory is used to manufacture uvm_objects and component.
In a simulation process, only one factory instance exists..
The User-Defined Object and component types are registered in the factory through typedef or macro. The factory generates and saves a lightweight Proxy: 1. uvm_object_registry # (T, tname) for objects 2. uvm_component_registry # (T, tname) for components
Each proxy only knows how to create an example of the object or component that it represents, and this is very efficient for memory.
When a user requests an object or component instance, the factory will determine what type of object to create based on its configuration, then ask that type's proxy to create an instance of the type, which is returned to the user. the structure of the entire factory in UVM is as follows.
Before introducing the factory Mechanism Implemented by UVM, let's implement a simple factory by ourselves. Why should we implement the factory mechanism?
In the OVM cookbook, the factory mode in OVM is described in detail. A toy factory example is used to illustrate the implementation principle of the factory mode, so that readers can gain a deeper understanding. Several important concepts need to be emphasized: 1. the focus of the singleton mode is to declare the constructor as a private member function to prevent external calls to the constructor to create an object and declare a static object handle of its own type, A static function is used to create a unique object and assign it to the object handle. This object handle can be used as a window to access this Singleton, or the object handle of this Singleton can be accessed using the static function return value. 2. The overide type in the factory must come from the same base class. Because the factory stores the associated array of objects, it is also called a dictionary in some programming languages (it seems like this in Python). The key of the associated array is the object handle. The associated array requires that the keywords must be of the same type, so the overrige type must belong to the same base class to ensure that they are of the same type. A Wrapper class is generated for each class. This Wrapper class is also a Singleton, and its object is statically created. Once this object is created, the object handle is unique (because there is only one object instance ). Therefore, it is easy to locate the object handle and use this handle to access the associated array. 3. Static functions, static variables static functions and static variables are not associated with specific object instances. They are created during the initialization phase of the runtime. A specific type has only one set. Therefore, you can use the type modifier ":" instead of static functions and variables, you cannot use the type modifier for access. For example, in the OVM cookbook instance, replace the statement H = family_base: type_id: Create (); with the following statement: H = family_base: type_id: create_object (); an error is reported because create_object () is not a static function. Cannot be accessed through the type modifier. (Using create_object to create an object cannot implement type overloading. It is only used for demonstration here.) static functions are created statically, so they can only access static variables and static functions of the type, because other variables are not created. 4. In addition to providing an associated array with the object handle as the keyword to implement the factory, OVM also provides an associated array with the string as the keyword to implement the factory. + In the command line parameter ovm_testname = "testcase1", the string factory is more practical. The string factory implementation is simpler and does not need to introduce the Wrapper class. You can directly create an object using the factory. create_component_by_name () function. The return type must be assigned to the actual specific type through downcast. The string factory does not have a type check, and there is no object handle for security. 5 wrapper's design philosophy wrapper # (t) is a singleton. Therefore, it cannot call its constructor externally. It can only get its unique static object get_type () through get_type () in addition to generating the unique object of the Wrapper class, it also registers itself to the association array in the factory. Registration means adding an element to the association array, the keyword is the handle of the unique static object of wrapper # (t. Wrapper # (t) must provide a function to generate T-type objects. This function is create_object (). In fact, there may be multiple objects of type T, so create_object () different calls will return objects of different types of T. This function does not need to be static, this function is called only by the value of the factory's associated array (the value of the associated array is the specific object handle. Wrapper # (t) must provide a static function that is called in type mode, that is, the CREATE () function. The static create () function in wrapper creates an object by calling the create function in the factory. Source: http://electron64.blog.163.com/blog/static/10603397020110106130965/>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service