User guide
24-112
SystemVerilog Testbench Constructs
$display("Generation of random number with seed 3 :");
a = $urandom(3);
b = $urandom();
c = $urandom();
d = $urandom();
$display("a = %0d,b= %0d, c = %0d, d = %0d",a,b,c,d);
end
endprogram
The output of this program is:
Generation of random number with seed 3 :
a = 229,b= 175, c = 7, d = 99
Generation of random number with seed 4 :
a = 228,b= 15, c = 254, d = 230
Generation of random number with seed 3 :
a = 229,b= 175, c = 7, d = 99
$urandom_range()
The system function $urandom_range() generates random numbers
within a certain range. The syntax is:
$urandom_range( unsigned int maxval, unsigned int minval)
The function returns an unsigned integer between maxval and minval
(inclusive of them). If one of the arguments is omitted, then the
function will return an unsigned integer between the argument
specified and zero.
The following program explains the usage of $urandom_range().
program test();
logic [3:0] a,a1;
bit [2:0] b;
initial begin