Randomization

In reply to anvesh dangeti:

As I said earlier, you can use $random or $urandom wherever an integral expression is allowed, irrespective of being inside a class or not. There are other restrictions, like side effects, that prevent certain functions and operators (e.g. ++,–) from being used in constraint expressions.

SystemVerilog introduces $urandom, which should replace the legacy use of Verilog’s $random. $urandom has the random stability features needed for testbench development that $random does not have. See section 18.14 Random stability in the IEEE 1800-2017 SystemVerilog LRM.