Verification #37 · 2026-10-30 · Casting · Easy · about 10 min

The cast that keeps the last write

A monitor collects transactions in a queue of base-class handles, txn q[$]. Some are wr_txn (they carry data) and some are rd_txn (they don't).

sum_writes(q) must return the sum of data over the write transactions in q. Reads add nothing, wherever they are in the queue. The queue may be empty, may hold only reads, and may hold any mix.

Run sums a queue of two writes (5 and 10) and three reads, and gets the wrong total. Fix tally.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.