Regarding Cover group and cover point modification

Hi,
I have defined a parameterized covergroup in a class, where i am controlling the inside cover points.and the range also from outside.

covergroup cg_1(ref logic [3:0] pid, ref logic [3:0] mid, ref int N, ref int M, ref string pid_str,ref string mid_str);

pid_str:coverpoint pid {
bins cov_a = {[0:N]};
}

mid_str:coverpoint mid {
bins cov_b = {[0:M]};
}
endgroup

Now, i have a case statement, which is to be switched to different port name of design. and i need to sample the pid,mid for different ports at that clock edge using sample().And i am passing the string name in Covergroup to reuse the same covergroup.

What are the possible ways to do that?

I tried changing the cover point name “pid_str:” to be replaced by the string i am passing in cover group, but that is static so,not possible/not changing.

In reply to Mayank@Tyagi94:

You can’t use strings to create identifiers. I’m having trouble understanding what you want to accomplish.