D
Dwayne Dilbeck
Guest
You can't read in the seed value. You can only set it. The LRM section
dealing with manually setting the Random Seed is located below.
Basically you will always set it at simulation initialization. Each run
will be identical, but the data is random.
Note: the same seed used across tools is not garanteed to produce the same
results. The same results can only be generated in the origianl simulator.
13.14 Manually seeding randomize
Each object maintains its own internal RNG, which is used exclusively by its
randomize() method. This
allows objects to be randomized independent of each other and of calls to
other system randomization functions.
When an object is created, its RNG is seeded using the next value from the
RNG of the thread that creates
the object. This process is called hierarchical object seeding.
Sometimes it is desirable to manually seed an object's RNG using the
srandom() method. This can be done
either in a class method or external to the class definition:
An example of seeding the RNG internally, as a class method, is as follows:
class Packet;
rand bit[15:0] header;
....
function new (int seed);
this.srandom(seed);
....
endfunction
endclass
An example of seeding the RNG externally is as follows:
Packet p = new(200); // Create p with seed 200.
p.srandom(300); // Re-seed p with seed 300.
Calling srandom() in an object's new() function assures the object's RNG is
set with the new seed before
any class member values are randomized.
"humann" <hongqing.hu@gmail.com> wrote in message
news:7952f1cb-727d-44e2-9534-b401de00bdf3@e10g2000prf.googlegroups.com...
dealing with manually setting the Random Seed is located below.
Basically you will always set it at simulation initialization. Each run
will be identical, but the data is random.
Note: the same seed used across tools is not garanteed to produce the same
results. The same results can only be generated in the origianl simulator.
13.14 Manually seeding randomize
Each object maintains its own internal RNG, which is used exclusively by its
randomize() method. This
allows objects to be randomized independent of each other and of calls to
other system randomization functions.
When an object is created, its RNG is seeded using the next value from the
RNG of the thread that creates
the object. This process is called hierarchical object seeding.
Sometimes it is desirable to manually seed an object's RNG using the
srandom() method. This can be done
either in a class method or external to the class definition:
An example of seeding the RNG internally, as a class method, is as follows:
class Packet;
rand bit[15:0] header;
....
function new (int seed);
this.srandom(seed);
....
endfunction
endclass
An example of seeding the RNG externally is as follows:
Packet p = new(200); // Create p with seed 200.
p.srandom(300); // Re-seed p with seed 300.
Calling srandom() in an object's new() function assures the object's RNG is
set with the new seed before
any class member values are randomized.
"humann" <hongqing.hu@gmail.com> wrote in message
news:7952f1cb-727d-44e2-9534-b401de00bdf3@e10g2000prf.googlegroups.com...
Constraints random generation is why I learn SystemVerilog. The test
data is different from time to time
for the same Test Program.
But sometimes, I need to repeat same test data set for debug,
specifically if checker reports a error. How can I do it in
SystemVerilog?
Are there any system function to get "random seed" in SystemVerilog?
Using the same seed can guarantee to reproduce the same test data?
What I what to do is the following pseudo code:
// in checker
if (expected != received)
sned_to_mailbox("ERROR");
// in mailbox
if (get_message == "ERROR")
report_error_msg();
seed = get_random_seed();
write_to_log(seed)
Any other solutions are welcome.