C12.1 Bucket the Address Space

MediumImplementVerilator coverage build · serverReview the topic

Turn a register map into value bins: scalar, array, fixed-count, open-range and write-only bins.

Hardware context: A peripheral with a control register, two status registers, a FIFO window and a memory window on an 8-bit offset. Turn the register map into bins that match each region of the plan.

A peripheral decodes an 8-bit offset. The coverage plan lists what each region needs. The control register needs one bin and each status register its own. The FIFO slots go in three equal groups. The memory window needs a bin, and so do writes to its upper half.

Write the covergroup map_cov with one coverpoint a on addr and exactly the bins in the table.

Signals in the Timeline

SignalWidthRole
samples8input of each check
Full specification
What you write
covergroup map_cov with function sample(bit [7:0] addr, bit write);
  a: coverpoint addr { ... }
endgroup
BinOffsetsBins it makes
ctrl01
stat1 and 2, one bin each2
fifo16 to 63, in 3 bins of 163
mem128 to the largest offset1
mem_wr192 to the largest offset, counted only when write = 11

Offsets 3 to 15 and 64 to 127 are reserved and need no bin. Each case samples a fresh instance and reads get_inst_coverage() times 100, rounded: 3750 means 37.50%. The full check samples more lists than the examples show.

Examples

Example 1

Three Regions
Input
accesses (addr, write): (0, 0) (1, 0) (20, 1)
Output
coverage_percent_x100 = 3750

ctrl, stat[1] and fifo[0]: 3 of 8 bins, 37.50%.

Example 2

Two Reads of the Window
Input
accesses (addr, write): (200, 0) (130, 0)
Output
coverage_percent_x100 = 1250

Both reads land in mem. 200 is in the mem_wr range, but a read does not count there: 1 of 8.

Example 3

A Write Covers Two Bins
Input
accesses (addr, write): (250, 1) (60, 0) (2, 1)
Output
coverage_percent_x100 = 5000

A write of 250 covers mem and mem_wr. With fifo[2] and stat[2], that is 4 of 8.

Constraints and Contract

  • Keep the covergroup name, the sample arguments, the coverpoint name and the bin names.
  • Use one coverpoint and the bin forms the table asks for.

Hints

Hint 1

Brackets after a bin name decide the count: none for one bin, [] for one per value, [N] for N bins.

Hint 2

How many values does each of the three FIFO bins get? Check where 31, 32, 47 and 48 land.

Hint 3

A guard at the end of one bin, iff (...), affects only that bin.

What the grader checks: Your covergroup is sampled with 19 lists of accesses. Its instance coverage is compared with the value IEEE 1800-2023 clause 19 gives for the specified bins. Three lists are shown; the others include every FIFO group boundary and reads in the write-only range.

19 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 2 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

Three Regions

Input
accesses (addr, write): (0, 0) (1, 0) (20, 1)
Expected output
coverage_percent_x100 = 3750

ctrl, stat[1] and fifo[0]: 3 of 8 bins, 37.50%.

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

Verilator coverage build · server