Welcome ! This website will help YOU (recent graduates/professionals) learn verification languages like SystemVerilog and UVM. Register for free and access more content !
2 minutes reading time (309 words)

what happens when you register a component with factory ?

what happens when you register a component with factory ?

One of the main features of UVM is the factory mechanism, and we already know how to use `uvm_component_utils () and `uvm_object_utils () within user-defined component and object classes. It's a way of registering our new component with the factory so that we can request the factory to return an object of some other type later on via type_id::create () method. Let's see what happens behind the scene when the code is elaborated and compiled for the example that follows.


Part 1: Register with Factory

class my_env extends uvm_env;
  `uvm_component_utils (my_env)
 
  ...
endclass
 

Part 2: Inclusion of type_id

`uvm_component_utils () is a UVM macro, and will be substituted with the following code when its compiled. uvm_component_registry serves as a lightweight proxy for a component of type T and type name Tname. The proxy enables efficient registration with the uvm_factory, and without it, registration would require an instance of the component itself.

typedef uvm_component_registry #(T, "Tname") type_id;                 // Note this important re-definition of the type where T = my_env

...

Part 3: Definition of create ()

Class uvm_component_registry has an internal static function to create and return an object of type T.

static function T create (string name, uvm_component parent, string cntxt = "");
	// Create a local object of type uvm_object
	// Get instance of the factory
	// Use factory method create_component_by_type ()
endfunction

Part 4: Call create ()

The static method create (), will return an object of type T, where T = my_env in our case, and will be assigned to the handle m_top_env.

class my_test extends uvm_test;
	`uvm_component_utils (uvm_test)
		
	my_env m_top_env;
	
	virtual function void build_phase ();
		super.build_phase (phase);
		
		m_top_env = my_env :: type_id :: create ("m_top_env", this);
	endfunction
	
endclass

Note that you'll get an error if you forget to include `uvm_component_utils () and try to use create( ), because type_id will then be undefined.

how to disable file name and line numbers in repor...
how to turn an agent from active to passive ?
 

Comments 2

Ratiranjan Senapati on Saturday, 08 October 2016 00:56

Thanks a lot Aravind.
Thanks for all your easy explanations. Helped a lot.

Please keep it up

Thanks a lot Aravind. Thanks for all your easy explanations. Helped a lot. Please keep it up :)
Rupam Kumari on Monday, 11 September 2017 23:24

Thanks for all your easy explanations.
It helped me alot.

Thanks for all your easy explanations. It helped me alot.
Already Registered? Login Here
Guest
Monday, 25 June 2018

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. You consent to our cookies if you continue to use our website. To find out more about the cookies we use and how to delete them, see our privacy policy.

  I accept cookies from this site.
Agree
EU Cookie Directive plugin by www.channeldigital.co.uk