[sv-ec] proposal for mantis #1382 - shallow copy

From: Ryan, Ray <Ray_Ryan_at_.....>
Date: Thu Apr 06 2006 - 16:11:57 PDT
Attached is a proposal for mantis #1382 - to clarify the behavior of a
shallow copy.

The motivation behind the proposal is that a shallow copy is intended to
create a clone of the original object. Thus the implicit state should
also be copied - including the RNG state, the constraint_mode and
rand_mode status bits, and the cyclic state of randc properties.

The proposal also clarifies that a shallow copy does not execute the new
method or any initialization assignments. It also attempt to clarify
that the shallow copy is similar to a virtual method (ie makes a copy of
the instance).

In the case:

  class A;
    int j;
    function new();
	$display("New A");
    endfunction
    function int foo();
      $display("foo");
	return 0;
    endfunction
    covergroup covA @clk;
      coverpoint j;
    endgroup
  endclass
  class C extends A;
    rand int x,y;
    int x = foo();
  endclass;

  A va1, va2;
  C vc;
  initial begin
    vc = new;		// create instance of 'C'
    va1 = vc;
    va2 = new va1;	// create, copy an object of type 'C'
    ...
  end

the shallow copy creates an object of type 'C' and stores the reference
in variable 'va2'.
The constructor of 'C' is not called. The function 'foo' in the
initialization assignement
for 'x' is also not called. Finally, va2.covA references the same
coverpoint instance
as va1.covA. This coverpoint instance covers the value va1.j.

- Ray

Received on Thu Apr 6 16:12:04 2006

This archive was generated by hypermail 2.1.8 : Thu Apr 06 2006 - 16:12:14 PDT