[sv-ec] A question about mixing rand and non-rand handles to the same object

From: William Paulsen <paulsen_at_.....>
Date: Fri Sep 29 2006 - 13:29:09 PDT
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 13:29:08 2006

This archive was generated by hypermail 2.1.8 : Fri Sep 29 2006 - 13:29:25 PDT