Fix VL_RANDom to better randomize bits.

This commit is contained in:
Wilson Snyder 2009-01-21 13:52:51 -05:00
parent 4beaa45199
commit 057928b079
3 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix compile issues with GCC 4.3, bug47. [Lane Brooks]
**** Fix VL_RANDom to better randomize bits. [Art Stamness]
* Verilator 3.700 2009/01/08
** Add limited support for tristate inouts. Written by Lane Brooks.

View File

@ -633,6 +633,12 @@ will call a function to determine the value, this allows randomization of
all Xs to find reset bugs and is the slowest, but safest for finding reset
bugs in code.
If using -x-assign unique, you may want to seed your random number
generator such that each regression run gets a different randomization
sequence. Use the system's srand48() or for Windows srand() function to do
this. You'll probably also want to print any seeds selected, and code to
enable rerunning with that same seed so you can reproduce bugs.
=back
=head1 VERILOG ARGUMENTS

View File

@ -73,9 +73,9 @@ void vl_fatal (const char* filename, int linenum, const char* hier, const char*
IData VL_RAND32() {
#if defined(_WIN32) && !defined(__CYGWIN__)
// Windows doesn't have lrand48(), although Cygwin does.
return (rand()<<16) | rand();
return (rand()<<16) ^ rand();
#else
return (lrand48()<<16) | lrand48();
return (lrand48()<<16) ^ lrand48();
#endif
}