In reply to Ashwath Saralaya:
So if obj_singleton is not null, create method will return nothing?
You should change your code like this:
static function singleton create ();
if (obj_singleton == null)begin
obj_singleton = new();
$display("Creating object ");
end
else begin
$display("Already object exists");
end
return obj_singleton;
endfunction
By the way, in singleton pattern, both obj_singleton in your code and new() function MUST be declared as a local variable, otherwise, your obj_singleton can be changed easily.