>From: "Clifford E. Cummings" <cliffc@sunburst-design.com> >The seed argument shall be an integral variable. The seed value >should be assigned to this variable prior to calling $random. >But I wonder if that is a mistake. Do you have access to any tools >that do not support integral numbers inside of the parentheses? Yes, including Verilog-XL. This is an inout argument, which requires a variable. Allowing a constant is a bug, not a feature. Using a constant will not work properly, and indicates that the user thinks the argument does something other than what it actually does. Tools are not doing you a favor by allowing it. > Seems >like if one uses $random(integral_number), one would always get the >same value returned, which is what I observed. Adding the integral >variable allows $random to change the seed between calls. Yes, if you allowed this and ignored the attempt to write the updated state back to a constant, this is what you would get. It is not useful for random number generation. And trying to do it indicates that the user thinks this is an input seed that will affect later $random calls without a seed, rather than being the state of a separate RNG. To put it in HW-like terms, $random is just the combinational next-state logic of a RNG. The so-called "seed" is the register holding the state of a RNG. Calling $random with a "seed" updates the register to the next state. Calling $random without a "seed" uses a hidden shared register to hold the state. Initializing a "seed" variable to a value has the effect of initializing that RNG's state, which is what seeding does, so it is not completely unreasonable to call it a seed. But it will have no effect on the state of the hidden shared RNG state that is used when no seed is provided. Passing a constant is like connecting the input *and output* of your next-state logic to a constant. >Regarding $urandom(integral_number), from the second paragraph of >18.13.1 (ballot draft): >The seed is an optional argument that determines the sequence of >random numbers generated. The seed can be any integral expression. >The random number generator (RNG) shall generate the same sequence of >random numbers every time the same seed is used. >And the subsequent example shows: addr[32:1] = $urandom(254); The argument to $urandom *is* an input seed, so this is fine. Steven Sharp sharp@cadence.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Jun 11 11:59:42 2009
This archive was generated by hypermail 2.1.8 : Thu Jun 11 2009 - 12:00:23 PDT