Openvera allowses object-oriented programiming for random stimulus generation subjected to specified constraints.
During randomization, variables declared as rand and randc inside class are only considered for randomization.Built-in randomized() method is called to generate new random values for there variable.
EXAMPLE: class Simple{
randinteger Var;
}
program main {
Simple obj;
obj = new();
repeat(10)
if(obj.randomize())
printf(" Randomization sucsessfull : Var = %0d \n",obj.Var);
else printf("Randomization failed\n");
}
RESULTS:
Randomization sucsessfull : Var = -2147414528 Randomization sucsessfull : Var = -1671855048 Randomization sucsessfull : Var = 1129920902 Randomization sucsessfull : Var = -1374483364 Randomization sucsessfull : Var = 1730349006 Randomization sucsessfull : Var = 1674352583 Randomization sucsessfull : Var = -485282618 Randomization sucsessfull : Var = -103324941 Randomization sucsessfull : Var = 1641506755 Randomization sucsessfull : Var = -1349564321
Random Varible Declaration:
Varibles declared as rand and randc are only randomized.All other varible are considered as state varibles.
EXAMPLE class ex{
rand [3:0] var1;
randc [3:0] var2;
randinteger var3;
}
Fixed Arrays,dynamic arrays,associative arrays and queues can be declared as rand and randc ,all their elements are treated as rand and randc.Individual array elements can also be constrained,in this ,index expression must be constant.For dynamic arryas,the size of the array length can be constrained.Non integral data types like real are not allowed for random varible declaration.
Rand Modifier :
Variables declared with the rand keyword are standard random variables.
When ther are no other control on distrubution,these variables are uniformly distributed.
Uniformly distribution is only on the valid values.
Simulation results shou that the rand variable is distrubuted uniformly.
Randc Modifier :
Varibles declared as randc, randomly iterates over all the values in the range and no value is repeated with in an iteration.
Iteration sequences are not same.Bit and enumarated types can be randc variables.To reduce memory requirements, implementations can impose a limit on the maximum size of a randc variable,but it should be no less than 8 bits.