In 8.11 the LRM states: A shallow copy executes in the following manner: 1) An object of the class type being copied is allocated. This allocation shall not call the object's constructor or execute any variable declaration initialization assignments. 2) All class properties, including the internal states used for randomization and coverage are copied to the new object. Object handles are copied; this includes the object handles for covergroup objects (see Clause 19). An exception is made for embedded covergroups (see 19.4). The object handle of an embedded covergroup shall be set to null in the new object. The internal states for randomization include the random number generator (RNG) state, the constraint_mode status of constraints, the rand_mode status of random variables, and the cyclic state of randc variables (see Clause 18). 3) A handle to the newly created object is assigned to the variable on the left-hand side. So Yes, the RNG state is copied and the same values should be randomized. Ray ________________________________ From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org] On Behalf Of Daniel Mlynek Sent: Wednesday, December 16, 2009 7:34 AM To: 'Bresticker, Shalom'; sv-ec@server.eda.org Cc: 'Mirek Forczek' Subject: RE: [sv-ec] random generator state for shallow copy 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 MailScanner <http://www.mailscanner.info/> , 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 <http://www.mailscanner.info/> , and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Dec 16 08:12:56 2009
This archive was generated by hypermail 2.1.8 : Wed Dec 16 2009 - 08:14:52 PST