The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Modeling >> Behavioral Models >> Random behavior of $random() in SpectreHDL https://designers-guide.org/forum/YaBB.pl?num=1153119865 Message started by vivkr on Jul 17th, 2006, 12:04am |
Title: Random behavior of $random() in SpectreHDL Post by vivkr on Jul 17th, 2006, 12:04am Hi, I wonder if the $random() function is recomputed each time a new analysis runs. I have an AHDL block where I generate a random number in the "initial" section of the code, and store it in a local variable, which is used in the "analog" section to output a random voltage. The DC output is different when seen by annotating or printing the DC operating point of the circuit, as compared to the DC level seen in the transient analysis. There appears to be no correlation between the quantities either. Is this normal behavior? The core of the code is quite simply: real x; initial{ x=random(); } analog{ V(out) <- vref*x; } Regards Vivek |
Title: Re: Random behavior of $random() in SpectreHDL Post by Geoffrey_Coram on Jul 20th, 2006, 4:18am The LRM says that, since you did not specify a seed, the simulator picks one, and I guess it picks a different one for each analysis. If you want a consistent value, then you should specify a seed. real x; int seed; initial begin seed = 123; x = random(seed); end analog V(out) <+ vref * x; |
Title: Re: Random behavior of $random() in SpectreHDL Post by Andrew Beckett on Jul 24th, 2006, 1:42pm Note, SpectreHDL is end-of-lifed - in fact it has gone in MMSIM61, the latest release of spectre. So don't use it... use Verilog-A. Geoffrey's answer was for Verilog-A. There was a fix recently to do with repeatability of random numbers (I think all instances ended up with the same sequence, when no seed was specified, and that was fixed) - but I can't remember precisely what it was... Andrew. |
Title: Re: Random behavior of $random() in SpectreHDL Post by Geoffrey_Coram on Jul 31st, 2006, 7:21am Andrew Beckett wrote on Jul 24th, 2006, 1:42pm:
Oops, thanks Andrew. I guess I didn't read the subject closely. |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |