A8.1.1 Test the Testbench

MediumBreak ItVerilator · serverReview the topic

Write stimulus that keeps the bench's own rules and still makes an assertion suite catch four hidden faulty FIFOs.

Hardware context: A 4-entry FIFO with no back-pressure, its assertion suite and four faulty variants. Write legal stimulus that reaches every corner where a FIFO fault can hide.

A 4-entry FIFO has no back-pressure, so the bench promises never to push while full and never to pop while empty. Two assertions check those promises: they test the testbench.

Write the module stim. It drives one FIFO and reads only its flags. The bench runs your stimulus against the correct FIFO and four faulty ones, each watched by the same assertion suite. A fault is caught when the suite fails on it while your stimulus keeps the bench rules.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
push1stimulus, the same for every design
pop1stimulus, the same for every design
full1stimulus, the same for every design
empty1stimulus, the same for every design
Full specification
The ports (keep them)
module stim (
  input  logic       clk,
  input  logic       full, empty,          // the flags of the FIFO under test
  output logic       push = 0, pop = 0,
  output logic [7:0] wdata = 0
);
  // your stimulus
endmodule
CheckPasses when
Your inputsthe bench rules never fail, and the suite stays silent on the correct FIFO
Each hidden faultthe bench rules never fail, and the suite fails at least once

The faults are in the flags, the pointers and the counting. Think about the corners a FIFO has: full, empty, wrapping pointers, and a push and a pop in the same cycle.

Examples

Example 1

Legal Inputs
Input
Your stimulus on the correct FIFO
Output
legal = 1

No push while full, no pop while empty, and the correct FIFO passes every rule.

Example 2

One Fault Caught
Input
Your stimulus on a faulty FIFO
Output
caught = 1

This fault needs the FIFO filled.

Example 3

Another Fault Caught
Input
Your stimulus on a faulty FIFO
Output
caught = 1

This fault needs a push and a pop together, with one entry stored.

Constraints and Contract

  • Drive push, pop and wdata from the module stim. Change them only on the falling edge of clk.
  • Never push while full and never pop while empty, as the flags of your FIFO show them.

Hints

Hint 1

A fault in the full flag only shows when the FIFO is filled.

Hint 2

A pointer that fails to wrap only shows after more reads than entries.

Hint 3

Some faults need a push and a pop in the same cycle, with one entry stored.

What the grader checks: Your stimulus runs against the correct FIFO and four hidden faulty variants in one simulation. Graded: the bench rules hold on every run and the suite is silent on the correct FIFO. Each faulty variant must make it fail.

5 checks on Verilator · 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 1 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

Legal Inputs

Input
Your stimulus on the correct FIFO
Expected output
legal = 1

No push while full, no pop while empty, and the correct FIFO passes every rule.

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

Verilator · server