Parameterized UVM test

In reply to jjych:

You need to create a parameterized typedef in your testbench so that it can be registered with the factory.

Here is a working example:


import uvm_pkg::*;
`include "uvm_macros.svh"

class mytest#(int NUM) extends uvm_test;
  typedef uvm_component_registry#(mytest#(NUM),$sformatf("mytest#(%1d)",NUM)) type_id;
  static function type_id get_type();
    return type_id::get();
  endfunction

  virtual function uvm_object_wrapper get_object_type();
    return type_id::get();
  endfunction

  const static string type_name = $sformatf("mytest#(%1d)",NUM);
  virtual function string get_type_name();
    return type_name;
  endfunction
  
  function new(string name="mytest", uvm_component parent=null);
    super.new(name, parent);
  endfunction
  //function build_phase
endclass

module testbench();
  parameter NUM = 3;
  typedef mytest#(NUM) mytest_typed;
  
  initial begin
    run_test($sformatf("mytest#(%1d)",NUM));
  end
endmodule