Welcome ! This website will help YOU (recent graduates/professionals) learn verification languages like SystemVerilog and UVM. Register for free and access more content !
  1. AJIT JAIN
  2. UVM
  3. Saturday, 03 June 2017
uvm new () constructor is non-virtual still how can we override it ? as i know only virtual methods can be overridden ?
Accepted Answer
Accepted Answer Pending Moderation
new function cannot be overriden. Function is overrided only when virtual is used.
new() is a constructor. It should not be overriden. new() is called to create an object.
  1. more than a month ago
  2. UVM
  3. # Permalink
Accepted Answer Pending Moderation
new() is a constructor and will be called when a class object is created and cannot be overridden. If you have something in the new() function that needs to be implemented differently in a child class, a work-around would be to call a virtual method in the new() function of the base class.

class class1;
function new ();
display();
endfunction

virtual function void display ();
$display ("class1: display");
endfunction
endclass

class class2 extends class1;
function new ();
$display ("class2: new()");
endfunction

virtual function void display ();
$display ("class2: display()");
endfunction
endclass

module tb;
initial begin
class2 cls = new();
end
endmodule
  1. more than a month ago
  2. UVM
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. You consent to our cookies if you continue to use our website. To find out more about the cookies we use and how to delete them, see our privacy policy.

  I accept cookies from this site.
Agree
EU Cookie Directive plugin by www.channeldigital.co.uk