I have a data item class.
I am using create method and new to create the item class object.
I have a function post_randomize inside this class.
However it doesnt get called by default.
Is it because I am using create and not new for generating the data item class?
The create method eventually calls new, so that should not matter.
obj_h.post_randomize() is called implicitly when you call obj_h.randomize(). post_randomize() is also called for any object that is a random variable of the object you called randomize() on. For example
class A;
rand int i;
function void post_randomize();
$display(i);
endfunction
endclass
class B;
rand A a;
endclass
B b;
Before you call b.randomize(), b.a must already be constructed to randomize b.a.i and then call b.a.post_randomize().