grai Posted April 24, 2012 Report Share Posted April 24, 2012 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! Quote Link to comment Share on other sites More sharing options...
mea1201 Posted April 24, 2012 Report Share Posted April 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
uwes Posted April 24, 2012 Report Share Posted April 24, 2012 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 Quote Link to comment Share on other sites More sharing options...
dave_59 Posted April 24, 2012 Report Share Posted April 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
grai Posted April 26, 2012 Author Report Share Posted April 26, 2012 Thanks to all for the excellent suggestions! Quote Link to comment Share on other sites More sharing options...
uwes Posted April 30, 2012 Report Share Posted April 30, 2012 the shortcut for the code above is: `uvm_component_registry(my_test#(item_t, NUM_ANALYSIS_PORTS), "my_test") Quote Link to comment Share on other sites More sharing options...
dave_59 Posted April 30, 2012 Report Share Posted April 30, 2012 Uwes, Again, your code will only register one string "my_test" for all specializations and will generate an error if there is more than one specialization. Dave Quote Link to comment Share on other sites More sharing options...
uwes Posted April 30, 2012 Report Share Posted April 30, 2012 yes, i know - however it gives a string "my_test" which can be used as the type key in the factory (unless as you say there are multiple specializations) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.