Ray,
I believe both the text and the example are correct.
That particular sentence describes the behavior of rand_mode when applied to a class that contains random handles. Consider the following example:
class Foo;
rand int value;
endclass
class Bar;
rand int value;
rand Foo handle;
endclass
int ret;
Bar b = new;
b.handle = new;
// Turn off all variables in object
b.rand_mode(0);
According to that sentence in the LRM the random disposition of the two objects is as follows:
b.value; => not random (off)
b.handle => not random (off)
b.handle.value => random (on)
In order to change the random mode of the embedded object, the following is needed:
Foo tmp = b.handle;
tmp.rand_mode(0);
Therefore, according to this, the value of ret in the LRM example is 0.
I hope this clarifies the text.
Arturo
----- Original Message -----
From: Ryan, Ray
To: sv-ec@eda.org
Sent: Thursday, December 09, 2004 10:37 AM
Subject: [sv-ec] Conflicting descriptions of rand_mode
In section 12.7 the 'rand_mode' method is defined.
The 8th paragraph states:
If the random variable is an object handle, only the mode of the variable is changed, not the mode of random variables within that object (see global constraints in Section 12.4.8).
However, just below that, the example and text contradict the above statement.
Example:
class Packet;
rand integer source_value, dest_value;
... other declarations
endclass
int ret;
Packet packet_a = new;
// Turn off all variables in object
packet_a.rand_mode(0);
// ... other code
// Enable source_value
packet_a.source_value.rand_mode(1);
ret = packet_a.dest_value.rand_mode();
This example first disables all random variables in the object packet_a, and then enables only the source_value variable. Finally, it sets the ret variable to the active status of variable dest_value.
So in the example, what is the correct value for 'ret' ?
- Ray
Received on Thu Dec 9 11:45:31 2004
This archive was generated by hypermail 2.1.8 : Thu Dec 09 2004 - 11:45:36 PST