Module 2: TLM and Data Flow | Intermediate UVM

Blocking and Nonblocking TLM

Learn how blocking and nonblocking TLM operations control transaction flow, synchronization, and consumer behavior in reusable UVM environments.

Learning objectives

  • Explain the difference between blocking and nonblocking TLM operations.
  • Understand why blocking operations naturally synchronize producer and consumer processes.
  • Use get(), peek(), try_get(), and try_peek() appropriately.
  • Understand the relationship between TLM interface type and communication semantics.
  • Choose blocking or nonblocking communication based on the behavior of the verification component.
  • Recognize common synchronization and polling mistakes.
  • Build and debug a scoreboard using both blocking and nonblocking retrieval.

Step 1: What does "blocking" mean?

In TLM, a blocking operation is an operation that can wait until the requested communication can be completed.

For example, a scoreboard can wait for the next transaction:

packet_fifo.get(pkt);

If the FIFO contains a transaction, the call returns it. If the FIFO is empty, the process waits.




FIFO contains packet
|
v
get(pkt)
|
v
returns immediately

FIFO is empty
|
v
get(pkt)
|
v
process waits
|
|  transaction arrives
v
get(pkt) returns 

Blocking does not mean that the entire simulation stops. Only the process performing the blocking operation waits. Other simulation processes continue to execute.

Important: a blocking TLM operation blocks the calling process, not the entire UVM simulation.

Step 2: What does "nonblocking" mean?

A nonblocking TLM operation returns immediately instead of waiting for the requested transaction or communication opportunity.

For a FIFO, the most common example is:

if (packet_fifo.try_get(pkt)) begin


// Transaction was available
end
else begin
// FIFO was empty
end

The process continues regardless of whether a transaction was available.




FIFO contains packet
|
v
try_get(pkt)
|
v
returns 1
|
v
process continues with packet

FIFO is empty
|
v
try_get(pkt)
|
v
returns 0
|
v
process continues without packet 

This gives the consumer control over what it does when data is unavailable.

Step 3: Why does this matter in verification?

Verification components often have different execution requirements.

Consider three examples:

  • A scoreboard may naturally wait for the next transaction.
  • A monitor may need to continue observing interface activity.
  • A scheduler may periodically check whether work is available while performing other tasks.

There is no universally "better" communication mode. The correct choice depends on the behavior of the component.

Design principle: choose the TLM operation that matches the synchronization model of the component, rather than choosing blocking or nonblocking simply because one appears more advanced.

Step 4: The basic FIFO operations

UVM TLM FIFOs provide several useful operations.

Operation Behavior Typical use
get() Blocking retrieve Wait for and consume the next transaction
peek() Blocking inspect Wait for and inspect without removing
try_get() Nonblocking retrieve Consume only if an item is immediately available
try_peek() Nonblocking inspect Inspect only if an item is immediately available

The most important distinction is:

  • get: wait and remove.
  • peek: wait but do not remove.
  • try_get: do not wait; remove if available.
  • try_peek: do not wait; inspect if available.

Step 5: Blocking get() in a scoreboard

A classic scoreboard architecture uses a forever loop that waits for transactions.

task run_phase(uvm_phase phase);


packet pkt;

forever begin


packet_fifo.get(pkt);

check_packet(pkt);


end

endtask

This is often preferable to polling because the scoreboard has no useful work to perform until a transaction arrives.

The code clearly expresses the intended behavior:




Wait for transaction
|
v
Receive transaction
|
v
Check transaction
|
v
Wait for next transaction 

This is simple, efficient, and easy to reason about.

Step 6: Nonblocking try_get()

Suppose a component cannot simply wait for a transaction because it has other periodic work to perform.

task run_phase(uvm_phase phase);


packet pkt;

forever begin


if (packet_fifo.try_get(pkt)) begin
  check_packet(pkt);
end

perform_periodic_work();

#10ns;


end

endtask

The important difference is that try_get() never waits for the FIFO.

However, this pattern introduces a new design concern: polling frequency.

Step 7: Avoid unnecessary polling

A common beginner implementation is:

forever begin


if (packet_fifo.try_get(pkt)) begin
check_packet(pkt);
end

end

This is usually a poor design because the process can repeatedly check an empty FIFO without performing useful work.

Conceptually:




try_get()
try_get()
try_get()
try_get()
try_get()
... 

If there is no reason to poll continuously, a blocking operation is normally cleaner:

packet_fifo.get(pkt);

Step 8: peek() versus get()

Sometimes a consumer needs to inspect the next transaction before deciding whether to consume it.

packet_fifo.peek(pkt);


// Inspect pkt without removing it

packet_fifo.get(pkt);

// Remove it when ready 

The key property is that peek() does not remove the transaction.

This can be useful when a consumer needs to examine transaction metadata before committing to consumption.

Be careful with designs that repeatedly peek without eventually consuming. The same transaction will remain at the front of the FIFO.

Step 9: Nonblocking try_peek()

The nonblocking counterpart is try_peek().

if (packet_fifo.try_peek(pkt)) begin


`uvm_info("FIFO",
$sformatf("Next packet id=%0d", pkt.id),
UVM_MEDIUM)

end

If the FIFO is empty, the operation immediately reports that no transaction is available.

Again, the transaction remains in the FIFO because it was only inspected.

Step 10: Blocking does not mean "slow"

A common misconception is that blocking operations are inherently inefficient. That is not correct.

A blocking operation allows the simulator to suspend the calling process until the required event occurs.

For a scoreboard that has no useful work until a transaction arrives, this is exactly what we want.

packet_fifo.get(pkt);

The process sleeps while waiting rather than repeatedly asking:

"Is there a packet?"


"Is there a packet?"
"Is there a packet?"
... 

Therefore, blocking can actually produce a cleaner and more efficient synchronization model.

Step 11: Blocking versus nonblocking TLM interfaces

The idea extends beyond FIFO operations. UVM provides different TLM interfaces with different communication semantics.

For example, blocking put/get interfaces allow operations that may wait, while nonblocking interfaces provide operations that return immediately with success/failure information.

Conceptually:




Blocking:

producer ----> put() ----> waits if necessary

Nonblocking:

producer ----> try_put() ----> returns immediately
|
+--> success
|
+--> failure 

The same principle applies to retrieval:




Blocking:

get()      -> wait until transaction exists

Nonblocking:

try_get()  -> return immediately
success if transaction exists
failure otherwise 

The operation's semantic contract matters more than the specific method name.

Step 12: Blocking and nonblocking are not the same as synchronous and asynchronous

These terms are related but should not be treated as interchangeable.

  • Blocking: the calling process may wait for the operation.
  • Nonblocking: the operation returns without waiting.
  • Synchronous: communication is coordinated around a defined interaction or completion point.
  • Asynchronous: producer and consumer can progress more independently.

A FIFO can provide buffering that makes producer and consumer more independent, but the consumer can still use a blocking get().

Remember: buffering, blocking, and synchronization describe different aspects of the communication architecture.

Step 13: Choosing the right operation

Situation Recommended approach Reason
Scoreboard waits for next transaction get() Natural event-driven synchronization
Need to inspect next transaction without consuming peek() Preserves FIFO contents
Process has other work and cannot wait try_get() Immediate return
Need optional inspection without waiting try_peek() Immediate return without removal
Continuous polling with no other work Usually get() Avoid unnecessary polling

Step 14: Practical scoreboard architecture

Consider a scoreboard that receives both expected and actual transactions.




Expected monitor
|
v
expected_fifo
|
|
+----------+
|
v
Scoreboard
^
|
+----------+
|
actual_fifo
^
|
Actual monitor 

The scoreboard may need to wait for both streams.

task run_phase(uvm_phase phase);


packet expected;
packet actual;

forever begin


expected_fifo.get(expected);
actual_fifo.get(actual);

compare(expected, actual);


end

endtask

This is simple for strictly synchronized, in-order traffic. More sophisticated protocols may require independent collection and transaction correlation, which will be addressed in later lessons.

Step 15: A more careful multi-stream consumer

Suppose expected and actual transactions do not necessarily arrive at exactly the same time.

Blocking on the expected FIFO first can prevent the scoreboard from examining actual transactions that have already arrived.

This illustrates an important architectural lesson:

When multiple independent streams must be handled concurrently, consider separate processes, synchronization mechanisms, or a more appropriate scoreboard architecture.

Do not solve every multi-stream problem by adding try_get() polling. First understand the required transaction relationships.

Step 16: Debugging blocking TLM

A frequent debug symptom is:

Scoreboard appears to hang at:


packet_fifo.get(pkt); 

This does not necessarily mean the FIFO implementation is broken. It may simply mean that no transaction has arrived yet.

Debug the path in order:

  1. Is the monitor observing valid interface activity?
  2. Does the monitor call analysis_port.write()?
  3. Is the analysis port connected to the FIFO?
  4. Was the FIFO constructed?
  5. Is the scoreboard's run_phase active?
  6. Is the test ending before the expected transaction arrives?

Add instrumentation around the producer and consumer:

`uvm_info("MONITOR",
      "Publishing transaction",
      UVM_MEDIUM)


analysis_port.write(pkt);

`uvm_info("SCOREBOARD",
"Waiting for transaction",
UVM_MEDIUM)

packet_fifo.get(pkt);

`uvm_info("SCOREBOARD",
"Transaction received",
UVM_MEDIUM)

These messages tell you whether the problem is upstream of the FIFO, inside the connection, or in the consumer.

Step 17: Common mistakes

Mistake 1 — Treating blocking as a simulation-wide stall. Only the calling process waits. Other UVM processes continue to execute.
Mistake 2 — Using try_get() in a tight loop. This can create unnecessary polling. If waiting is the intended behavior, use get().
Mistake 3 — Assuming nonblocking is always better. Nonblocking operations are useful when the process cannot wait, but they add responsibility for handling the "no transaction available" case.
Mistake 4 — Confusing peek() and get(). peek() does not remove the transaction.
Mistake 5 — Ignoring control-flow consequences. Where a component blocks can determine whether another stream is serviced promptly.
Mistake 6 — Debugging the consumer before proving the producer. First establish that the transaction is actually being published.

Practice: Compare blocking and nonblocking consumers

Create an analysis FIFO connected to a monitor. Generate five transactions with IDs 0 through 4.

Part A — Blocking consumer

Implement a scoreboard using:

packet_fifo.get(pkt);

Print each received transaction.

Part B — Nonblocking consumer

Implement a consumer using:

packet_fifo.try_get(pkt)

The consumer should perform another piece of work whenever no packet is available.

Part C — Compare

Explain:

  • which process waits,
  • what happens when the FIFO is empty,
  • how many times the consumer checks the FIFO, and
  • which implementation is easier to reason about for a scoreboard that has no other work.

Challenge: Avoid unnecessary polling

You inherit this code:

forever begin


if (packet_fifo.try_get(pkt)) begin
check(pkt);
end

end

The FIFO is empty most of the time. The component performs no other work.

Refactor the architecture so that the process waits efficiently for transactions.

Reveal the solution
forever begin


packet_fifo.get(pkt);

check(pkt);

end

Because the process has no useful work to perform while waiting, blocking retrieval directly expresses the desired behavior.

Debugging challenge

A scoreboard contains:

task run_phase(uvm_phase phase);


packet pkt;

forever begin


`uvm_info("SB", "Waiting for packet", UVM_MEDIUM)

packet_fifo.get(pkt);

`uvm_info("SB", "Packet received", UVM_MEDIUM)


end

endtask

You see:

SB: Waiting for packet

but never:

SB: Packet received

Determine whether the correct first response is to replace get() with try_get().

Reveal the reasoning

No. Replacing get() with try_get() changes the symptom, not necessarily the problem.

If the scoreboard is correctly designed to wait for a transaction, blocking get() may be exactly what it should be doing.

First verify the upstream path:

  1. Is the monitor producing a transaction?
  2. Does it call analysis_port.write()?
  3. Is the analysis connection correct?
  4. Was the FIFO constructed?
  5. Does the test actually generate the expected traffic?

Use nonblocking operations for a genuine architectural requirement, not simply to hide a missing transaction.

Knowledge check

  1. What happens when get() is called on an empty FIFO?
  2. What is the difference between get() and peek()?
  3. What is the difference between try_get() and try_peek()?
  4. Why is a tight try_get() loop often a poor design?
  5. Does a blocking operation stop the entire simulation?
  6. Why can the location of a blocking operation matter in a multi-stream scoreboard?
  7. When should you prefer blocking retrieval?
Answers
  1. The calling process waits until a transaction becomes available.
  2. Both can wait for a transaction, but get() removes it while peek() leaves it in the FIFO.
  3. Both return immediately. try_get() removes an available transaction; try_peek() only inspects it.
  4. It can repeatedly poll an empty FIFO without doing useful work.
  5. No. Only the process performing the blocking operation waits.
  6. It determines where the consumer stops executing and can therefore affect how independently arriving streams are serviced.
  7. Prefer it when the consumer naturally waits for the next transaction and has no useful work to perform while the FIFO is empty.

Key takeaways

  • Blocking operations may wait; nonblocking operations return immediately.
  • get() waits and consumes, while peek() waits without consuming.
  • try_get() and try_peek() return immediately when data is unavailable.
  • Blocking a TLM operation blocks only the calling process, not the entire simulation.
  • A blocking scoreboard can be simpler and more efficient than a polling-based scoreboard.
  • Nonblocking operations are appropriate when the consumer genuinely has other work to perform instead of waiting.
  • Avoid tight polling loops when a blocking operation naturally expresses the required behavior.
  • The placement of blocking operations matters in multi-stream verification components.
  • Do not replace get() with try_get() merely because a scoreboard appears to be waiting. First debug the transaction path.
  • Blocking/nonblocking semantics are separate from buffering and protocol-level backpressure. Keep these concepts distinct when designing TLM architectures.