• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. cloning question

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 65
  • Views 13350
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cloning question

mwhite
mwhite over 13 years ago

I am trying to utilize "clone" so that the cloned data retain the value even after the original data gets updated.  So far it does not work as I expected.

forever begin
  @(posedge clk);
    if (getItemRdy) begin
      myitem_expected.get(myitem_item);
      myitem_expected_cloned.put(myitem_item);
    end
  end

myitem_expected and myitem_expected_cloned are analysis_fifo.
myitem_expected will receive new items asynchronous to this process above.  With this code, my understanding is that myitem_expected_cloned data will change when myitem_expected data changes because the fifos are holding handles.  And that is not what I want.  I want myitem_expected_cloned to change only when getItemRdy is asserted.

forever begin
  @(posedge clk);
    if (getItemRdy) begin
      myitem_expected.get(myitem_item);
      $cast(cloned_item, myitem_item.clone());     
      myitem_expected_cloned.put(cloned_item);
    end
  end

So, I added "$cast" code as above.  I thought myitem_expected_cloned will be updated only when this clone copy gets executed.  But I see new value in myitem_expected_cloned before executing $cast for the 2nd time.

Could anyone help me?  Thank you!

  • Cancel
  • StephenH
    StephenH over 13 years ago

    Based on your examples, I think you may be confused about what the clone() function does. It returns a handle to a new class instance that's a clone of the original. You need to store the cloned class into your long-term storage:

    myitem_expected_cloned.put(cloned_item);

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mwhite
    mwhite over 13 years ago

    Sorry, I had a typo, I was storing the cloned_item instance in my original code.

    It turns out that do_copy method of the sequence_item class had a problem.  The sequence_item class has data members of another class.

    Inside do_copy method:

    instance_of_another_class = rhs.instance_of_another_class;  // This does not work

    instance_of_another_class.data_member = rhs.instance_of_another_class.data_member;  // This works

     

    But this class has to know all the data members below this class member.  This seems to go against OOP way.  It is not clear to me how to implement deep copy of class objects.  I was not able to find any example.

    Thanks.

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information