In reply to chr_sue:
sry sry… actually I have seen that later and I modified it working perfectly. but What I have noticed is.
when we are writing the write function we need to pass the argument seq_item handle as “t”.
virtual function void write(seq_item t); // here if you take any handle it is not working, we need to take only "t"
seq_item_handle =t;
cg.sample();
endfunction
thank you chr_sue for your inputs.