RE: [sv-ec] random generator state for shallow copy

From: Daniel Mlynek <daniel.mlynek_at_.....>
Date: Wed Dec 16 2009 - 07:34:12 PST
Yes this is what I know. The problem is with copying RNG state during
shallow copy. Should it be copied or no?
If this is copied then should same values be randomized?
 
DANiel

  _____  

From: Bresticker, Shalom [mailto:shalom.bresticker@intel.com] 
Sent: Wednesday, December 16, 2009 4:27 PM
To: Daniel Mlynek; sv-ec@server.eda.org
Cc: 'Mirek Forczek'
Subject: RE: [sv-ec] random generator state for shallow copy


Hi,
 
The LRM says,
"p2 = new p1;

The last statement has new executing a second time, thus creating a new
object p2, whose class properties are copied from p1. This is known as a
shallow copy. All of the variables are copied across integers, strings,
instance handles, etc. Objects, however, are not copied, only their handles;
as before, two names for the same object have been created. This is true
even if the class declaration includes the instantiation operator new"

Thus since i is a variable, not an object handle, c1.i and c2.i are
independent data objects. If i was an object handle, then c1.i and c2.i
would point to the same object.

Shalom


  _____  

From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org] On
Behalf Of Daniel Mlynek
Sent: Wednesday, December 16, 2009 3:00 PM
To: sv-ec@server.eda.org
Cc: 'Mirek Forczek'
Subject: [sv-ec] random generator state for shallow copy



How should below case work? Object ponited by c2 is created as a shalow copy
from object pointed by c1. Then both get randomized - should values
randomized for c1 and c2 be the same?

class C;
        rand int i,j;
        function new;
                $display("new");
        endfunction
        function void post_randomize;
                $display(i,j);
        endfunction
endclass

module top;
        C c1,c2;
        initial begin
                c1 = new;
                c1.j.rand_mode(0);
                c1.randomize();
                c2 = new c1; //<<<<<<<<<shalow copy
                c1.randomize(); 
                c2.randomize(); //should c1.i be equal c2.i ?????????????
                c1.randomize();
                c2.randomize(); //should c1.i be equal c2.i ??????????????
        end

endmodule


 
 
DANiel

-- 
This message has been scanned for viruses and 
dangerous content by  <http://www.mailscanner.info/> MailScanner, and is 
believed to be clean. 

---------------------------------------------------------------------

Intel Israel (74) Limited



This e-mail and any attachments may contain confidential material for

the sole use of the intended recipient(s). Any review or distribution

by others is strictly prohibited. If you are not the intended

recipient, please contact the sender and delete all copies.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Dec 16 07:37:31 2009

This archive was generated by hypermail 2.1.8 : Wed Dec 16 2009 - 07:39:05 PST