|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



VARIABLE ORDARING

Variable Ordaring



openvera allows to control the order of randomization variables.The solution space remains the same,but the probabulity of picking up the values changes.the syntax for variable ordering is "solve x before y".The exact meaning of this statement is "choos x befor y" as the this state ment if to guide the distribution,but not the solution space.
Only rand variables are allowed.


EXAMPLE:
class Var_order{
rand bit a;
rand bit [3:0] b;
constraint bidirectional { a -> b == 0; }}


The probabulity of a=1 is 1/2**5,as bidirectional constraints are solved at once,the solver pics the random value from the possible set of {a,b} which has 2**5 solutions.To make the probability of a= 0 to 50% and a = 1 to 50% ,use


constraint order { solve Var1 before Var2 ;}


This guides the solver to give highest priority to Var1 than Var2.This is explicit variable ordaring.The solver follows the implicit variable ordaring also,like randc are solved before rand variables,in dynamix arrays size and elements are solved with two constraints,and size is solved before element.


class var_order{
rand bit Var;
rand bit [3:0] b;
constraint c { if(Var == 0) (b == 1); }
constraint order { solve Var before b ;}

}

program var_order_{
var_order obj;
integer count_0 ,count_1,i ;
obj=new();
count_0 = 0;count_1 = 0;
for(i=0; i< 10000; i++)
{
obj = new();
if( obj.randomize())
{
if( obj.Var == 0 ) count_0 ++;
else if( obj.Var == 1 ) count_1 ++;
}}
printf(" count_0 = %0d;count_1 = %0d;",count_0 ,count_1);
}
RESULTS:

count_0 = 5120;count_1 = 4880




Too many explicit variable ordering may lead to circular dependency.The LRM says that "Circular dependencies created by the implicit variable ordering shall result in an error." and "circular dependency is not allowed".
But it does not put restriction on what to do if a explicit circular dependency exists.Check with your tool,if explicit Circular dependency is existing,it may report warning,it may fail solver or proceed by just ignoring the order.


EXAMPLE:
program Cir_Dip_p{
class Cir_Dep;
rand integer a,b,c;

constraint a_c { solve a before b ;}
constraint b_c { solve b before c ;}
constraint c_c { solve c before a ;}
}

Cir_Dip obj=new();
void = obj.randomize();
}
Index
Introduction
Data Types
Linked List
Operators Part 1
Operators Part 2
Operators Part 3
Operator Precedence
Control Statements
Procedures And Methods
Interprocess
Fork Join
Shadow Variables
Fork Join Control
Wait Var
Event Sync
Event Trigger
Semaphore
Regions
Mailbox
Timeouts
Oop
Casting
Randomization
Randomization Methods
Constraint Block
Constraint Expression
Variable Ordaring
Aop
Predefined Methods
String Methods
Queue Methods
Dut Communication
Functional Coverage

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright 2007-2017 :: all rights reserved www.testbench.in::Disclaimer