If the scope randomize function is called with a class variable as a
parameter, the variables declared within the class as rand or randc are
randomized. The other variables within the class are treated as state
variables and are not modified.
In your example, data and address are random variables, base is a state
variable.
Yes, all the constraints must be satisfied - any explicit constraints of the
scope randomize and any constraints declared within a randomized class.
The LRM description of this is a combination of the description of the scope
randomize function (12.11) and the description for randomization of a class
variable (12.4.8). Based on 12.11 (see below), each class variable in the
argument list of the scope randomize function is a 'starting object' in
determining the random variables and constraints (section 12.4.8).
12.11 third paragraph:
"The scope randomize function behaves exactly the same as a class randomize
method, except that it operates on the variables of the current scope
instead of class member variables."
12.4.8 third paragraph:
The following rules determine which objects, variables, and constraints are
to be randomized:
1) First, determine the set of objects that are to be randomized as
a whole. Starting with the object that invoked the randomize() method,
add all objects that are contained within it, are declared rand, and are
active (see rand_mode in Section 12.7). The definition is recursive and
includes all of the active random objects that can be reached from the
starting object. The objects selected in this step are referred to as
the
active random objects.
2) Next, select all of the active constraints from the set of active random
objects. These are the constraints
that are applied to the problem.
3) Finally, select all of the active random variables from the set of active
random objects. These are the variables that are to be randomized. All other
variable references are treated as state variables, whose current value is
used as a constant.
- Ray
> -----Original Message-----
> From: Francoise Martinolle [mailto:fm@cadence.com]
> Sent: Monday, September 20, 2004 9:28 AM
> To: Ryan, Ray; Francoise Martinolle
> Cc: sv-ec@eda.org
> Subject: RE: [sv-ec] question about randomization
>
> Ray,
>
> in the case of the scope randomize function, do variables
> declared within a class and which do not have the rand or
> randc qualifier get randomized?
>
> class class1
> rand int data;
> int base;
> rand int address;
>
> end class;
> class1 obj1 = new;
>
> initial
> begin
> std::randomize(obj1);
> end
>
> Does base also get assigned random values?
> An additional question is regarding the constraint which
> exist in the class and the constraint which may be provided
> in the std::randomize call.
> Do the random values need to satisfy ALL the constraints?
>
>
>
> Francoise
> '
>
> At 02:18 PM 9/16/2004 -0400, Ryan, Ray wrote:
> >In general,
> >
> >The rand or randc qualifier can only be specified for
> >variables declared in a class. When the built-in
> >'randomize' method of the class is called, the
> >variables with a rand or randc qualifier are assigned
> >random values (also meeting any constraints).
> >
> >Any variable can be randomized by using the scope
> >randomize function (std::randomize). The variables to
> >be randomized are listed as parameters in the
> >call to the scope randomize (eg std::randomize(a, b, c);).
> >
> >- Ray
> >
> > > -----Original Message-----
> > > From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On
> > > Behalf Of Francoise Martinolle
> > > Sent: Thursday, September 16, 2004 10:07 AM
> > > To: sv-ec@eda.org
> > > Subject: [sv-ec] question about randomization
> > >
> > > I thought that variables declared with the rand or randc
> > > qualifier could be randomized.
> > > It seems that variables qualified with rand or randc and
> > > declared as member of a class can be randomized.
> > > Regular variables without qualifier declared inside a module
> > > can also be randomized.
> > > Is that correct?
> > >
> > >
> > > Thanks
> > > Francoise
> > > '
> > >
>
Received on Mon Sep 20 11:31:21 2004
This archive was generated by hypermail 2.1.8 : Mon Sep 20 2004 - 11:31:55 PDT