ChipTalkOfficial home
UVM & SystemVerilog · Debug & Coverage

Two transfers went in. Why does the UVM scoreboard see the second one twice?

Follow two bytes from the bus to the scoreboard to see what a transaction handle actually remembers.

Reader level · Students who know the basics of SystemVerilog classes, engineers debugging a UVM testbench, and leads reviewing a monitor.

The waveform shows two accepted transfers. The first carries 0x31, the second 0xA8. The monitor prints both correctly. A little later, the scoreboard opens its queue. There are two entries, just as expected. Both contain 0xA8.

Where did 0x31 go?

Start with the line that saves a transaction for later. In SystemVerilog, a variable of class type holds a handle to an object. If the scoreboard puts that handle in a queue, it can find the object again later. Whether it can still find the original byte depends on what happened to the object in the meantime.

Follow the first byte

Suppose a monitor creates one transaction object when it starts. Each time the interface accepts a transfer, the monitor fills in the object’s data field and sends it through a UVM analysis port. Two components subscribe. A logger prints data immediately. A scoreboard saves the handle and waits until both transfers have arrived before reading its queue.

Here is the hand-worked sequence. No simulation was run.

EventWhat the logger printsWhat the scoreboard holds
Monitor sets data to 0x31 and publishes0x31One handle to the object
Monitor changes data to 0xA8 and publishes again0xA8Two handles to the same object
Scoreboard reads both entries—First read 0xA8, second read 0xA8

The decisive moment is the start of the second transfer. The first queued entry already reads 0xA8 as soon as the monitor overwrites the field. Even if you stop the simulation just before the second publication, the first byte is gone from the object. The logger’s earlier message still says 0x31 because it recorded the value while that value was present.

Accellera’s UVM implementation shows the handoff directly. The analysis port calls each connected subscriber’s write() with the same argument. For a class transaction, each subscriber receives a handle to the same object.

Decide what the scoreboard needs to remember

If the scoreboard needs the whole transaction, a straightforward fix belongs in the monitor. Create a fresh object for each observed transfer, fill its fields, and publish it when complete. Treat the published fields as read-only. The first queue entry can then point to the object holding 0x31 while the monitor fills a different object with 0xA8. The monitor can reuse the same variable name on every pass through its loop. What matters is which object that variable points to.

If the scoreboard compares only a byte, the fix can be smaller. Have its write() callback read data immediately and push that byte into a queue of byte values. Now the queue holds 0x31 and 0xA8 directly. Choose the fields deliberately. If the comparison also depends on an address or transfer ID, capture those at the same time so each byte stays paired with the transfer that produced it.

Make the bug easy to catch

Use two different bytes and hold the scoreboard consumer until the monitor has published both transfers. Check the queue depth, then read the entries and compare them in order. The expected result is exactly two entries containing 0x31 followed by 0xA8.

Three choices can hide the problem during debug.

For a monitor review, ask the author to pause the example after the second transfer and point to where the first byte still lives. A separate published object and a queue of captured values are both clear answers. If the only place anyone can find 0x31 is the log, the checker has lost the observation it was meant to verify.

Sources and further reading