Random number generation in testbench

Oct 28, 2004 2 Replies

Back ground info : Using Modelsim in Windows environment, using Verilog.



I'm trying to generate a random number that's different each time $random is called. Not knowing much about DOS/windows environment, I need help passing in wallclock information from the command line (in a does batch file).



Doing



dos prompt> vsim +SEED='time' ...



and using in the testbench



if (!($value$plusargs("SEED=%d", rand_seed)) ...



doesn't work because the wallclock time isn't passed in correctly. I don't want to use the same starting seed each time the simulation is run, either. I'll, of course, save the seed so that I can reproduce the bugs.



How do I get around this problem? How do you use random data pattern in your test bench?



I don't have an option of using unix (or unix-like shell in windows)...



Thanks in advance.


You can always find some sort of Perl or Python for Windows to convert wallclock time to a number and then launch vsim from it.

Best regards,

Ben

there is a uniform(seed1,seed2,rand_v); in ieee It will generate a random number each time it is called. the seed values we keep in a small text file, and using standard io calls, read, increment, and save the numbers each time the simulation is started. This gives a random stream of data each time a restart is done.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required