RE: [sv-ec] solve before and randc inconsistency

From: Ryan, Ray <Ray_Ryan@mentor.com>
Date: Thu Nov 18 2010 - 09:42:26 PST

There are two kinds of variable ordering.

1) The priority ordering implied by the randc modified (13.3.2) or
by function arguments (13.4.11)

2) The distribution ordering specified by solve-before constraints
(13.4.9)

 

 

For the priority ordering, the solver is allowed to choose a value for a
higher priority variable before considering constraints relating that
variable to lower priority variables. The higher priority variable is
then considered as a 'state' (constant) value when solving for the lower
priority variables

 

Example 1:

            randomize (x,y) with { x < 10; x > myfunc( y ); }

Here the solver will choose a random value for 'y'. Then call the
function; then attempt to solve for 'x' such that 'x' is less than 10
and greater than the value returned by the function. If the value chosen
for 'y' is greater than 9 there is a conflict when solving for 'x' and
the randomize call will fail. This priority ordering is needed so that
the solver can treat a function as a black box.

Example 2:

            randc bit[2:0] y;

            rand bit[2:0] x

            constraint C1 { y != x; y != 3; }

As decribed in 13.3.2 "Randomize computes an initial random permutation
of the range of values of y, and then return those values in order on
successive calls".

In this case, when selecting the random permutation, the future values
for 'x' are not known. However, it is known that 'y' can never have the
value '3'. So a permutation of the values 0,1,2,4,5,6,7 is chosen. On
each of the 7 successive randomize call the variable 'y' is first
assigned the next value (from the permutation), then 'x' is solved for
with the value for 'y' treated as a state value.

 

In general priority ordering is imposed by the solver (IE needed to make
the solver feasible). However, it can be used to help the solver for
complex sets of constraints by allowing the solver to break the overall
problem in an ordered sequence of smaller, independent problems.
Currently, the only way the User can specify this priority ordering is
by declaring a constraint that as a side effect imposes the desired
ordered (IE through specifying constraints with function calls).

 

----
 
A distribution ordering is specified by the User to effect the
distribution of values chosen by the solver.
Example 3:
            rand bit[2:0] x,y;
 
            randomize ( x, y ) with { x < y }
            randomize ( x, y ) with { x < y; solve x before y; };
 
For BOTH these randomize call, the solution space [ie possible
solutions] for (x,y) is:
(0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (0,7), (1,2), (1,3), (1,4),
(1,5), (1,6), (1,7), (2,3), (2,4), (2,5), (2,6), (2,7), (3,4), (3,5),
(3,6), (3,7), (4,5), (4,6), (4,7), (5,6), (5,7), (6,7)
 
In the first randomize call each of these solutions has the same
likelihood of being chosen.
 
In the second randomize call, the solver is instructed to order the
variables when choosing the solution. In this case, in looking at all
the possible solutions, the variable 'x' can have the values
0,1,2,3,4,5,6. The solver chooses one of these (with each having equal
chance of selection). Say the value 3 is chosen. The variable 'y' then
has the possible values of 4,5,6,7. The solver then chooses one of these
(equal likelihood). 
 
Regards,
Ray Ryan
 
________________________________
From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
Daniel Mlynek
Sent: Thursday, November 18, 2010 8:19 AM
To: sv-ec@eda.org
Subject: [sv-ec] solve before and randc inconsistency
 
I'm having 2 doubts according to variable ordering. Could you please
express yours opinion on them:
1. Ordering of randomization of variable is in general done in 2 cases -
when solve before operator is used and when variable is randc
I'm finding below 2 descriptions defining ordering contradictory
Solve before: "Variable ordering can be used to force selected corner
cases to occur more frequently than they would otherwise. However, a
"solve...before..." constraint does not change the solution space and,
therefore, cannot
cause the solver to fail."
randc: "The semantics of random-cyclical variables requires that they be
solved before other random variables. A set of constraints that includes
both rand and randc variables shall be solved so that the randc
variables are
solved first, and this can sometimes cause randomize() to fail."
In my opinion definition used in randc is correct. In some cases
ordering can cause randomization failure. Lets analyze case like below:
class C;
        rand reg [3:0]r1,r2;
        function void post_randomize;
                $display(" %d %d ",r1, r2);
        endfunction
    constraint c { solve r1 before r2;}
endclass
module top;
        C hnd=new;
        initial begin
                repeat(20)begin
                        assert( hnd.randomize()with {r1>r2; r2>10;
})else $error("randozmiation failed");//here randomizatio should fail if
r1 is randomized 1st then we do not know what value will have r2
                end
        end
endmodule
Summarizing: "constraint does not change the solution space and,
therefore, cannot cause the solver to fail." used in solve before
definition is not true
2. LRM says "Variables that are partially ordered" what does it mean?
what are partially ordered variables?
DANiel
-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is
believed to be clean. 
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Nov 18 09:43:40 2010

This archive was generated by hypermail 2.1.8 : Thu Nov 18 2010 - 09:43:46 PST