Hi,
while reading the Random Package sources and documentation I wondered why there are overloaded sets of random functions separately for each type (int, signed, unsigned and slv)
What’s the idea behind this?
Wouldn’t overloading allow for a single Random function name covering all kind of types?
e.g if I have some adder code
y<=a+b;
as long as the provided types are valid for the “+” function it just depends on the type declaration of a, b and y what the code actually does.
But then, a testbench using the random package wold need to be reworked if the type declarations change for some reason.
e.g.
–Signed Data feed:
a <= A.RandSigned(...);
b<= B.RandSigned(...);
needs to be changed to
a <= A.RandUnsigned(...);
b<= B.RandUnsigned(...);
while a (fictional) generic overloaded function would provide the correct type according to the assignment destination type:
e.g.
a <= A.Random(...);
b<= B.Random(...);
I mean, that’s what overloading and strict typing is good for, isn’t it?
Are there cases where this wouldn’t work as described, or any other reasons that I did not see?
Kind regards
Eilert