|
|
|
|
|
|
|
|
|
|
|
|
Random number system tasks
|
|
|
Systemverilog introductes additional system tasks to aid randomization, which are not CPU intersive, basically very fast compared to object randomization. |
|
|
|
|
|
- $urandom_range : The $urandom_range() function returns an unsigned integer within a specified range.
- $urandom : The system function $urandom provides a mechanism for generating pseudo-random numbers. The function returns a new 32-bit random number each time it is called. The number shall be unsigned.
- $srandom : The srandom() method allows manually seeding the RNG of objects or threads.
- $set_randstate :The set_randstate() method sets the state of an object’s RNG.
- $get_randstate : The get_randstate() method retrieves the current state an object’s RNG.
|
|
|
|
|
|
|
|
|
|
|
|
Example : Random number system tasks
|
|
|
|
|
|
1 module system_random();
2
3 initial begin
4 // Set the seed
5 $srandom(10);
6 // Randomize number between 1 and 10
7 $display ("Value is %0d",$urandom_range(10,1));
8 // Use seed 10 before randomize
9 $display ("Value is %0d",$urandom(10));
10 end
11
12 endmodule
You could download file system_random.sv here
|
|
|
|
|
|
Simulator Output : Random number system tasks
|
|
|
|
|
|
Value is 7
Value is 1259199836
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|