Bins

Bins are the counters that make up your coverage. Explicitly determining which values belong to which bin gives you granular control over your verification plan.

Simple vs Vector Bins

This is the most critical concept.

  • Merged Bin (default): All values specified are counted into a single bucket.
  • Vector Bin ([]): Creates a separate bucket for each value.
cp_addr: coverpoint addr {
    // Merged Bin: 
    // If we see 0 OR 1 OR 2 OR 3, increment ONE counter.
    bins low = {[0:3]};

    // Vector Bin:
    // Creates 4 separate counters: mid[4], mid[5], mid[6], mid[7].
    // We can track each value individually.
    bins mid[] = {[4:7]};
}

Ignore and Illegal Bins

Use these to filter out values that are irrelevant or forbidden.

cp_cmd: coverpoint cmd {
    bins valid[] = {[0:3]};

    // 1. ignore_bins: Like they don't exist
    // Does not contribute to coverage calculation.
    ignore_bins unused = {4, 5};

    // 2. illegal_bins: The Panic Button
    // If 'cmd' ever becomes 6 or 7, the simulation throws an ERROR.
    // Use this for values that are impossible in correct hardware.
    illegal_bins forbidden = {6, 7};
}

Default Bin

The default bin acts as a "catch-all" for any values not covered by your explicit bins. This is great for spotting values you forgot to cover.

cp_state: coverpoint state {
    bins idle   = {0};
    bins active = {1};
    
    // If state becomes 2 or 3, it lands here.
    bins others = default; 
}

Auto-Distribution with Fixed Number of Bins

You can tell SystemVerilog: "Take this range of 0 to 127, and split it into exactly 4 bins."

cp_data: coverpoint data {
    // 128 possibilities divided into 4 bins.
    // Bin 1: 0-31
    // Bin 2: 32-63
    // Bin 3: 64-95
    // Bin 4: 96-127
    bins quarters[4] = {[0:127]};
}

Common Interview Questions

Q: Why use ignore_bins instead of just leaving the value out?
If you don't define implicit bins (i.e., you are using explicit bins), leaving a value out means it won't be covered, which is fine. However, if you have overlapping definitions or rely on default, ignore_bins takes precedence and explicitly strips those values away, ensuring accuracy.
Q: Can illegal_bins replace assertions?
Conceptually yes, as they both flag errors. However, assertions are for checking protocol correctness over time, while illegal_bins are purely for checking if a sampled value is valid at the moment of sampling. Assertions are generally preferred for protocol checking.