RE: [sv-ec] A question about randomize and non-rand class handle members

From: Arturo Salz <Arturo.Salz_at_.....>
Date: Wed Feb 22 2006 - 11:36:37 PST
Paul,

I believe the LRM needs work in this respect. Your question is not
limited to classes, but it also applies to nested structures:

typedef struct { rand int a; } s_a;

struct {
  s_a   a;	// is this randomized
  rand int b;
}

I think the easiest solution would be to treat structures and classes as
orthogonal constructs. Then, a struct that is not declared as rand will
not be randomized, even if it includes rand members. However, when the
randomize operator is applied to the struct (which is itself not
declared as a rand member) then all its rand-declared members are
randomized.

	Arturo
 
-----Original Message-----
From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
William Paulsen
Sent: Wednesday, February 22, 2006 7:38 AM
To: Rich, Dave; sv-ec@eda.org
Subject: RE: [sv-ec] A question about randomize and non-rand class
handle members

Thanks,
But please consider something similar for structs.  If a struct member
is rand, but the struct object in a class is not rand, does the struct
member get randomized?

EG, does c1.s1.i1 get randomized in a c1.randomize() call?

If so, then I would expect classes to have similar behavior.

If not, then what's the purpose of allowing a rand qualifier on a struct
member?

Bill



module top;

typedef struct {
  rand integer i1;  // Does this get randomized?
  integer i2;
} struct_t;

class class1;
  struct_t s1; // Note this is not rand
endclass

integer r;
class1 c1 = new;

initial begin
  r = c1.randomize();
end
endmodule

 

-----Original Message-----
From: Rich, Dave [mailto:Dave_Rich@mentor.com] 
Sent: Wednesday, February 22, 2006 10:21 AM
To: William Paulsen; sv-ec@eda.org
Subject: RE: [sv-ec] A question about randomize and non-rand class
handle members

No, only if the declaration of c1 was rand.

rand class1 c1;

See 13.3

> -----Original Message-----
> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of 
> William Paulsen
> Sent: Wednesday, February 22, 2006 5:23 AM
> To: sv-ec@eda.org
> Subject: [sv-ec] A question about randomize and non-rand class handle 
> members
> 
> 
> Here's a question about randomization:
> 
> In this example, should c2.c1.i1 be randomized?  Ie, must randomize 
> dereference all handle members in a class and solve all rand members
of
> those classes? (and also recurse)
> 
> Thanks,
> Bill Paulsen
> 
> 
> 
> module top;
> 
> class class1;
>   rand integer i1;
> endclass
> 
> class class2;
>   class1 c1;  // Note there's no rand qualifier endclass
> 
> integer r;
> class2 c2 = new;
> 
> initial begin
>   r = c2.randomize();
> end
> endmodule
Received on Wed Feb 22 11:36:44 2006

This archive was generated by hypermail 2.1.8 : Wed Feb 22 2006 - 11:37:05 PST