Assign parameter in interface

Hi
I have a module with parameter:

module a #(parameter N=32);

the instance is:

parameter NUM = 20;
a #(.N(NUM)) a_i;

now, I want to use the parameter ‘N’ during the verification of the module. I want to take that number (20) from aaninterface. I want it to as generic as possible, meant not write it directly, but took it from the rtls’ parameter.
How can I assign variable from the interface to the rtl, so I’ll have the right number (20 and not 32)?
Thanks!

It is very hard to follow what you are asking. Where is this interface in relation to the code shown? What are looking to do with the parameter N? Please show as much code as possible that recreates your situation.

Hi Dave, thanks for the reply.
I want to use ‘N’ for:
bus length for coverage sample:

bit [N-1 : 0] var1;
var1 = if1.var1;
...
coverpoint var1{bins var1 = {1};}

also, I will use it as a limit in for loop:

int upper_limit = if1.N;
for (int i = 0; i < upper_limit; i++)

currently I use the interface like that:

interface if1 #(parameter N = 20)
logic [N - 1 : 0] var1;
logic [N - 1 : 0] var2;

I want to connect the parameter from the interface directly to the wrapper of the module. This doesn’t work:

interface if1 #(parameter N = a_wrap.NUM)

due to parameter RHS issue.

That is still not enough context. What is this “wrapper of the module”?

Thank again for the reply.

The ‘wrapper of the module’ is the module that creates the instance to module ‘a’. There the parameter N gets its’ value.

parameter NUM = 20;
a #(.N(NUM)) a_i;

I want that the interface will take ‘NUM’.

Where is the interface if1 being instantiated?

A better practice is define module/interfaces without values and giving them values when instantiating them as you have with module a.

interface if1 #(parameter int N);
  logic [N - 1 : 0] var1;
  logic [N - 1 : 0] var2;