Difference Between Std: :Randomize and Class Based Randomize

What is the difference between option A and Option B

Option A:

sucess = std::randomize(type_l) with { 
   type_l inside { A ,B ,C};
   type_l dist { A := 2 ,B := 5 ,C := 4 }; 
};

if(  sucess == 0 ) begin
   `uvm_fatal("TEST_CFG", "type_l randomization failed")
end

Option B:

class gen_type;

   enum_type type_l;

   constraint type_c{ 
      type_l inside { A ,B ,C};
      type_l dist { A := 2 ,B := 5 ,C := 4 }; 
   };       
endclass
1
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.