B2.5.2 Repair the End of the Test

MediumFix20 minIcarus · browser samples / server checksReview the topic

The bench's end-of-test logic says PASS for a design that never answered. It also times out a slow design and misses an extra answer. Find its three faults and repair it.

Hardware context: The end-of-test logic of a bench, and a small UART transmitter that may never finish. Debugging a run that stopped on its time limit.

Every run of the bench ends here. test_end counts the answers and gives up after QUIET clocks with no progress. It waits DRAIN clocks after the last expected answer to catch extra ones. Then it decides.

This copy has three faults. One of them turns a silent design into a PASS, the false pass of the lesson. Repair it.

Signals in the Timeline

SignalWidthRole
scenario4input of each check
Full specification
At a rising edge, while runningWhat test_end does
got = 1, bad = 1verdict 2 (a wrong answer) at once.
got = 1 after the last expected answerverdict 4 (an extra answer) at once.
got = 1, otherwisereceived + 1; progress, so the quiet count starts again. When received reaches expected, the drain begins.
no got, during the drainAfter DRAIN such clocks, verdict 1 (PASS).
no got, otherwisequiet + 1. When quiet reaches QUIET, verdict 3 (timeout): a failure, never a pass.

With expected = 0 the drain begins at start. end_cycle is the number of rising edges after start at which the verdict was decided. After that nothing changes until the next start.

Examples

Example 1

Three Answers, All Right
Input
expected 3; answers at clocks 4, 8, 12
Output
verdict = 1, end_cycle = 16

Answers at clocks 4, 8 and 12; the third starts a drain of 4 clocks, so PASS is decided at clock 16.

Example 2

A Design That Never Answers
Input
expected 3; answers at clocks none
Output
verdict = 3, end_cycle = 20

No answer ever comes. After 20 quiet clocks the verdict is 3, a timeout: a failure with a reason, at clock 20.

Example 3

The Second Answer Is Wrong
Input
expected 3; answers at clocks 4, 8 (wrong), 12
Output
verdict = 2, end_cycle = 8

The second answer is wrong, so the test fails at once, at clock 8.

Constraints and Contract

  • Keep the module name, the parameters, the ports, verdict and end_cycle.
  • QUIET is 20 and DRAIN is 4 in every case.

Hints

Hint 1

What verdict does a timeout give here?

Hint 2

When does the quiet count start again?

Hint 3

What happens between the last expected answer and the verdict?

What the grader checks: Eleven runs of 120 clocks with QUIET = 20 and DRAIN = 4. They cover right answers, silence, a wrong answer, a slow design, extra answers, gaps of 19 and 20 clocks, and none expected. The bench reads verdict and end_cycle at the end of each run.

11 checks on Icarus · browser samples / server checks. 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 problems on this path

Report a problem with this page

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

Three Answers, All Right

Input
expected 3; answers at clocks 4, 8, 12
Expected output
verdict = 1, end_cycle = 16

Answers at clocks 4, 8 and 12; the third starts a drain of 4 clocks, so PASS is decided at clock 16.

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

Icarus · browser samples / server checks