quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Distributions Constraints

When weight based randomization is required in Vera, we can use Distribution.

   

space.gif

Syntax

   

space.gif

expression dist {value_range_ratio_list};
   

space.gif

Where

   

space.gif

  • expression : Can be any Vera expression that refers to at least one variable declared as rand.
  • dist: The dist operator returns true if the expression is contained in the set; otherwise it returns false.
  • value_range_ratio_list : Is a comma-separated list of ranges, expressed through integers, enumerated types, or bit vectors. The format of a list element is: min[:max ][:= weight | :/ weight]
    • min[:max] : Is a range of values if max included. Otherwise, the value of the expression is min.
    • := weight : The := operator assigns weight to the item, min, or if there is a range (that is, min:max), to every value in the range (that is, all) elements in the range get the weight. weight may be any Vera expression).
    • :/ weight : The :/ operator divides the value of weight and assigns equally among all elements in the range. If there are n values in the range, the weight of each value is range_weight/n. (weight may be any Vera expression).
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Distributions
   

space.gif


  1 class frame_t {
  2   rand bit [7:0] src_port;
  3   rand bit [7:0] des_port;
  4   rand bit [15:0] length;
  5   constraint len {
  6     length dist {
  7       64  :  127  := 10,
  8       128 :  511  := 10,
  9       512 :  2048 := 10
 10     };
 11   }
 12   constraint src {
 13     src_port dist {
 14       0  := 1,
 15       1  := 1,
 16       2  := 5,
 17       4  := 1
 18     };
 19   }
 20   constraint des {
 21     des_port dist {
 22       0   : 5    :/ 5,
 23       6   : 100  := 1,
 24       101 : 200  := 1,
 25       201 : 255  := 1
 26     };
 27   }
 28 }
 29 
 30 program distribution {
 31    frame_t frame = new();
 32    integer i,j = 0;
 33    for (j=0;j < 4; j++) {
 34      printf("-------------------------------\n");
 35      printf("Randomize Value\n");
 36      i = frame.randomize();
 37      frame.object_print();
 38    }
 39    printf("-------------------------------\n");
 40 }
You could download file distribution.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output : Distributions
   

space.gif

 -------------------------------
 Randomize Value
     src_port            : hex: 00
     des_port            : hex: e0
     length              : hex: 0324
 -------------------------------
 Randomize Value
     src_port            : hex: 02
     des_port            : hex: d0
     length              : hex: 0046
 -------------------------------
 Randomize Value
     src_port            : hex: 01
     des_port            : hex: 77
     length              : hex: 026a
 -------------------------------
 Randomize Value
     src_port            : hex: 01
     des_port            : hex: 6f
     length              : hex: 0578
 -------------------------------
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com