Reply To: Support for large SLV/signed/unsigned?

Why OSVVM™? Forums OSVVM Support for large SLV/signed/unsigned? Reply To: Support for large SLV/signed/unsigned?

#438
Jim Lewis
Member

I have some second thoughts.

While multiple draws on the same seed will remain uniform, you will need to be careful about how you construct the number as that may cause the number to be non-uniform.

Consider the small example done in two 4 bit pieces:   randomize a number between 0 and 16#A3#.  If you first randomize the upper nibble as 0 to A.  If the result is between 0 and 9, then randomize the lower between 0 and F, otherwise randomize the lower between 0 and 3.  This will result in the numbers A0, A1, A2, and A3 higher frequency (4X) of occurrence the other values.   

I think this would work: randomize the upper word with the range constrained.  Randomize the lower word(s) without the range constrained.  If the resulting value is not within the range, then repeat the steps again until a value in range is found.