Static Class Handle

Hi,
I have problem understanding the meaning of a static class handle, which is referred to only once in LRM, section 6.8.
As far as I understand, in the following piece of code which I quote from Chris Spear’s book, ‘me’ is an example of a static class handle:


class svm_component;
	...
endclass

class svm_component_registry #(type T=svm_component, string Tname="<unknown>");
	typedef svm_component_registry #(T,Tname) this_type;
	local static this_type me = get();			// Handle to singleton
	static function this_type get();
		if (me == null) begin	// Is there an instance?
			me = new();	// Build the singleton
		end
		return me;
	endfunction
endclass

Now what is the behavior of ‘me’ handle declared as static? What happens when it is constructed using the get() function? It can be seen that the get() function is called inline with the declaration of ‘me’. Does this mean that an object is automatically constructed at compile time of the class svm_component_registry?

In reply to Farhad:

No, you are confusing class variables with class handles. The variable is static, not the handle. All static variables regardless of their type get initialized once at run-time 0, before any initial or always block processes begin.

In reply to dave_59:

Thank you Dave, I get it better now, after reading your reply and the article you suggested. So if I understand correctly, in the above example, the class svm_component_registry must be constructed somewhere else in a procedural block, which will cause ‘get()’ function to be called automatically and construct an object for ‘me’, right? I mean, ‘me’ is constructed automatically upon construction of an object of type svm_component_registry. Is that correct?

In reply to Farhad:

That is still incorrect. Static class properties, like any other static variables get initialized once at time 0. They do not require the class they are contained in to ever be constructed.

You may want to read this paper that includes information about how static class variables interact with parameterized classes. Using parameterized classes & factories: Object-oriented verification

Also, SystemVerilog OOP for UVM Verification | Track

In reply to dave_59:

Thank you very much, Dave.