Is the fixed prototype requirement of the factory essentially is meant to discourage passing arguments through the constructor ?
Sometimes it is very handy to pass an integer through constructor. I am not able to achieve the same through parameters. I think they are fixed at compile time.
program test;
import uvm_pkg::*;
class compA #(int unsigned id = 10) extends uvm_component;
`uvm_component_param_utils(compA#)
//`uvm_component_param_utils(compA#(id))
function new(string name = "compA", uvm_component parent = null);
super.new(name, parent);
endfunction
function void display();
$display("ID = %0d", id);
endfunction
endclass
class env extends uvm_test;
`uvm_component_utils(env)
compA compa_h;
function new(string name = "env", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build();
compa_h = compA#(20)::type_id::create("compa_h", this);
compa_h.display();
endfunction
endclass
initial begin
run_test();
end
endprogram
What is the recommended way to pass information during construction of an object ?
–