In build_phase of test, Iam randomizing N value and parameterising Interface with the randomized N value, and setting it to lower components through uvm_cobfig_db.
When I get it, I do not know what is the randomized N value in test for instantiating it. If I try to get with default value, its a compatible error. How to get the parameterised interface in this case? Please help me out
You cannot randomize the value of a parameter because parameter values are set as part of the compilation and elaboration process before simulation starts.
What you can do is randomize N is a separate simulation run, and use that value to set the parameter override in your UVM testbench simulation.
Another option is to forget about randomizing the widths of data and addr and just declare them with a maximum width.
This is fine. My actual intention is, I want to set a parameterized interface from test and get that in driver component. The parameter can be anything. But Iam unaware of it in the driver component. So How do I instantiate my interface and get it properly in the driver?
// in top module
uvm_config_db#(intf#(N))::set(null, "*", "intf", intf_inst);
// in driver class
class driver;
virtual intf#(N) v_intf;
...
if (!uvm_config_db #(intf#(N)))::get(this, "", "", v_intf)) // get config
The problem is N has to be set with the same value at compilation. You get get N from a common package by everywhere replacing N with my_params::N