What is the difference between $random and $urandom?
What is the difference between $random and $urandom?
Model answer
Both return a 32-bit pseudo-random number on each call. $random returns a signed value. It comes from Verilog, and its optional seed is a variable that the call updates. $urandom returns an unsigned value. It was added by SystemVerilog, and its seed is an optional input. It is thread-stable, so its sequence in one process is not disturbed by random calls in other processes. The signed result matters with modulo. $random % 10 gives -9 to 9. $urandom % 10 gives 0 to 9.