I have a class that is widely reused similar to the following:
virtual class my_reuse_class#(type A=int) extends uvm_component;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunciton
pure virtual function void my_function(A my_attribute);
endclass
There is now need for more functionality and I want to be able to pass in additional typed parameters without hurting the backwards compatibility with previous usage. Is it possible to give a “pass by type parameter” a default value, so that older code will not need to be modified to work with the new class? For example:
virtual class my_reuse_class#(type A=int, type B=int=0) extends uvm_component;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
pure virtual function void my_function(A my_attribute, B my_new_attribute);
endclass
class my_old_class extends my_reuse_class(logic[1:0]);
virtual function void my_function(A my_attribute);
// do stuff
endfunction
endclass
class my_new_class extends my_reuse_class(logic[1:0], string);
virtual function void my_function(A my_attribute, B my_new_attribute);
// do more stuff
endfunction
endclass
Thank you