C11.1 Cover the Derived Value

MediumImplementVerilator coverage build · serverReview the topic

Cover the region a burst starts in and where its last byte lands, and skip retried bursts.

Hardware context: A DMA engine that moves 1- to 8-byte bursts inside a 256-byte window with four address regions. Cover the region and the last byte of each new burst, values computed from the address and length.

A DMA engine moves bursts of 1 to 8 bytes inside a 256-byte window. A burst starts at byte addr and covers len bytes. A burst whose last byte lies past FF wraps, which is the case the designers worry about most.

The coverage plan asks two questions. In which of the four regions of the window did bursts start? Did any burst end past the end of the window? Neither answer is a raw field: both are computed from addr and len.

A failed burst is retried with the same values. A retry is not new traffic, so it must not count.

Write the function region_of and the covergroup burst_cov.

Signals in the Timeline

SignalWidthRole
samples8input of each check
Full specification
Given (in the preamble) and what you write
typedef enum bit [1:0] {CSR, BUF, FIFO, ROM} region_e;   // given

function automatic region_e region_of(bit [7:0] a);   // you write
covergroup burst_cov with function sample(bit [7:0] addr, bit [3:0] len, bit retry);   // you write
RegionByte addresses (hex)
CSR00 to 0F
BUF10 to 7F
FIFO80 to BF
ROMC0 to FF
CoverpointValueBins
regionregion_of(addr)the four regions (automatic enum bins)
lastthe address of the last byte, addr + len - 1, with the carry kept (9 bits)in_window = 0 to 255, past_end = 256 to 270

Neither coverpoint counts a sample with retry = 1. Each case samples a fresh instance and reads get_inst_coverage() times 100, rounded: 7500 means 75.00%.

The full check samples more lists than the examples show, including bursts at every region boundary and at the window end.

Examples

Example 1

Two Bursts, Both Inside the Window
Input
bursts (addr, len, retry): (04, 2, 0) (40, 8, 0)
Output
coverage_percent_x100 = 5000

CSR and BUF: 2 of 4 regions. Both last bytes (05, 47) are in the window: 1 of 2. The average is 50.00%.

Example 2

A Burst Past the End
Input
bursts (addr, len, retry): (90, 4, 0) (fa, 8, 0) (c0, 1, 1)
Output
coverage_percent_x100 = 7500

FA + 8 - 1 is 101 hex, past the end. The retry at C0 counts for nothing, so ROM comes only from FA. That is 2 of 4 regions and 2 of 2 last-byte bins.

Example 3

A Retry That Would Have Filled Two Bins
Input
bursts (addr, len, retry): (f9, 8, 1) (08, 1, 0)
Output
coverage_percent_x100 = 3750

The retried burst at F9 is skipped. Only CSR and in_window are hit: (25 + 50) / 2 = 37.50%.

Constraints and Contract

  • Keep the covergroup name, the sample arguments and the coverpoint and bin names.
  • Use exactly these two coverpoints, with no cross.
  • The coverage build ignores a declared coverpoint type (lesson C11): keep the carry with a cast in the expression.

Hints

Hint 1

A coverpoint can sample a function call. A function that returns region_e gives one automatic bin per region.

Hint 2

How many bits does the last-byte value need? What happens to FC + 8 - 1 if anything on its way is only 8 bits wide?

Hint 3

A coverpoint iff guard is evaluated at each sample. Both coverpoints need it.

What the grader checks: Your covergroup is sampled with 20 lists of two to twelve bursts. 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 region boundary, the window end and retries.

20 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

Two Bursts, Both Inside the Window

Input
bursts (addr, len, retry): (04, 2, 0) (40, 8, 0)
Expected output
coverage_percent_x100 = 5000

CSR and BUF: 2 of 4 regions. Both last bytes (05, 47) are in the window: 1 of 2. The average is 50.00%.

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

Verilator coverage build · server