Jump to content

Trick: Calling new within a constructor's parameter list


Recommended Posts

I extended uvm_algorithmic_comparator class and had some trouble writing its constructor because it insisted that I call super.new first before doing anything else in the body of the constructor function. The problem was I needed the transformer object created first before calling super.new.

My solution was to create the transform object in the argument list of my constructor, rather than trying to do it in the body of the function:

function new(string name, uvm_component parent=null, alu_op_to_result transformer=new());

This worked and the tool allowed it. Just wanted to share this trick with the forum.

-Ed

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...