C17.2 Filter the Cross

HardImplementVerilator coverage build · serverReview the topic

Cover an 8-port switch: loopback routes by a with filter, and the hot routes of a table without a set expression.

Hardware context: An 8-port switch with a table of hot routes. Cover loopback and hot routes across source and destination ports.

A switch has 8 ports and routes packets from src to dst. The plan crosses source and destination ports. It names two groups: every loopback route (destination equals source), and the three hot routes of the traffic table. All other routes stay as automatic bins.

In the standard, the cross could take the variables directly, and the hot routes could be a set expression. The coverage build reads 0% for the first and rejects the second (lesson C17). Write the runnable equivalents.

Signals in the Timeline

SignalWidthRole
samples8input of each check
Full specification
What you write
covergroup route_cov with function sample(bit [2:0] src, bit [2:0] dst);
  // coverpoints sp (on src) and dp (on dst), automatic bins
  routes: cross ... { loopback, hot }
endgroup
Hot routesrcdst
105
227
361

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

Two Loopbacks
Input
routes (src, dst): (3, 3) (4, 4)
Output
coverage_percent_x100 = 1727

Both are in loopback: 1 of 55 cross bins. sp and dp are at 2 of 8 each.

Example 2

A Hot Route
Input
routes (src, dst): (0, 5) (1, 2)
Output
coverage_percent_x100 = 1788

(0, 5) covers hot; (1, 2) is an automatic bin: 2 of 55.

Example 3

Order Matters
Input
routes (src, dst): (5, 0) (2, 7)
Output
coverage_percent_x100 = 1788

(5, 0) is not a hot route, only (0, 5) is; it is an automatic bin. (2, 7) covers hot.

Constraints and Contract

  • Keep the covergroup, coverpoint, cross and bin names; sp and dp keep their automatic bins.
  • Select both user bins with with: no tuple lists, no functions, no ignore or illegal bins.

Hints

Hint 1

In a cross with, the coverpoint names stand for the values of a product.

Hint 2

A product is in a with bin if the expression holds for it.

Hint 3

How many automatic bins remain after 8 loopback and 3 hot products are taken?

What the grader checks: Your covergroup is sampled with 18 lists of routes. Its instance coverage is compared with the value IEEE 1800-2023 19.6 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 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 Loopbacks

Input
routes (src, dst): (3, 3) (4, 4)
Expected output
coverage_percent_x100 = 1727

Both are in `loopback`: 1 of 55 cross bins. sp and dp are at 2 of 8 each.

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

Verilator coverage build · server