C19.3 Shared Covergroup in a Package

MediumImplementVerilator coverage build · serverReview the topic

Share one kind covergroup through a package and shape a length covergroup with a class parameter, in a monitor with two covergroups.

Hardware context: Two links with different maximum packet lengths and one shared kind model. Share kind coverage through a package and size length bins with a class parameter.

Two links carry packets of different maximum lengths: 4 beats on one, 8 on the other. Both need the same kind coverage, and length coverage that fits their own maximum.

Write the package link_cov_pkg with the covergroup kind_cg, and the parameterised class link_mon that holds an instance of it and an embedded length covergroup lens.

Signals in the Timeline

SignalWidthRole
samples8input of each check
Full specification
What the testbench does (given)
link_mon #(4) m4;   link_mon #(8) m8;     // fresh per case
m4.observe(kind, len);                      // samples both covergroups
// report: m4.kinds, m4.lens, m8.kinds and m8.lens, each get_inst_coverage() x 100 rounded, summed
CovergroupBins
kind_cg (package), sample(bit [1:0] k)rd = 0, wr = 1, cfg = 2
lens (embedded, on len)one = 1, mid[] = 2 to MAX_LEN - 1, max = MAX_LEN

The full check samples more lists than the examples show.

Examples

Example 1

One Packet on the Short Link
Input
packets (link, kind, len): (m4, 0, 1)
Output
coverage_percent_x100 = 5833

m4.kinds 1 of 3 (3333) and m4.lens 1 of 4 (2500); m8 adds 0: 5833.

Example 2

Length 4 on Both Links
Input
packets (link, kind, len): (m4, 1, 4) (m8, 1, 4)
Output
coverage_percent_x100 = 10416

On m4, 4 is max; on m8 it is mid[4]. Each monitor: 1 of 3 kinds and 1 length bin (2500 and 1250).

Example 3

Long Packets
Input
packets (link, kind, len): (m8, 2, 8) (m8, 0, 6) (m8, 3, 9)
Output
coverage_percent_x100 = 9167

m8 sees cfg and rd (kind 3 has no bin) and lengths 8 and 6; 9 is in no bin: 6667 + 2500.

Constraints and Contract

  • Keep the package, class, member and covergroup names, observe(bit [1:0] k, bit [3:0] l), and the class parameter MAX_LEN.
  • kinds is an instance of the package covergroup; lens uses MAX_LEN in its bins.

Hints

Hint 1

A class member can have a covergroup type from a package: link_cov_pkg::kind_cg kinds;.

Hint 2

An embedded covergroup can use the class parameters in its bins.

Hint 3

Construct both covergroups in the class constructor, and sample both in observe().

What the grader checks: Two monitors per case are sampled with 18 lists of packets. The sum of the four instance numbers is compared with the values IEEE 1800-2023 clause 19 gives. 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 Packet on the Short Link

Input
packets (link, kind, len): (m4, 0, 1)
Expected output
coverage_percent_x100 = 5833

m4.kinds 1 of 3 (3333) and m4.lens 1 of 4 (2500); m8 adds 0: 5833.

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

Verilator coverage build · server