Jump to content

Running a parameterized test


Recommended Posts

I have the following test:

class my_test #(parameter type item_t = std_item,

parameter NUM_ANALYSIS_PORTS=DEFAULT_NUM_ANALYSIS_PORTS)

extends base_test;

`uvm_component_param_utils(my_test #(item_t,NUM_ANALYSIS_PORTS))

How do I run the test with defaults for the parameters or otherwise? When I run with "+UVM_TESTNAME=my_test" I get an error "my_test not found". I expected the test would just run with the defaults.

Thanks!

Link to comment
Share on other sites

You would replace the `uvm_component_param_utils macro with its expansion, and ensure the test class is registered in the string-based factory in the expanded code (the macro registers only in the type-based factory). So, your test class would look like:

class my_test #(type item_t = std_item, NUM_ANALYSIS_PORTS = DEFAULT_NUM_ANALYSIS_PORTS) extends base_test;
// -- Replace `uvm_component_param_utils with this:
typedef uvm_component_registry#(my_test#(item_t, NUM_ANALYSIS_PORTS), "my_test") type_id;
static function type_id get_type();
  return type_id::get();
endfunction : get_type
...
endclass : my_test

Then, declare a specialization in the testbench module:

module tb#(parameter type item_t, parameter NUM_ANALYSIS_PORTS);
...
typedef my_test#(item_t, NUM_ANALYSIS_PORTS) whatever;  // A dummy type name.
...
endmodule : tb

The detailed workings is probably beyond the scope of this post, so study the UVM class reference and maybe even the source code if you are really interested. Also, this cookbook recipe was introduced in Mentor's UVM Cookbook, which you can find in their Verification Academy site. I've applied this to my own environment with parameterized tests, and it works perfectly fine.

Link to comment
Share on other sites

hi,

you cant refer to parameterized class via a string type name directly.there are several ways to resolve that.

1. you could register a string name for the param type in the factory

2. you could create a non-param test class instantiating your param test class and then use the non-param class with +UVM_TESTNAME

3. you could derive a non-param class from your param class and reference that

/uwe

Link to comment
Share on other sites

The typedef mentioned by mea1201 will register one string name for all specializations of my_test, and will be an error if there is more than one. You could do

typedef uvm_component_registry#(my_test#(item_t, NUM_ANALYSIS_PORTS), $psprintf("my_test_%0d",NUM_ANALYSIS_PORTS) type_id;
You need to realize that when you declare a parametrized class, it is only a generic template, not a real type. You need have a reference to a parametrized class for it to become real type, a specialization. The only strings that will be registered with the factory are the one that are associated with a specialization.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...