Reply To: RandomPkg: How to set weight for range

Why OSVVM™? Forums OSVVM RandomPkg: How to set weight for range Reply To: RandomPkg: How to set weight for range

#1389

Hi Nicolai,

the argument type of DistValSlv is an array with a record of two integers.

I wonder wether the range notation can work here too.

It wold look somewhat like this:

A <= RndA.DistValSlv(
       ((0,5),
        (1 to 14,1),
        (15,5)), A'length);

If this works not, maybe a function with a case statement can help.

In the function you then write sth. like this:

for position in 0 to 15 loop — 15 might come from some ‘lengh calculation
  case position is
    when 0 =>  ReturnVal(position,5);
    when 1 to 14 =>ReturnVal(position,1);
    when 15 =>ReturnVal(position,5);
  end case;
end loop
return ReturnVal;

Unless there isn’t some better solution, this might at least be a useful  workaround for the moment.

(edit:) But actualy that won’t reduce the code much, unless you have a really big array of random constraints.

Have a nice simulation

  Eilert