Reply To: Negative weights and index range in DistInt(weights)?
Why OSVVM™? › Forums › OSVVM › Negative weights and index range in DistInt(weights)? › Reply To: Negative weights and index range in DistInt(weights)?
Jim,
Thanks for your quick response.
I found the issues while reading the source code.
I don’t have any uses for negative weights, and I’m not really sure conceptually how they would work anyway, but I’m not sure that others won’t have a use for them. If there is a viable usage model for negative weights, then we should either support it or error out (like we do for all-zero weights).
The other (3rd?) issue I brought up was that it would be useful to return a result within the index range of the Weight array supplied, rather than always returning 0 to ‘length – 1.
I think it would add useful utility/flexibility, and would not cause problems with most existing code. It would simplify many use cases that currently require supplying value-weight pairs, and would allow use of “others” in those cases too.
Example:
constant weighting : integer_vector(8 to 15) := (9 => 25, 13 => 51, others => 4);
variable value : natural range weighting’range;
…
value := myRnd.DistInt(weighting); — returns value in weighting’range
Andy