Project

General

Profile

Task #5676

[generator] Random generation - weighting / biasing distribution

Added by Andrei Tatarnikov over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
-
Category:
-
Target version:
-
Start date:
03/03/2015
Due date:
% Done:

100%

Estimated time:
Detected in build:
svn
Published in build:
150305

Description

Subj. must be implemented.

Discussion about the randomisation/seeding/biasing/buckets point (Randomisation and seeding / Biasing – not just :min, :max , but buckets):

we were thinking about something available in languages with support for constrained-random activity, like Specman 'e' and SystemVerilog.

For instance this is a SystemVerilog example taken from http://www.asic-world.com/systemverilog/random_constraint7.html :

     constraint src {
       src_port dist {
         0  := 1,
         1  := 1,
         2  := 5,
         4  := 1
       };
     }
     constraint des {
       des_port dist {
         [0   : 5   ] :/ 5,
         [6   : 100 ] := 1,
         [101 : 200 ] := 1,
         [201 : 255 ] := 1
       };
     }

Basically the "dist" construct allows a "distribution" of probability to be specified.

For instance the value of "src_port" can have values 0,1,2,4, where values 0,1,4 all have the same weight whereas value 2 has five times the weight of the others.

As the total sum of all the weights is 8, values 0,1,4 will be extracted 1/8 of the time each (i.e. 12.5%), whereas value 2 will have a probability of 5/8 (i.e. 62.5%).

The second example for "dst_port" is a bit more complex (you can find an explanation of the operators here: http://www.testbench.in/CR_15_CONSTRAINT_EXPRESSION.html ).

Basically all the values comprised for instance in the second range [6:100] will all have a weight of 1 each; whereas those in the first range will share the same weight of 5 (so the six numbers will have a weight of 5/6 each).

Each of these ranges can be considered a "bucket" (but we usually refer to this as "distributions" at the time of generation and "bucketing" at the time of collecting coverage).

In addition of getting generating values match the desired distribution across multiple generated tests, it is desirable to be able to generate exactly the same test again if the generator is invoked with the same randomization seed (typically from the command line).

Please note that the probability distribution doesn't necessarily have to only work with numbers, for instance something like this could be envisaged for load instructions:

     constraint c_LD_instr {
       LD_instr dist {
         LDR   := 1,
         LDRB  := 1,
         LDRH  := 5,
         LDUR  := 1
       };
     }

History

#1

Updated by Andrei Tatarnikov over 4 years ago

  • Status changed from New to Open
  • % Done changed from 0 to 20

The test template construct will look like this:

my_dist = dist range(:value => 10,           :bias => 3),
               range(:value => 10..30,       :bias => 7),
               range(:value => [10, 20, 30], :bias => 2)

add t0, t1, t2 do situation('random', :size => 32,
  :dist => [range(:value=> 1,          :bias => 100), # Single
            range(:value=> 1..3,       :bias => 2),   # Interval
            range(:value=> [1, 10, 3], :bias => 33),  # Collection
            range(:value=> my_dist,    :bias => 7)]   # Distribution
  ) end
#2

Updated by Alexander Kamkin over 4 years ago

Support for randomization constructs has been implemented in Fortress (see the ru.ispras.fortress.randomizer package).

#3

Updated by Andrei Tatarnikov over 4 years ago

  • % Done changed from 20 to 60
#4

Updated by Andrei Tatarnikov over 4 years ago

  • % Done changed from 60 to 80

Implementation is ready r3250. But a good example is needed.

#5

Updated by Andrei Tatarnikov over 4 years ago

  • Status changed from Open to Resolved
  • % Done changed from 80 to 100
#6

Updated by Andrei Tatarnikov over 4 years ago

Working example - r3254

#7

Updated by Andrei Tatarnikov over 4 years ago

  • Status changed from Resolved to Closed
  • Published in build set to 150305

Also available in: Atom PDF