Extending Class Problem

Hello all,
Sorry for silly question.

I want to give constraints to my address fields in TEST FILE.
and the address fields are defined in PACKET CLASS.

I done “class packet_cwdt extends packet;”
and in that class, i have defined a new field, which is address and giving constraints to that field.
Now, i have to randomize my whole transaction, with respect to this constrained address fields.
How can i do it ?
can any one please suggest something ?

i have assigned like this.
“e1.gen.p2rand.add=pkt_cwdt.add;”
e1-> env class object
gen-> generator class object
p2rand-> obj of packet class, which is to be randomize.
add-> field of packet class.

pkt_cwdt-> object of constrained packet class.
add-> field of constrained packet class.

It is hard to understand what you are trying to accomplish based upon what you have provided. Can you post your code along with any relevant log files?

In order to be able to randomize any class variable, you need to make sure that the keyword ‘rand’ is part of the variable declaration. Then, after the class is new’ed, you can call the randomize() function on that class. Any defined constraints will be utilized when randomizing the class variables, and there are several different techniques to change this behavior.