Pre/post randomze behavior in randomize(null)

In reply to gordon:

BTW, you probably want to add a flag so that the same object can be used for both. Hopefully your 3rd party library is set up to use the factory.


class randomize_proof_prepost extends randomize_proof;
  enum bit {ENABLE, DISABLE} prepost = ENABLE;
  function void pre_randomize(); 
    if (prepost == ENABLE) super.pre_randomize();
  endfunction
   function void post_randomize(); 
    if (prepost == ENABLE) super.post_randomize();
  endfunction
endclass

module top_dp;
	initial begin
		randomize_proof_prepost rp;
		rp = new;
		assert(rp.randomize());
                rp.prepost = DISABLE;
		assert(rp.randomize(null));
                rp.prepost = ENABLE;
	end
endmodule