Following are the random functions which are used to generate random number in system verilog
1-$random
2-$urandom()
1-$random
function return a random 32 signed value so this value can be positive or negative
for example
integer d;
d = $random;
RESULT:
d = 303379748;
d = -1064739199;
2-$urandom()
function generates also 32 bit random number but it is always unsigned
bit [31:0] d;
d = $urandom();
here another option is present you can seed the random function for example
integer seed=3;
int b=$urandom(seed);
It will generate random number but random number remain same throughout the simulation unless one will change the seed value.This function will generate 32 bit fixed random number but if you will change the seed value the random value will also change
what if someone wants to generate random number within specific range let I want to generate random number between 1 to 20, then there is a specific function as given below is used.
int b=$urandom(seed)%20;
this function generate random value b/w 0 and 20;
3-$urandom_range()
it returns the unsigned value b/w specified range its syntax is $urandom_range(max,min);
e.g $urandom(100,1)
this will return value b/w 1 and 100