RTL Foundations / F16

Delivering a Small IP Block: Can Another Engineer Reproduce the Result?

Replay a collector and a checker-result controller. Verify completed work, delivery and reset cancellation from independent records.

Lesson film

Film chapters

TranscriptCaptionsDownload film

When you take over a collector, ask two questions. What did it accept at this edge? Which record can I check against it? In F16A we connect the data path, counter, finite state machine (FSM) and buffer from the earlier lessons. F16B uses the same accept, save and deliver pattern for the trusted checker’s result controller.

F16A | From starting a group to delivering its report

In IDLE, collector_top.sv accepts start_valid && start_ready. It then collects four unsigned eight-bit samples. The sum advances on sampled edges with sample_valid && sample_ready. A start offered during COLLECT leaves the current job in progress. The largest sum is FF + FF + FF + FF = 3FC, so the result needs ten bits.

The sample valid/ready handshake feeds the counter and accumulator. The fourth accepted sample moves the FSM to REPORT, with the sum stored in sum_q. The buffer receives it at a later handshake.
The FSM hands a report to the buffer. The receiver later takes it from the buffer. Each transfer has its own handshake.

After the fourth sample, the FSM enters REPORT and sum_q holds the final total. Acceptance at the buffer input sends the FSM back to IDLE. The receiver takes a report only when out_valid && out_ready is true. If the buffer is still holding an old report, REPORT retains the new sum until the buffer makes room.

Replay the main case and its boundaries

The test starts the job at E1 and accepts 11, 22, 33 and 44 at E2, E4, E6 and E7. The values are hexadecimal. E3 and E5 have no valid sample. A second start at E4 leaves the current job in place. At E8, 0AA enters the buffer. The receiver stalls at E9 through E11 and accepts the result at E12. Run the same fixture with a counter that advances on every COLLECT cycle. Its first mismatch is at E6. The independent record holds just two accepted samples, but the faulty design has already stopped accepting them.

The collector accepts four samples at E2, E4, E6 and E7, then buffers 0AA at E8. It holds the valid result through three stalls and delivers it at E12.
Observed sample and output records from the simulation. The waiting value is 0AA at each sample from E9 through E12.

The scoreboard sums accepted samples independently in the testbench, then compares each output word with its expected result in order. The four-FF boundary case delivers 3FC at E19. E22 cancels a partially collected group. E29 cancels a queued 00A. The new epoch can begin again, and E36 delivers 01A. The suite completes four groups and delivers three. One finished report and one partial job are cancelled.

F16B | Follow one job from request to delivery

Now use the pattern for a checker-result controller. The controller accepts one job at a time and notifies an external checker when it takes a request. The trusted checker returns done, pass and the job ID. Both sides in the main example share a active-low synchronous reset that cancels their work. The checker sends no replies for cancelled jobs. The teaching checker_stub.sv uses a decision preset by the test and replies three sampled edges later.

The controller keeps two flags. A valid done sets checked=1 to record that the checker finished. Only pass=1 also sets verified=1. Job IDs are hexadecimal with a 0x prefix. Labels starting with B mark sampling edges. Job 0xA1 comes back with a failed result at B4. After that sample, checked is one and verified is zero. At B5, both delivery_valid and delivery_ready are high, so rejection retires the job. The next request starts with a fresh record.

The trusted checker drives done and pass. Job 0xA1 completes and fails. Job 0xC3 completes and passes, and the receiver takes it at the following edge.
B4 and B11 sample completion replies. After capture, B5 rejects job 0xA1 and B12 accepts job 0xC3.

Check accept against a separate history

The delivery event is accept = delivery_valid && delivery_ready && grant. Grant requires a current job that has finished and passed. Reset gates grant low. The matching reply for 0xC3 is sampled at B11. Its decision has yet to be stored at that sample, so this fixture delivers job 0xC3 at B12. A done event while idle or after a job is already checked leaves the result unchanged.

The testbench builds a history from the request handshakes and checker replies. It records the accepted request ID, whether the reply matches, and whether that job has completed successfully. At every sampled edge it computes the expected delivery from that history and compares it with accept. Using the DUT’s grant as the answer would repeat F15’s conditional definition and would leave the source of the decision unchecked.

How does the controller recognize replies after reset?

At B6 the controller accepts job 0xB2. B7 cancels it on reset. B8 begins a new job, 0xC3. In the shared-reset example, the checker is silent at B9. A separate-reset test fixture checks compatibility with a checker that missed the cancellation. That model reports the old ID 0xB2 at B9. The controller is waiting for 0xC3, so it discards the mismatched reply. The scoreboard records an INVALID_REPLY and checks that grant and accept are both low at that edge.

B7 cancels job 0xB2. B8 requests 0xC3. The controller ignores the separate-reset fixture’s 0xB2 reply at B9. It records the matching 0xC3 reply at B11 and delivers it at B12.
Both reset models deliver only job `0xC3`. Their difference at B9 is whether the monitor observes an out-of-contract reply.

With no ID field, busy and done alone cannot establish which job a reply belongs to. This implementation compares the reply ID with the ID of the waiting job. The testbench assigns distinct IDs across functional reset. An allocator that also resets could reuse an ID and make two jobs indistinguishable. A real interface needs an agreed ID or generation lifetime. Keep jobs distinguishable while any old reply can still arrive. Reuse an ID only after confirming that the old work has drained.

At B16, reset, done, delivery valid and delivery ready coincide. Cancellation takes priority and both grant and accept stay low. The B22 test asserts reset after a passing result is already stored and also sees grant go low. The two testbenches use E and B respectively to label their independent timelines.

Point each claim back to a reproducible record

Extract the lab package on Linux or WSL and run bash run.sh. The README records the interface, synchronous reset, trusted checker, one-job limit, and ID lifetime and reuse rules. Icarus logs what was actually delivered. The Yosys generic netlist reveals adders, muxes, registers and the state machine. In this run the fsm pass recoded the collector’s two-bit state into three-bit one-hot. The checker controller has four $sdffe cells, one of which holds the job ID. The evidence lists physical timing, CDC, fault resilience and checker algorithm validation as unexecuted.

Review the run summary, collector VCD, shared-reset checker VCD, separate-reset check trace, and version hashes and evidence. If a later exercise asks whether the stored verified flag remains trustworthy, this independent history gives it a repeatable comparison point. The current checks establish functional delivery in the stated scenarios.

What if two jobs can wait at once?

Send X and Y with a checker that may return them in either order. Can one pair of checked and verified flags still represent both jobs? What happens to each job on reset?

Answer

One flag pair describes one job. Give each job a distinct ID and its own pending, checked and verified state. An ordered receiver also needs a queue of expected delivery order. An out-of-order receiver needs an ID on each delivery. On reset, apply the agreed cancellation or drain rule to all outstanding jobs. The independent scoreboard can then match each reply and delivery to its request.

Read the handoff record

The handoff contains two interfaces. First trace four samples through the collector. Then switch to the result controller and see how completing a check differs from delivering its result. The table shows the relevant events.

Download RTL, testbench and results

Check your understanding

1. How wide is the complete sum of four unsigned eight-bit samples, and what is its maximum?
2. The first report enters the buffer at E8. The receiver raises ready at E12. When does it receive the report?
3. 0xA1 returns done high and pass low. What are checked and verified after the B4 update?
4. 0xC3 was accepted at B8. The separate-reset fixture reports 0xB2 at B9. What does the defensive controller do?
5. What should the scoreboard use to determine which job may be delivered?