Problem: When generating random stimulus, one needs to check that all sought cases have been witnessed. Often, the cases are a subset of a limited set (e.g. a list of register addresses). Creating covergroup for each subset is at most boring copy&paste exercise and creates maintenance nightmare.
IEEE 1800-2012 allows coverpoint bins being specified using set covergroup expressions (Sec. 19.5.1.2). This lets one to define bins from an array. To make it configurable, the array needs to be passed to the coverpoint; covergroup's constructor is the ideal way.
Below is an example of such covergroup:
covergroup CgGivenAddrs(
t_address givenAddrs[$]
) with function sample(
t_address addr
);
given_addrs: coverpoint addr {
bins all_given[] = givenAddrs;
}
endgroup