RTL Foundations / F15

Assertions and Reachability: Did the Required Scenario Occur?

Read a real counterexample from the result-buffer lab and distinguish stability, reachability and bounded checking.

Lesson film

Film chapters

TranscriptCaptionsDownload film

Run F11’s result buffer for four rising edges. Reset it on the first edge and leave the input idle for the next three. Every stall-stability check passes. The same test also passes on the faulty buffer that drops valid too early. The receiver never held up a valid result, so there was nothing for either buffer to preserve.

What did the check exercise while valid was low?

A stalled sample means that a rising edge saw out_valid=1 and out_ready=0. Low ready alone tells us the receiver cannot take a word. With no word on offer, there is nothing pending. If the receiver keeps out_ready low while out_valid is one, it takes another sample to tell whether the buffer kept the word.

The idle test has no valid output at E1 through E3. Stability reads true, but no sample creates a hold obligation or reaches the delivery cover.
With valid low throughout the idle test, the rule never has to check a held word. This is a vacuous pass.

The pass follows the meaning of a conditional. If the instruction is “compare the report when one arrives,” receiving no reports produces no comparison failures. To judge stalled behavior, we also need evidence that the receiver had a word to accept and left it waiting.

Write the hold rule across two samples

The contract keeps F11’s synchronous reset. If a sampled edge saw a valid result blocked, and reset is inactive at the next sample, that sample must still see valid high and the same payload. If the receiver raises ready by then, the word it receives is the one that was waiting.

The directed test puts 31 in the slot at E1. At E2 the buffer holds 31, and ready is low. Ready returns at E3. The main version delivers 31 on E3. The pulse version drops valid after the E2 update, so the E3 sample violates the hold rule.

Both versions stall with 31 at E2. At E3 ready is high, the main design transfers 31, and the pulse version violates the rule by dropping valid.
Each column shows what the sampling edge sees. The pulse version still has 31 on its data pins, but valid is low.

The executable checker saves was_stalled and held_data at the previous edge. A third signal, past_valid, becomes high only after the first sample. This prevents the first check from using history before it has been captured. Reset at the previous sample also prevents that sample from creating a hold obligation.

assign hold_required = past_valid && rst_ni && was_stalled;
assign stable_ok = !hold_required || (out_valid && out_data == held_data);

The Icarus testbench and the formal harness use the same checker. The directed test also stalls at E6 and samples reset at E7. Reset cancels the pending delivery and the E7 hold obligation.

Ask cover for a real example

An assert asks whether any behavior allowed by the assumptions can break the rule. The assume statements define that environment. This harness samples reset once at the start and keeps it released afterward. A blocked input source must also keep its valid and payload at the next edge. The solver can choose output ready and the input values.

A cover asks whether a scenario can happen. Here it needs a genuine stall at one edge and a transfer of the same word at the next. In the Yosys SAT witness, step 3 blocks B2 and step 4 delivers B2. The solver chose that byte. The 31 from the directed simulation belongs to a different trace.

In the SAT witness, step 3 has valid high and ready low with byte B2. In step 4, both signals are high and the same B2 transfers.
A cover trace establishes one way to reach the scenario. The assertion result tells us whether the bounded search found a legal way to break the rule.

Force out_ready=1. The faulty pulse version passes the assertion at depth eight because there can be no stall. Force in_valid=0 instead and it also passes, this time without ever offering an output. The stall-and-delivery cover is unreachable within either restricted model. Relax the extra assumptions and the cover becomes reachable, while the solver can again expose the pulse bug.

Read the failure by looking back one sample

In the ordinary environment, the eight-step Yosys SAT run found no stability counterexample for the main design. For the pulse version, step 6 has out_valid=1, out_ready=0 and data 00. At step 7, reset is still inactive and the hold obligation applies. The data pins still show 00, but valid has fallen. stable_ok becomes zero. Look back one row to see which word the buffer had promised to keep.

The recorded SAT counterexample shows valid high and ready low with 00 at step 6. At step 7 valid is low, the hold is required and the stability property fails.
Two adjacent rows from the SAT counterexample. Directed edges E2 and E3 reproduce the same type of failure.

One legal counterexample disproves the property. The run with no counterexample covers the stated model and eight-step bound. An all-time conclusion needs a proof beyond that bound, such as a successful induction argument. This property checks what happens after a stall, with no requirement for the receiver to raise ready eventually.

Read the SVA and replay the lab

The reading version defines stalled = rst_ni && out_valid && !out_ready to exclude reset samples. Its assertion reads stalled |=> (!rst_ni || (out_valid && $stable(out_data))). Here |=> evaluates the right side at the next sample. With |->, both sides evaluate at the same sample, so the left side uses $past(stalled) and guards it with past_valid. The expression specifies cancellation at the synchronous sample. The executable harness uses explicit registers and immediate assertions. See buffer_properties_reading.sv for the concurrent form. YosysHQ formal extensions to Verilog

Extract the lab package on Linux or WSL and run bash run.sh. The bundle also contains buffer.sby and bash run-sby.sh, replayed with SBY and Z3 at depth eight. That engine found the pulse failure at its step 3 and reached the main cover. The two engines may number samples differently and choose different values. Get the run summary, SAT counterexample, SAT cover witness, directed waveform or replay evidence.

Does accepted implying grant verify the basis for permission?

Suppose accepted = valid && ready && grant. The assertion only says accepted implies grant. When will that assertion pass? What could a separate check use to judge whether grant has a recorded basis?

Answer

The assertion always passes because grant is already part of the definition of accepted. That remains true even when transfers occur. Keep an independent record of requests and checker results. On delivery, check that the corresponding job was accepted, completed and passed. Use cover to confirm a legal delivery can occur and assert to check any allowed delivery. F16 applies this idea in an independent scoreboard.

What did the passing test exercise?

Record valid, ready and data at each rising edge. If the receiver stalls an offer, the source must still present that word at the next edge. Select a trace and find when this obligation begins.

Download RTL, testbench and results

Check your understanding

1. The idle test keeps out_valid low and every stability check passes. What does that say about stalls?
2. At E2 valid is high, ready is low and data is 31. At E3 ready is high and reset is inactive. What must the monitor see?
3. The ordinary environment reaches the stall-then-delivery cover within eight steps. What does the result establish?
4. E6 stalls a word and E7 samples rst_ni=0. What is the E7 hold obligation under this synchronous cancellation contract?
5. Accepted is already defined as valid && ready && grant. What separate record could justify grant?