C23.2 Rare Events Need More Hits

MediumImplementVerilator coverage build · serverReview the topic

Make rare events count only after four occurrences and weigh them double, with options set where the coverage build honours them.

Hardware context: A buffer that reports normal operations and rare underflow and overflow events. Count rare events only after four occurrences and weigh them double.

A buffer reports an event code each cycle it does something. Codes 1 to 6 are normal operations, 0 an underflow and 7 an overflow. Underflow and overflow are rare, and the plan wants each seen four times before it counts, with the pair weighted double.

Write the covergroup ev_cov.

Signals in the Timeline

SignalWidthRole
samples8input of each check
Full specification
CoverpointBinsOptions
commonnormal[]: one per code 1 to 6defaults
rareunderflow = 0, overflow = 7weight 2; each bin needs 4 hits

Each case samples a fresh instance and reads get_inst_coverage() times 100, rounded. The full check samples more lists than the examples show.

Examples

Example 1

One Overflow
Input
event codes: 1 2 3 7
Output
coverage_percent_x100 = 1667

common 3 of 6 (50%); one overflow is not enough, so rare is 0%: (50 + 0 x 2) / 3 = 16.67%.

Example 2

Four Overflows
Input
event codes: 7 7 7 7 4
Output
coverage_percent_x100 = 3889

overflow is covered: rare 50%. common 1 of 6: (16.67 + 50 x 2) / 3 = 38.89%.

Example 3

Two of Each
Input
event codes: 0 7 0 7 5 6
Output
coverage_percent_x100 = 1111

Neither rare bin has four hits. common 2 of 6: 11.11%.

Constraints and Contract

  • Keep the covergroup, coverpoint and bin names.
  • The coverage build ignores option.at_least set in the covergroup (lesson C23): set it in the coverpoint.

Hints

Hint 1

Which coverpoint needs at_least, and which does not?

Hint 2

A weight of 2 on rare makes it count twice in the average.

Hint 3

Count the hits of 0 and of 7 separately.

What the grader checks: Your covergroup is sampled with 18 lists of event codes. Its instance coverage is compared with the value IEEE 1800-2023 19.7 and 19.11 give. Three lists are shown.

18 checks on Verilator coverage build · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 3 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

One Overflow

Input
event codes: 1 2 3 7
Expected output
coverage_percent_x100 = 1667

common 3 of 6 (50%); one overflow is not enough, so rare is 0%: (50 + 0 x 2) / 3 = 16.67%.

Run samples executes all 3 public checks. Check all tests runs 18 checks on the server.

Verilator coverage build · server