Hi Billy,
The code below works for me. You will get a warning from the UVM, but that is a symptom of the factory and parameterized classes - you can ignore it.
In the snippet:
case (i)
0: begin
$display("Making 7");
//c = p7::type_id::create("p7", this);
c = parameterized_class#(7)::type_id::create("p7", this);
end
1: begin
$display("Making 1000");
//c = p1000::type_id::create("p1000", this);
c = parameterized_class#(1000)::type_id::create("p1000", this);
end
endcase
there are TWO possible solutions. One is the code as you wrote it. The other code is a non-parameterized wrapper around the parameterization (the commented out lines creating a 'c'). The wrappers are the class definitions 'p7' and 'p1000'. Personally, I don't prefer the wrapper. I prefer the code the way you wrote it.
Best regards,
rich
import uvm_pkg::*;
`include "uvm_macros.svh"
class parameterized_class #(int T = 42) extends uvm_component;
`uvm_component_utils(parameterized_class#(T))
function new(string name = "p", uvm_component parent = null);
super.new(name, parent);
endfunction
task run_phase(uvm_phase phase);
$display("Class parameterized_class#(%0d) running", T);
endtask
endclass
class p7 extends parameterized_class#(7);
`uvm_component_utils(parameterized_class#(7))
function new(string name = "p#(7)", uvm_component parent = null);
super.new(name, parent);
endfunction
endclass
class p1000 extends parameterized_class#(1000);
`uvm_component_utils(parameterized_class#(1000))
function new(string name = "p#(1000)", uvm_component parent = null);
super.new(name, parent);
endfunction
endclass
class env extends uvm_env;
`uvm_component_utils(env)
function new(string name = "env", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
uvm_component c;
for (int i = 0; i < 2; i++) begin
case (i)
0: begin
$display("Making 7");
//c = p7::type_id::create("p7", this);
c = parameterized_class#(7)::type_id::create("p7", this);
end
1: begin
$display("Making 1000");
//c = p1000::type_id::create("p1000", this);
c = parameterized_class#(1000)::type_id::create("p1000", this);
end
endcase
c.print();
end
endfunction
task run_phase(uvm_phase phase);
phase.raise_objection(this);
$display("Running env");
phase.drop_objection(this);
endtask
endclass
module top();
initial
run_test("env");
endmodule