| Login | | Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name. | |
| Who's Online | There are currently, 67 guest(s) and 0 member(s) that are online.
You are Anonymous user. You can register for free by clicking here | |
 | |
|
Verification Guild: Forums |
|
| View previous topic :: View next topic |
| Author |
Message |
bricks Newbie


Joined: Oct 28, 2004 Posts: 1
|
Posted: Thu Oct 28, 2004 12:10 pm Post subject: How to randomize the seed for $random from one test to next? |
|
|
This may be a trivial problem for others, but somehow I'm stuck.
How do I make sure I get a different random number from one test run to next? I'll have to save the seed, so I can reproduce the same exact test, of course.
I'm using Modelsim in Windows (XP) environment, and I have a dos batch file (I know...). In the test bench, I have
cpu_wdat = $random(SEED);
...
then I have
if ( cpu_rdat != cpu_wdat )
error = 1;
and so on...
If I were in unix environment, I could do something like
% vsim +SEED='date' ...
but somehow I cannot pass the wall clock information to the test bench in dos/windows environment (I tried using 'time' instead in .bat). I thought about using unix-like shell (cygwin, etc), but I cannot force it to the rest of the team.
Help? |
|
| Back to top |
|
 |
EdA Senior


Joined: Jan 06, 2004 Posts: 64
|
Posted: Fri Oct 29, 2004 8:26 am Post subject: One approach |
|
|
Have your DOS script call a program which writes the current time to a
$readmem loadable file and load that file and use the value to seed the random number generator.
You'll need some mode in the script which does not overwrite the memory file if you want to rerun with the same seed.
/Ed |
|
| Back to top |
|
 |
yossi_ginzburg Newbie


Joined: Jan 11, 2004 Posts: 4
|
Posted: Mon Nov 01, 2004 5:17 am Post subject: Why would you want your SEED randomized? |
|
|
Why would you want your SEED randomized?
Isn't having your seed DIFFERENT from one test run to the next good enough?
Because if it is, just have your script increse the seed by 1 each time a test is run.
It will also make your life easier when trying to reproduce the test. |
|
| Back to top |
|
 |
alexg Senior

![]()
Joined: Jan 07, 2004 Posts: 586 Location: Ottawa
|
Posted: Wed Nov 03, 2004 7:21 am Post subject: Re: Why would you want your SEED randomized? |
|
|
In a cases tests are different, there is no reason to change the seed - it can be the same for the whole regression run and change only from one regression to another.
Changing the seed is important when we run the same constraint-random test case number of times. But even here, seed for next re-run can be generated from the previous one. Only the first, initial seed have to be supplied by environment. The following working example demonstrates it in Verilog:
| Code: | `define SEED 12
module top;
integer reset_num, seed;
initial begin
reset_num = 3;
if ($reset_value == 0)
seed = `SEED;
else
seed = $reset_value;
$display("reset count = %0d, seed = %0d", $reset_count, seed);
$system("move_log"); // move log file to "name".reset_count
if ($reset_count > reset_num)
$finish;
else
$reset(1,seed+1); // alternatives: $reset(1, $random(seed)); etc
end
endmodule
|
Here, environment script "move_log" has to be also implemented in order to save log files for all runs.
Regards,
Alexander Gnusin |
|
| Back to top |
|
 |
yossi_ginzburg Newbie


Joined: Jan 11, 2004 Posts: 4
|
Posted: Wed Nov 03, 2004 7:49 am Post subject: Re: Why would you want your SEED randomized? |
|
|
Alex,
this was exactly my question to bricks:
What was he trying to achieve in randomizing the random SEED? the way I see it (and so do you, Alex, I undestand) there is no added value in that.
Does anyone else see a reason for doing that? |
|
| Back to top |
|
 |
alexg Senior

![]()
Joined: Jan 07, 2004 Posts: 586 Location: Ottawa
|
Posted: Wed Nov 03, 2004 11:32 am Post subject: Re: Why would you want your SEED randomized? |
|
|
| yossi_ginzburg wrote: | Alex,
this was exactly my question to bricks:
What was he trying to achieve in randomizing the random SEED? the way I see it (and so do you, Alex, I undestand) there is no added value in that.
Does anyone else see a reason for doing that? |
I also think that it's good enough to have different (not necessarily random) seeds. However, incrementing by one may be not the best approach, once you exit simulation and enter it again. In this case, you have to extract the seed from the last test run, increment it and supply to the new test. In addition, this will not work for parallel simulation. Setting seeds as a function of the current time of the system clock seems for me as a better approach.
I don't believe that incrementing seed will simplify verification environment: independently of seed definition algorithms, test seed has to be saved somewhere in results directory (for example, in separate file for easier extraction) to be extracted by environment script in case of test case re-run.
Regards,
Alexander Gnusin |
|
| Back to top |
|
 |
srini Senior


Joined: Jan 23, 2004 Posts: 430 Location: Bengaluru, India
|
Posted: Fri Nov 05, 2004 9:28 am Post subject: Re: Why would you want your SEED randomized? |
|
|
| alexg wrote: | | yossi_ginzburg wrote: | Alex,
this was exactly my question to bricks:
What was he trying to achieve in randomizing the random SEED? the way I see it (and so do you, Alex, I undestand) there is no added value in that.
Does anyone else see a reason for doing that? |
I also think that it's good enough to have different (not necessarily random) seeds.
|
I kind of disagree based on my previous full chip verification. We had very complex environment with > 30 K lines of "optimal" e-code, tests were written at level above Transaction based verification (we called it as a "flow" that can have multiple transactions slightly different from each other). What we have seen is with 3 or 4 digit random seeds we encountered certain corner case scenarios that were not seen (with almost no change to the generator portion of the env) with more than 10,000 runs with say 5-digit seed. We used PERL to generate random numbers and drive the env.
From then on, we were quite watchful of the kind of "randomness" we get on the SEED number itself - it was an interesting observation, though things may be different with a different "random generator"/tool.
Just my 2 cents.
Thanks,
Srinivasan _________________ Srinivasan Venkataramanan
Chief Technology Officer, CVC www.cvcblr.com
A Pragmatic Approach to VMM Adoption
SystemVerilog Assertions Handbook
Using PSL/SUGAR 2nd Edition.
Contributor: The functional verification of electronic systems |
|
| Back to top |
|
 |
alexg Senior

![]()
Joined: Jan 07, 2004 Posts: 586 Location: Ottawa
|
Posted: Fri Nov 05, 2004 10:49 am Post subject: Re: Why would you want your SEED randomized? |
|
|
| srini wrote: | | We used PERL to generate random numbers and drive the env. |
http://www.devpapers.com/article/43:
| Quote: |
Truly Random
Use of Perl's rand() function is not advised for cryptographers. The rand() function uses a seed to generate its input, and unfortunately that seed is predictable approximately one third of the time. Check out perldoc -f srand and perldoc -f rand for more information on this. Instead, it's advised that for truly random input, one should use the Perl Module Math::TrulyRandom.
|
Are you using Math::TrulyRandom function?
Regards,
Alexander Gnusin |
|
| Back to top |
|
 |
srini Senior


Joined: Jan 23, 2004 Posts: 430 Location: Bengaluru, India
|
Posted: Fri Nov 05, 2004 10:49 pm Post subject: Re: Why would you want your SEED randomized? |
|
|
| alexg wrote: | | srini wrote: | | We used PERL to generate random numbers and drive the env. |
http://www.devpapers.com/article/43:
| Quote: |
Truly Random
Use of Perl's rand() function is not advised for cryptographers. The rand() function uses a seed to generate its input, and unfortunately that seed is predictable approximately one third of the time. Check out perldoc -f srand and perldoc -f rand for more information on this. Instead, it's advised that for truly random input, one should use the Perl Module Math::TrulyRandom.
|
Are you using Math::TrulyRandom function?
Regards,
Alexander Gnusin |
Thanks for that link and quote, I didn't know that before! I have passed that information to my old colleagues, as I mentioned in my earlier post - I don't work for that group/company any more so can't try and "see" for myself what the result is (:-
Thanks,
Srinivasan _________________ Srinivasan Venkataramanan
Chief Technology Officer, CVC www.cvcblr.com
A Pragmatic Approach to VMM Adoption
SystemVerilog Assertions Handbook
Using PSL/SUGAR 2nd Edition.
Contributor: The functional verification of electronic systems |
|
| Back to top |
|
 |
srini Senior


Joined: Jan 23, 2004 Posts: 430 Location: Bengaluru, India
|
Posted: Mon Nov 08, 2004 12:24 pm Post subject: Re: Why would you want your SEED randomized? |
|
|
| srini wrote: |
Thanks for that link and quote, I didn't know that before! I have passed that information to my old colleagues, as I mentioned in my earlier post - I don't work for that group/company any more so can't try and "see" for myself what the result is (:-
Thanks,
Srinivasan |
Just a quick follow-up. I discussed this with my ex-colleague who is still with the same team, he brought up the point that with the use rand(), though we got "different" seeds, the stimuli generated were kind of "similar" - i.e. more than 10 seeds resulted in failures due to same reasons (though each might manifest and report slightly differently) in a weekly regression. Perhaps this emphasises the need for "truy random" seeds than just "different seeds".
DISCLAIMER: As I mentioned before, this could well be specific to that verif. env. and/or tool/version.
Thanks,
Srinivasan
P.S. I would like to thank Jayakrishna, my ex-colleague (who has also co-authored a paper with me in DCon East 2004) for bringing up this point over the weekend. _________________ Srinivasan Venkataramanan
Chief Technology Officer, CVC www.cvcblr.com
A Pragmatic Approach to VMM Adoption
SystemVerilog Assertions Handbook
Using PSL/SUGAR 2nd Edition.
Contributor: The functional verification of electronic systems |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|