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

From: William Paulsen <paulsen_at_.....>
Date: Wed Feb 22 2006 - 07:37:57 PST
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 07:38:04 2006

This archive was generated by hypermail 2.1.8 : Wed Feb 22 2006 - 07:38:19 PST