Question on $random usage in Cadence NC Verilog

D

Doug Hillmer

Guest
I am looking for some help here.

I am running a test bench (that I did not write) that uses the $random
function for generating it's input values. I am running this as a
regression test and of course it is not matching the previous runs of
the test because $random generates random numbers.

In my opinion the proper way to have written this test would have been
to set (and record) a known SEED so the test can be repeated, but that
was not done.

So here is my question. If I know the particular random sequence I want
to see generated can I figure out what SEED I need to use to get that
sequence? How many numbers in the sequence are needed to figure it out?

Thanks for any help.

Doug
 
Doug Hillmer wrote:
I am looking for some help here.

I am running a test bench (that I did not write) that uses the $random
function for generating it's input values. I am running this as a
regression test and of course it is not matching the previous runs of
the test because $random generates random numbers.

In my opinion the proper way to have written this test would have been
to set (and record) a known SEED so the test can be repeated, but that
was not done.

So here is my question. If I know the particular random sequence I want
to see generated can I figure out what SEED I need to use to get that
sequence? How many numbers in the sequence are needed to figure it out?

Thanks for any help.

Doug

In my experience with the NCVerilog, $random always assumes a default
seed and generates the same sequence everytime. So I don't think you
need to guess what that seed is. Hope that helps.
 
Doug Hillmer <hillmer@sdd.hp.com> wrote in message news:<1094832011.757758@hp-sdd.sdd.hp.com>...
I am running a test bench (that I did not write) that uses the $random
function for generating it's input values. I am running this as a
regression test and of course it is not matching the previous runs of
the test because $random generates random numbers.
Actually, it is pseudo-random, and it always starts with the same default
seed value. So running the same simulation repeatedly should always give
you the same result. The random number sequence is also the same as that
used by Verilog-XL, and is now standardized in the IEEE Std 1364-2001.

It is still possible to get different behavior in different simulators or
the same simulator run with different options. The design may contain
race conditions between different processes that call $random. If the
order of the process execution changes, then the order of the calls will
change, and each process will get a different number than it did before,
even though $random is still producing the same sequence.

In my opinion the proper way to have written this test would have been
to set (and record) a known SEED so the test can be repeated, but that
was not done.
It shouldn't be necessary to get repeatability. I don't know why you
are seeing a problem.

So here is my question. If I know the particular random sequence I want
to see generated can I figure out what SEED I need to use to get that
sequence? How many numbers in the sequence are needed to figure it out?
The normal default starting seed value is 0 (which is actually treated
specially and changed to 259341593 before the algorithm is applied).
If you wanted to analyze the algorithm, it is probably possible to work
backward from a few numbers to the seed value. As noted above, the
algorithm has been published. However, you shouldn't need to do that.
 

Welcome to EDABoard.com

Sponsor

Back
Top