RandomPkg: How to set weight for range
Why OSVVM™? › Forums › OSVVM › RandomPkg: How to set weight for range
Tagged: RandomPkg
- This topic has 4 replies, 3 voices, and was last updated 7 years, 4 months ago by Eilert Backhus.
-
AuthorPosts
-
June 22, 2017 at 12:04 #1387NikolayMember
Hi,
Is it possible to reduce next code:
A <= RndA.DistValSlv(
((0,5),
(1,1),(2,1),(3,1),(4,1),
(5,1),(6,1),(7,1),(8,1),(9,1),
(10,1),(11,1),(12,1),(13,1),(14,1),
(15,5)), A'length);I need to set Weight for range. For example in SV it looks like this:
a dist {0 := 5, [1:4] /= 5, [5:9] /=5, [10:14] /= 5, 15 := 5}
Thanks,
Nikolai
June 26, 2017 at 01:51 #1389Eilert BackhusMemberHi 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
June 28, 2017 at 19:38 #1393Jim LewisMemberHi Nikolai,
There is a simpler form of DistValSlv that returns values in the range of its argument, which is 0 to 15 if the argument is a literal or aggregate:
A <= RndA.DistSlv((5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5), A'length) ;
If you prefer, you can also use named association:
A <= RndA.DistSlv((0=>5, 1=>1, 2=>1, 3=>1, 4=>1, 5=>1, 6=>1,
7=>1, 8=>1, 9=>1, 10=>1, 11=>1, 12=>1,
13=>1, 14=>1, 15=>5), A'length) ;With named association, you can also do the following:
A <= RndA.DistSlv((0=>5, 1 to 14 =>1, 15=>5), A'length) ;
You can also do this with a coverage model:
shared variable ACov : CovPType ;
. . .
process
begin
ACov.AddBins(5, GenBin(0)) ;
ACov.AddBins(1, GenBin(1,14)) ;ACov.AddBins(5, GenBin(15)) ;
. . .
A <= ACov.RandCovPoint ;
ACov.ICoverLast ;Jim
June 28, 2017 at 22:58 #1396NikolayMemberHi Eilert, Jim,
Thank you for the answers. They are very useful for me.
Nikolai
June 28, 2017 at 23:11 #1398Eilert BackhusMemberHi Jim,
I hoped that there’s some solution using the range notation like you showed:
With named association, you can also do the following:
A <= RndA.DistSlv((0=>5, 1 to 14 =>1, 15=>5), A'length) ;
I just didn’t expect it to be so straight simple, since the defined type is self defined.
You mentioned integer_vectors somewhere else. Are these defined internally in a similar way as DistValSlv is? Does this kind of assignment work with integer_vectors too?Kind regards
Eilert -
AuthorPosts
- You must be logged in to reply to this topic.