Skip to content

Instantly share code, notes, and snippets.

@brabect1
Created February 26, 2016 06:47
Show Gist options
  • Save brabect1/07f3f0b67337917a0ff8 to your computer and use it in GitHub Desktop.
Save brabect1/07f3f0b67337917a0ff8 to your computer and use it in GitHub Desktop.
Shows how create a reusable covergroup with a coverpoint of configurable bins.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment