When ch2.randomize() is called, the set of random objects and constraints initially consists of all the random members and constraints of ch2. These are: Random variables: ch2.rint2 ch2.rch1 Constraints: ch2.con2 {ch2.rint2 == ch2.ch1.rint1;} Because ch2.rch1 is random and is a class handle, its random members and constraints are added to the randomization. So the random variable and constraints become: Random variables: ch2.rint2 ch2.rch1.rint1 Constraints: ch2.rch1.con1 { ch2.rch1.rint1 == 10; } ch2.con2 {ch2.rint2 == ch2.ch1.rint1;) A reference to a variable in a constaint does not make it 'rand'. So yes, for this randomization, ch2.ch1.rint1 is a state value. Ray > -----Original Message----- > From: owner-sv-ec@server.eda.org > [mailto:owner-sv-ec@server.eda.org] On Behalf Of William Paulsen > Sent: Friday, September 29, 2006 1:29 PM > To: sv-ec@server.eda-stds.org > Subject: [sv-ec] A question about mixing rand and non-rand > handles to the same object > > > Section 13.4.8 of the LRM is not clear (to me) about the > following scenario. > Does there need to be an explanation or clarification added > to the LRM for this? > > Thanks, > Bill > > > In the example below, two constraint expressions contain > references to the same property (rint1) of the same class > (class1) object instance. > > In class2, constraint "con2" has the reference "ch1.rint1", > where "ch1" > is not a rand handle. > > In class1, constraint "con1" has the reference "rint1", > where "rint1" > is rand. > > Is "ch1.rint1" in constraint "con2" considered a state > variable, or is it one of the "active random objects?" > > One possibility is that in constraint "con2", "rint1" is a > state variable, whose value is not subject to generation, > since "ch1" is not rand. > > The other possibility is that since "ch2.ch1.rint1" is the > same property as "ch2.rch1.rint1", then it should be > considered rand even in the context of constraint "con2". > > module top; > > class class1; > rand int rint1; > constraint con1 { rint1 == 10;} > endclass > > class class2; > rand int rint2; > class1 ch1; > rand class1 rch1; > constraint con2 { rint2 == ch1.rint1; } // What value is > rint2 set to? > endclass > > class2 ch2 = new; > int res; > > initial begin > ch2.ch1 = new; > ch2.rch1 = ch2.ch1; // The same object > > ch2.ch1.rint1 = 20; > > res = ch2.randomize(); > > if (ch2.rint2 == 20) $display("ch2.ch1 is considered non-rand"); > if (ch2.rint2 == 10) $display("ch2.ch1 is considered > rand"); end endmodule > > >Received on Fri Sep 29 14:34:04 2006
This archive was generated by hypermail 2.1.8 : Fri Sep 29 2006 - 14:34:21 PDT