Altera_Forum
Honored Contributor
11 years agoHow to generate random numbers in Verilog TB?
As we all know there is a system function $random in Verilog, which can be used to generate the random numbers. I used it in my simulation and call $random() 5 times, then I found each time I simulated, the 10 numbers generated by $random() are always same, I mean e.g.:
The 1st simulation: 1 3 5 6 8 The 2nd simulation: 1 3 5 6 8 So it means although in once simulation, it looks like the random numbers are genrated, but in different simulation, these 5 numbers are always same. I guess this is because $random() needs a seed. But how can I generate a seed in Verilog? Or how can I generate random numbers that change simulation by simulation? Thanks very much.